summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-07-04 13:58:54 +0000
committered <ed@FreeBSD.org>2009-07-04 13:58:54 +0000
commit4981926bf654fe5a2c3893f24ca44106b217e71e (patch)
tree8ddfe382e1c6d590dc240e76f7cd45cea5c78e24 /tools
parentc1ff020ff2d3e7ba86f7ab986ac7569c34f2ab1a (diff)
downloadFreeBSD-src-4981926bf654fe5a2c3893f24ca44106b217e71e.zip
FreeBSD-src-4981926bf654fe5a2c3893f24ca44106b217e71e.tar.gz
Import Clang r74788.
Diffstat (limited to 'tools')
-rw-r--r--tools/clang-cc/clang-cc.cpp28
-rw-r--r--tools/driver/driver.cpp2
-rw-r--r--tools/index-test/index-test.cpp7
3 files changed, 30 insertions, 7 deletions
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index a3ffb48..9433c17 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -50,6 +50,7 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Version.h"
+#include "llvm/LLVMContext.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringExtras.h"
@@ -660,6 +661,11 @@ PICLevel("pic-level", llvm::cl::desc("Value for __PIC__"));
static llvm::cl::opt<bool>
StaticDefine("static-define", llvm::cl::desc("Should __STATIC__ be defined"));
+static llvm::cl::opt<int>
+StackProtector("stack-protector",
+ llvm::cl::desc("Enable stack protectors"),
+ llvm::cl::init(-1));
+
static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
TargetInfo *Target,
const llvm::StringMap<bool> &Features) {
@@ -779,6 +785,9 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
if (AccessControl)
Options.AccessControl = 1;
+ // OpenCL and C++ both have bool, true, false keywords.
+ Options.Bool = Options.OpenCL | Options.CPlusPlus;
+
Options.MathErrno = MathErrno;
Options.InstantiationDepth = TemplateDepth;
@@ -814,6 +823,15 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
Options.Static = StaticDefine;
+ switch (StackProtector) {
+ default:
+ assert(StackProtector <= 2 && "Invalid value for -stack-protector");
+ case -1: break;
+ case 0: Options.setStackProtectorMode(LangOptions::SSPOff); break;
+ case 1: Options.setStackProtectorMode(LangOptions::SSPOn); break;
+ case 2: Options.setStackProtectorMode(LangOptions::SSPReq); break;
+ }
+
if (MainFileName.getPosition())
Options.setMainFileName(MainFileName.c_str());
}
@@ -1729,7 +1747,8 @@ static llvm::raw_ostream* ComputeOutFile(const std::string& InFile,
///
static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
const std::string &InFile, ProgActions PA,
- const llvm::StringMap<bool> &Features) {
+ const llvm::StringMap<bool> &Features,
+ llvm::LLVMContext& Context) {
llvm::OwningPtr<llvm::raw_ostream> OS;
llvm::OwningPtr<ASTConsumer> Consumer;
bool ClearSourceMgr = false;
@@ -1796,7 +1815,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
InitializeCompileOptions(Opts, PP.getLangOptions(), Features);
Consumer.reset(CreateBackendConsumer(Act, PP.getDiagnostics(),
PP.getLangOptions(), Opts, InFile,
- OS.get()));
+ OS.get(), Context));
break;
}
@@ -2088,9 +2107,10 @@ InputFilenames(llvm::cl::Positional, llvm::cl::desc("<input files>"));
int main(int argc, char **argv) {
llvm::sys::PrintStackTraceOnErrorSignal();
llvm::PrettyStackTraceProgram X(argc, argv);
+ llvm::LLVMContext Context;
llvm::cl::ParseCommandLineOptions(argc, argv,
"LLVM 'Clang' Compiler: http://clang.llvm.org\n");
-
+
llvm::InitializeAllTargets();
llvm::InitializeAllAsmPrinters();
@@ -2264,7 +2284,7 @@ int main(int argc, char **argv) {
((PathDiagnosticClient*)DiagClient.get())->SetPreprocessor(PP.get());
// Process the source file.
- ProcessInputFile(*PP, PPFactory, InFile, ProgAction, Features);
+ ProcessInputFile(*PP, PPFactory, InFile, ProgAction, Features, Context);
HeaderInfo.ClearFileInfo();
DiagClient->setLangOptions(0);
diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp
index 804bef4..323283e 100644
--- a/tools/driver/driver.cpp
+++ b/tools/driver/driver.cpp
@@ -219,7 +219,7 @@ int main(int argc, const char **argv) {
int Res = 0;
if (C.get())
- Res = C->Execute();
+ Res = TheDriver.ExecuteCompilation(*C);
llvm::llvm_shutdown();
diff --git a/tools/index-test/index-test.cpp b/tools/index-test/index-test.cpp
index 5606e75..552b7b0 100644
--- a/tools/index-test/index-test.cpp
+++ b/tools/index-test/index-test.cpp
@@ -125,16 +125,19 @@ int main(int argc, char **argv) {
if (Point.D) {
llvm::raw_ostream &OS = llvm::outs();
- assert(Point.D && "If no node was found we should have exited with error");
OS << "Declaration node at point: " << Point.D->getDeclKindName() << " ";
if (NamedDecl *ND = dyn_cast<NamedDecl>(Point.D))
OS << ND->getNameAsString();
OS << "\n";
+ if (const char *Comment = AST->getASTContext().getCommentForDecl(Point.D))
+ OS << "Comment associated with this declaration:\n" << Comment << "\n";
+
if (Point.Node) {
OS << "Statement node at point: " << Point.Node->getStmtClassName()
<< " ";
- Point.Node->printPretty(OS, AST->getASTContext());
+ Point.Node->printPretty(OS, AST->getASTContext(), 0,
+ PrintingPolicy(AST->getASTContext().getLangOptions()));
OS << "\n";
}
}
OpenPOWER on IntegriCloud