]> granicus.if.org Git - clang/commitdiff
Always initialize the header search object as part of InitializePreprocessor;
authorDaniel Dunbar <daniel@zuster.org>
Wed, 11 Nov 2009 21:44:42 +0000 (21:44 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 11 Nov 2009 21:44:42 +0000 (21:44 +0000)
not doing this has little to no utility.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86883 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/Utils.h
lib/Frontend/InitPreprocessor.cpp
tools/clang-cc/clang-cc.cpp

index cc0d1b56717a2056c7d38f919b0c07e7fc544ddf..60c0f226ef54f19e62476e11e396c79bcbbba098 100644 (file)
@@ -48,9 +48,9 @@ void ApplyHeaderSearchOptions(HeaderSearch &HS,
 
 /// InitializePreprocessor - Initialize the preprocessor getting it and the
 /// environment ready to process a single file.
-///
 void InitializePreprocessor(Preprocessor &PP,
-                            const PreprocessorOptions &PPOpts);
+                            const PreprocessorOptions &PPOpts,
+                            const HeaderSearchOptions &HSOpts);
 
 /// ProcessWarningOptions - Initialize the diagnostic client and process the
 /// warning options specified on the command line.
index 15ea9015a2de36ab9e8856f580c1876d91d7bf1a..ad70727c05e6a6ec6a07524aa1e3d71390e436de 100644 (file)
@@ -456,7 +456,8 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
 /// environment ready to process a single file. This returns true on error.
 ///
 void clang::InitializePreprocessor(Preprocessor &PP,
-                                   const PreprocessorOptions &InitOpts) {
+                                   const PreprocessorOptions &InitOpts,
+                                   const HeaderSearchOptions &HSOpts) {
   std::vector<char> PredefineBuffer;
 
   const char *LineDirective = "# 1 \"<built-in>\" 3\n";
@@ -501,4 +502,9 @@ void clang::InitializePreprocessor(Preprocessor &PP,
   // Null terminate PredefinedBuffer and add it.
   PredefineBuffer.push_back(0);
   PP.setPredefines(&PredefineBuffer[0]);
+
+  // Initialize the header search object.
+  ApplyHeaderSearchOptions(PP.getHeaderSearchInfo(), HSOpts,
+                           PP.getLangOptions(),
+                           PP.getTargetInfo().getTriple());
 }
index 0b5a6d35a6e576f7ecf7fa4b1b037dde965604e8..5cce02ff4ba8ced07239b31235f47b5e784e17b9 100644 (file)
@@ -377,6 +377,7 @@ std::string GetBuiltinIncludePath(const char *Argv0) {
 static Preprocessor *
 CreatePreprocessor(Diagnostic &Diags, const LangOptions &LangInfo,
                    const PreprocessorOptions &PPOpts,
+                   const HeaderSearchOptions &HSOpts,
                    const DependencyOutputOptions &DepOpts,
                    TargetInfo &Target, SourceManager &SourceMgr,
                    FileManager &FileMgr) {
@@ -413,7 +414,7 @@ CreatePreprocessor(Diagnostic &Diags, const LangOptions &LangInfo,
     PP->setPTHManager(PTHMgr);
   }
 
-  InitializePreprocessor(*PP, PPOpts);
+  InitializePreprocessor(*PP, PPOpts, HSOpts);
 
   // Handle generating dependencies, if requested.
   if (!DepOpts.OutputFile.empty())
@@ -1209,14 +1210,10 @@ int main(int argc, char **argv) {
     llvm::OwningPtr<Preprocessor>
       PP(CreatePreprocessor(Diags, CompOpts.getLangOpts(),
                             CompOpts.getPreprocessorOpts(),
+                            CompOpts.getHeaderSearchOpts(),
                             CompOpts.getDependencyOutputOpts(),
                             *Target, SourceMgr, FileMgr));
 
-    // Apply all the options to the header search object.
-    ApplyHeaderSearchOptions(PP->getHeaderSearchInfo(),
-                             CompOpts.getHeaderSearchOpts(),
-                             CompOpts.getLangOpts(), Triple);
-
     if (CompOpts.getPreprocessorOpts().getImplicitPCHInclude().empty()) {
       if (InitializeSourceManager(*PP.get(), InFile))
         continue;