aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Frontend')
-rw-r--r--lib/Frontend/ASTUnit.cpp5
-rw-r--r--lib/Frontend/CompilerInstance.cpp6
-rw-r--r--lib/Frontend/CompilerInvocation.cpp25
3 files changed, 26 insertions, 10 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index e2544027b5..c59f2d16d2 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -1041,6 +1041,7 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) {
// Configure the various subsystems.
// FIXME: Should we retain the previous file manager?
+ LangOpts = &Clang->getLangOpts();
FileSystemOpts = Clang->getFileSystemOpts();
FileMgr = new FileManager(FileSystemOpts);
SourceMgr = new SourceManager(getDiagnostics(), *FileMgr);
@@ -1247,7 +1248,7 @@ ASTUnit::ComputePreamble(CompilerInvocation &Invocation,
}
return std::make_pair(Buffer, Lexer::ComputePreamble(Buffer,
- Invocation.getLangOpts(),
+ *Invocation.getLangOpts(),
MaxLines));
}
@@ -2230,7 +2231,7 @@ void ASTUnit::CodeComplete(StringRef File, unsigned Line, unsigned Column,
FrontendOpts.CodeCompletionAt.Column = Column;
// Set the language options appropriately.
- LangOpts = CCInvocation->getLangOpts();
+ LangOpts = *CCInvocation->getLangOpts();
llvm::OwningPtr<CompilerInstance> Clang(new CompilerInstance());
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index ea2c3bd6c6..838a0675f2 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -987,11 +987,11 @@ static void compileModule(CompilerInstance &ImportingInstance,
// For any options that aren't intended to affect how a module is built,
// reset them to their default values.
- Invocation->getLangOpts().resetNonModularOptions();
+ Invocation->getLangOpts()->resetNonModularOptions();
Invocation->getPreprocessorOpts().resetNonModularOptions();
// Note the name of the module we're building.
- Invocation->getLangOpts().CurrentModule = ModuleName;
+ Invocation->getLangOpts()->CurrentModule = ModuleName;
// Note that this module is part of the module build path, so that we
// can detect cycles in the module graph.
@@ -1004,7 +1004,7 @@ static void compileModule(CompilerInstance &ImportingInstance,
FrontendOpts.DisableFree = false;
FrontendOpts.Inputs.clear();
FrontendOpts.Inputs.push_back(
- std::make_pair(getSourceInputKindFromOptions(Invocation->getLangOpts()),
+ std::make_pair(getSourceInputKindFromOptions(*Invocation->getLangOpts()),
UmbrellaHeader));
Invocation->getDiagnosticOpts().VerifyDiagnostics = 0;
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 1fd967ffcc..13be408141 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -30,6 +30,21 @@
#include "llvm/Support/Path.h"
using namespace clang;
+//===----------------------------------------------------------------------===//
+// Initialization.
+//===----------------------------------------------------------------------===//
+
+CompilerInvocation::CompilerInvocation()
+ : LangOpts(new LangOptions()) {}
+
+void CompilerInvocation::setLangOpts(LangOptions *LOpts) {
+ LangOpts = LOpts;
+}
+
+//===----------------------------------------------------------------------===//
+// Utility functions.
+//===----------------------------------------------------------------------===//
+
static const char *getAnalysisStoreName(AnalysisStores Kind) {
switch (Kind) {
default:
@@ -892,7 +907,7 @@ void CompilerInvocation::toArgs(std::vector<std::string> &Res) {
FileSystemOptsToArgs(getFileSystemOpts(), Res);
FrontendOptsToArgs(getFrontendOpts(), Res);
HeaderSearchOptsToArgs(getHeaderSearchOpts(), Res);
- LangOptsToArgs(getLangOpts(), Res);
+ LangOptsToArgs(*getLangOpts(), Res);
PreprocessorOptsToArgs(getPreprocessorOpts(), Res);
PreprocessorOutputOptsToArgs(getPreprocessorOutputOpts(), Res);
TargetOptsToArgs(getTargetOpts(), Res);
@@ -1982,9 +1997,9 @@ void CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
ParseCodeGenArgs(Res.getCodeGenOpts(), *Args, DashX, Diags);
ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), *Args);
if (DashX != IK_AST && DashX != IK_LLVM_IR) {
- ParseLangArgs(Res.getLangOpts(), *Args, DashX, Diags);
+ ParseLangArgs(*Res.getLangOpts(), *Args, DashX, Diags);
if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
- Res.getLangOpts().ObjCExceptions = 1;
+ Res.getLangOpts()->ObjCExceptions = 1;
}
// FIXME: ParsePreprocessorArgs uses the FileManager to read the contents of
// PCH file and find the original header name. Remove the need to do that in
@@ -2057,9 +2072,9 @@ std::string CompilerInvocation::getModuleHash() const {
// Extend the signature with the language options
#define LANGOPT(Name, Bits, Default, Description) \
- Signature.add(LangOpts.Name, Bits);
+ Signature.add(LangOpts->Name, Bits);
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
- Signature.add(static_cast<unsigned>(LangOpts.get##Name()), Bits);
+ Signature.add(static_cast<unsigned>(LangOpts->get##Name()), Bits);
#define BENIGN_LANGOPT(Name, Bits, Default, Description)
#define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
#include "clang/Basic/LangOptions.def"