diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-02-05 16:36:52 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-02-05 16:36:52 +0000 |
commit | 3ad86fd2effccf1b9337e8cb9a317e4353cec275 (patch) | |
tree | 5fdb879c0e095d904a9348553432156c21ea70d1 /lib/Frontend | |
parent | ee0feec7362053f22b6c01d12e1bfa06fb3ac93f (diff) |
[frontend] Don't put a PCH/PTH filename into the set of includes in the preprocessor options;
since only one of them is allowed in command-line, process them separately.
Otherwise, if more than one is specified in the command-line, one is processed normally
and the others are going to be treated and included as header files.
Related to radar://13140508
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174385 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend')
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 3 | ||||
-rw-r--r-- | lib/Frontend/FrontendAction.cpp | 12 | ||||
-rw-r--r-- | lib/Frontend/InitPreprocessor.cpp | 13 |
3 files changed, 10 insertions, 18 deletions
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index a2b28bc539..a4597fd84d 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1345,8 +1345,7 @@ static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args, Opts.MacroIncludes = Args.getAllArgValues(OPT_imacros); // Add the ordered list of -includes. - for (arg_iterator it = Args.filtered_begin(OPT_include, OPT_include_pch, - OPT_include_pth), + for (arg_iterator it = Args.filtered_begin(OPT_include), ie = Args.filtered_end(); it != ie; ++it) { const Arg *A = *it; Opts.Includes.push_back(A->getValue()); diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp index 05064fbd4f..6d31c315b4 100644 --- a/lib/Frontend/FrontendAction.cpp +++ b/lib/Frontend/FrontendAction.cpp @@ -247,16 +247,8 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, CI.getLangOpts(), CI.getTargetOpts(), CI.getPreprocessorOpts())) { - for (unsigned I = 0, N = PPOpts.Includes.size(); I != N; ++I) { - if (PPOpts.Includes[I] == PPOpts.ImplicitPCHInclude) { - PPOpts.Includes[I] = Dir->path(); - PPOpts.ImplicitPCHInclude = Dir->path(); - Found = true; - break; - } - } - - assert(Found && "Implicit PCH include not in includes list?"); + PPOpts.ImplicitPCHInclude = Dir->path(); + Found = true; break; } } diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp index 3646e27a49..b74c3c0b1c 100644 --- a/lib/Frontend/InitPreprocessor.cpp +++ b/lib/Frontend/InitPreprocessor.cpp @@ -784,15 +784,16 @@ void clang::InitializePreprocessor(Preprocessor &PP, AddImplicitIncludeMacros(Builder, InitOpts.MacroIncludes[i], PP.getFileManager()); + // Process -include-pch/-include-pth directives. + if (!InitOpts.ImplicitPCHInclude.empty()) + AddImplicitIncludePCH(Builder, PP, InitOpts.ImplicitPCHInclude); + if (!InitOpts.ImplicitPTHInclude.empty()) + AddImplicitIncludePTH(Builder, PP, InitOpts.ImplicitPTHInclude); + // Process -include directives. for (unsigned i = 0, e = InitOpts.Includes.size(); i != e; ++i) { const std::string &Path = InitOpts.Includes[i]; - if (Path == InitOpts.ImplicitPTHInclude) - AddImplicitIncludePTH(Builder, PP, Path); - else if (Path == InitOpts.ImplicitPCHInclude) - AddImplicitIncludePCH(Builder, PP, Path); - else - AddImplicitInclude(Builder, Path, PP.getFileManager()); + AddImplicitInclude(Builder, Path, PP.getFileManager()); } // Exit the command line and go back to <built-in> (2 is LC_LEAVE). |