[cfe-commits] r86757 - in /cfe/trunk: include/clang/Frontend/PreprocessorOptions.h lib/Frontend/InitPreprocessor.cpp tools/clang-cc/clang-cc.cpp

Daniel Dunbar daniel at zuster.org
Tue Nov 10 17:53:44 CST 2009


Author: ddunbar
Date: Tue Nov 10 17:53:43 2009
New Revision: 86757

URL: http://llvm.org/viewvc/llvm-project?rev=86757&view=rev
Log:
PreprocessorOptions: Get rid of unnecessary 'isPTH' flag for include entries.

Modified:
    cfe/trunk/include/clang/Frontend/PreprocessorOptions.h
    cfe/trunk/lib/Frontend/InitPreprocessor.cpp
    cfe/trunk/tools/clang-cc/clang-cc.cpp

Modified: cfe/trunk/include/clang/Frontend/PreprocessorOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PreprocessorOptions.h?rev=86757&r1=86756&r2=86757&view=diff

==============================================================================
--- cfe/trunk/include/clang/Frontend/PreprocessorOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/PreprocessorOptions.h Tue Nov 10 17:53:43 2009
@@ -10,6 +10,7 @@
 #ifndef LLVM_CLANG_FRONTEND_PREPROCESSOROPTIONS_H_
 #define LLVM_CLANG_FRONTEND_PREPROCESSOROPTIONS_H_
 
+#include "llvm/ADT/StringRef.h"
 #include <string>
 #include <vector>
 
@@ -22,7 +23,7 @@
 /// used in preprocessor initialization to InitializePreprocessor().
 class PreprocessorOptions {
   std::vector<std::pair<std::string, bool/*isUndef*/> > Macros;
-  std::vector<std::pair<std::string, bool/*isPTH*/> > Includes;
+  std::vector<std::string> Includes;
   std::vector<std::string> MacroIncludes;
 
   unsigned UsePredefines : 1; /// Initialize the preprocessor with the compiler
@@ -61,14 +62,14 @@
     ImplicitPTHInclude = Value;
   }
 
-  void addMacroDef(const std::string &Name) {
+  void addMacroDef(llvm::StringRef Name) {
     Macros.push_back(std::make_pair(Name, false));
   }
-  void addMacroUndef(const std::string &Name) {
+  void addMacroUndef(llvm::StringRef Name) {
     Macros.push_back(std::make_pair(Name, true));
   }
-  void addInclude(const std::string &Name, bool isPTH = false) {
-    Includes.push_back(std::make_pair(Name, isPTH));
+  void addInclude(llvm::StringRef Name) {
+    Includes.push_back(Name);
   }
   void addMacroInclude(const std::string &Name) {
     MacroIncludes.push_back(Name);
@@ -79,8 +80,7 @@
   macro_iterator macro_begin() const { return Macros.begin(); }
   macro_iterator macro_end() const { return Macros.end(); }
 
-  typedef std::vector<std::pair<std::string,
-                                bool> >::const_iterator include_iterator;
+  typedef std::vector<std::string>::const_iterator include_iterator;
   include_iterator include_begin() const { return Includes.begin(); }
   include_iterator include_end() const { return Includes.end(); }
 

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=86757&r1=86756&r2=86757&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Tue Nov 10 17:53:43 2009
@@ -492,10 +492,10 @@
   // Process -include directives.
   for (PreprocessorOptions::include_iterator I = InitOpts.include_begin(),
        E = InitOpts.include_end(); I != E; ++I) {
-    if (I->second) // isPTH
-      AddImplicitIncludePTH(PredefineBuffer, PP, I->first);
+    if (*I == InitOpts.getImplicitPTHInclude())
+      AddImplicitIncludePTH(PredefineBuffer, PP, *I);
     else
-      AddImplicitInclude(PredefineBuffer, I->first);
+      AddImplicitInclude(PredefineBuffer, *I);
   }
 
   // Null terminate PredefinedBuffer and add it.

Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=86757&r1=86756&r2=86757&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Tue Nov 10 17:53:43 2009
@@ -1135,9 +1135,9 @@
       if (!ImplicitIncludes.empty() &&
           Ptr >= &ImplicitIncludes[0] &&
           Ptr <= &ImplicitIncludes[ImplicitIncludes.size()-1]) {
-        InitOpts.addInclude(*Ptr, false);
+        InitOpts.addInclude(*Ptr);
       } else if (Ptr == &ImplicitIncludePTH) {
-        InitOpts.addInclude(*Ptr, true);
+        InitOpts.addInclude(*Ptr);
       } else {
         // We end up here when we're producing preprocessed output and
         // we loaded a PCH file. In this case, just include the header
@@ -1145,7 +1145,7 @@
         assert(Ptr == &ImplicitIncludePCH);
         std::string OriginalFile = PCHReader::getOriginalSourceFile(*Ptr);
         if (!OriginalFile.empty()) {
-          InitOpts.addInclude(OriginalFile, false);
+          InitOpts.addInclude(OriginalFile);
           InitOpts.setImplicitPCHInclude("");
         }
       }




More information about the cfe-commits mailing list