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

Daniel Dunbar daniel at zuster.org
Mon Nov 16 21:52:41 PST 2009


Author: ddunbar
Date: Mon Nov 16 23:52:41 2009
New Revision: 89047

URL: http://llvm.org/viewvc/llvm-project?rev=89047&view=rev
Log:
Simplify PreprocessorOptions, it doesn't need abstracted field access.

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

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

==============================================================================
--- cfe/trunk/include/clang/Frontend/PreprocessorOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/PreprocessorOptions.h Mon Nov 16 23:52:41 2009
@@ -23,6 +23,7 @@
 /// PreprocessorOptions - This class is used for passing the various options
 /// used in preprocessor initialization to InitializePreprocessor().
 class PreprocessorOptions {
+public:
   std::vector<std::pair<std::string, bool/*isUndef*/> > Macros;
   std::vector<std::string> Includes;
   std::vector<std::string> MacroIncludes;
@@ -43,61 +44,12 @@
 public:
   PreprocessorOptions() : UsePredefines(true) {}
 
-  bool getUsePredefines() const { return UsePredefines; }
-  void setUsePredefines(bool Value) {
-    UsePredefines = Value;
-  }
-
-  const std::string &getImplicitPCHInclude() const {
-    return ImplicitPCHInclude;
-  }
-  void setImplicitPCHInclude(llvm::StringRef Value) {
-    assert((Value.empty() || ImplicitPTHInclude.empty()) &&
-           "Cannot both implicit PCH and PTH includes!");
-    ImplicitPCHInclude = Value;
-  }
-
-  const std::string &getImplicitPTHInclude() const {
-    return ImplicitPTHInclude;
-  }
-  void setImplicitPTHInclude(llvm::StringRef Value) {
-    assert((ImplicitPCHInclude.empty() || Value.empty()) &&
-           "Cannot both implicit PCH and PTH includes!");
-    ImplicitPTHInclude = Value;
-  }
-
-  const std::string &getTokenCache() const {
-    return TokenCache;
-  }
-  void setTokenCache(llvm::StringRef Value) {
-    TokenCache = Value;
-  }
-
   void addMacroDef(llvm::StringRef Name) {
     Macros.push_back(std::make_pair(Name, false));
   }
   void addMacroUndef(llvm::StringRef Name) {
     Macros.push_back(std::make_pair(Name, true));
   }
-  void addInclude(llvm::StringRef Name) {
-    Includes.push_back(Name);
-  }
-  void addMacroInclude(llvm::StringRef Name) {
-    MacroIncludes.push_back(Name);
-  }
-
-  typedef std::vector<std::pair<std::string,
-                                bool> >::const_iterator macro_iterator;
-  macro_iterator macro_begin() const { return Macros.begin(); }
-  macro_iterator macro_end() const { return Macros.end(); }
-
-  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(); }
-
-  typedef std::vector<std::string>::const_iterator imacro_iterator;
-  imacro_iterator imacro_begin() const { return MacroIncludes.begin(); }
-  imacro_iterator imacro_end() const { return MacroIncludes.end(); }
 };
 
 } // end namespace clang

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

==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Mon Nov 16 23:52:41 2009
@@ -167,8 +167,8 @@
                                      FileManager &FileMgr) {
   // Create a PTH manager if we are using some form of a token cache.
   PTHManager *PTHMgr = 0;
-  if (!PPOpts.getTokenCache().empty())
-    PTHMgr = PTHManager::Create(PPOpts.getTokenCache(), Diags);
+  if (!PPOpts.TokenCache.empty())
+    PTHMgr = PTHManager::Create(PPOpts.TokenCache, Diags);
 
   // FIXME: Don't fail like this.
   if (Diags.hasErrorOccurred())

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

==============================================================================
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Mon Nov 16 23:52:41 2009
@@ -90,10 +90,10 @@
       goto failure;
 
     /// Use PCH?
-    if (!CI.getPreprocessorOpts().getImplicitPCHInclude().empty()) {
+    if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
       assert(hasPCHSupport() && "This action does not have PCH support!");
       CI.createPCHExternalASTSource(
-        CI.getPreprocessorOpts().getImplicitPCHInclude());
+        CI.getPreprocessorOpts().ImplicitPCHInclude);
       if (!CI.getASTContext().getExternalSource())
         goto failure;
     }

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

==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Nov 16 23:52:41 2009
@@ -477,7 +477,7 @@
                          LineDirective, LineDirective+strlen(LineDirective));
 
   // Install things like __POWERPC__, __GNUC__, etc into the macro table.
-  if (InitOpts.getUsePredefines())
+  if (InitOpts.UsePredefines)
     InitializePredefinedMacros(PP.getTargetInfo(), PP.getLangOptions(),
                                PredefineBuffer);
 
@@ -488,27 +488,25 @@
                          LineDirective, LineDirective+strlen(LineDirective));
 
   // Process #define's and #undef's in the order they are given.
-  for (PreprocessorOptions::macro_iterator I = InitOpts.macro_begin(),
-       E = InitOpts.macro_end(); I != E; ++I) {
-    if (I->second)  // isUndef
-      UndefineBuiltinMacro(PredefineBuffer, I->first.c_str());
+  for (unsigned i = 0, e = InitOpts.Macros.size(); i != e; ++i) {
+    if (InitOpts.Macros[i].second)  // isUndef
+      UndefineBuiltinMacro(PredefineBuffer, InitOpts.Macros[i].first.c_str());
     else
-      DefineBuiltinMacro(PredefineBuffer, I->first.c_str());
+      DefineBuiltinMacro(PredefineBuffer, InitOpts.Macros[i].first.c_str());
   }
 
   // If -imacros are specified, include them now.  These are processed before
   // any -include directives.
-  for (PreprocessorOptions::imacro_iterator I = InitOpts.imacro_begin(),
-       E = InitOpts.imacro_end(); I != E; ++I)
-    AddImplicitIncludeMacros(PredefineBuffer, *I);
+  for (unsigned i = 0, e = InitOpts.MacroIncludes.size(); i != e; ++i)
+    AddImplicitIncludeMacros(PredefineBuffer, InitOpts.MacroIncludes[i]);
 
   // Process -include directives.
-  for (PreprocessorOptions::include_iterator I = InitOpts.include_begin(),
-       E = InitOpts.include_end(); I != E; ++I) {
-    if (*I == InitOpts.getImplicitPTHInclude())
-      AddImplicitIncludePTH(PredefineBuffer, PP, *I);
+  for (unsigned i = 0, e = InitOpts.Includes.size(); i != e; ++i) {
+    const std::string &Path = InitOpts.Includes[i];
+    if (Path == InitOpts.ImplicitPTHInclude)
+      AddImplicitIncludePTH(PredefineBuffer, PP, Path);
     else
-      AddImplicitInclude(PredefineBuffer, *I);
+      AddImplicitInclude(PredefineBuffer, Path);
   }
 
   // Null terminate PredefinedBuffer and add it.

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

==============================================================================
--- cfe/trunk/tools/clang-cc/Options.cpp (original)
+++ cfe/trunk/tools/clang-cc/Options.cpp Mon Nov 16 23:52:41 2009
@@ -1008,8 +1008,8 @@
 void clang::InitializePreprocessorOptions(PreprocessorOptions &Opts) {
   using namespace preprocessoroptions;
 
-  Opts.setImplicitPCHInclude(ImplicitIncludePCH);
-  Opts.setImplicitPTHInclude(ImplicitIncludePTH);
+  Opts.ImplicitPCHInclude = ImplicitIncludePCH;
+  Opts.ImplicitPTHInclude = ImplicitIncludePTH;
 
   // Select the token cache file, we don't support more than one currently so we
   // can't have both an implicit-pth and a token cache file.
@@ -1020,12 +1020,12 @@
     exit(1);
   }
   if (TokenCache.getPosition())
-    Opts.setTokenCache(TokenCache);
+    Opts.TokenCache = TokenCache;
   else
-    Opts.setTokenCache(ImplicitIncludePTH);
+    Opts.TokenCache = ImplicitIncludePTH;
 
   // Use predefines?
-  Opts.setUsePredefines(!UndefMacros);
+  Opts.UsePredefines = !UndefMacros;
 
   // Add macros from the command line.
   unsigned d = 0, D = D_macros.size();
@@ -1040,7 +1040,7 @@
   // If -imacros are specified, include them now.  These are processed before
   // any -include directives.
   for (unsigned i = 0, e = ImplicitMacroIncludes.size(); i != e; ++i)
-    Opts.addMacroInclude(ImplicitMacroIncludes[i]);
+    Opts.MacroIncludes.push_back(ImplicitMacroIncludes[i]);
 
   // Add the ordered list of -includes, sorting in the implicit include options
   // at the appropriate location.
@@ -1064,7 +1064,7 @@
   llvm::array_pod_sort(OrderedPaths.begin(), OrderedPaths.end());
 
   for (unsigned i = 0, e = OrderedPaths.size(); i != e; ++i)
-    Opts.addInclude(*OrderedPaths[i].second);
+    Opts.Includes.push_back(*OrderedPaths[i].second);
 }
 
 void clang::InitializeLangOptions(LangOptions &Options,





More information about the cfe-commits mailing list