[cfe-commits] r166587 - in /cfe/trunk: include/clang/Frontend/CompilerInvocation.h include/clang/Frontend/PreprocessorOptions.h include/clang/Lex/PreprocessorOptions.h lib/ARCMigrate/FileRemapper.cpp lib/Frontend/CompilerInvocation.cpp lib/Frontend/InitPreprocessor.cpp

Douglas Gregor dgregor at apple.com
Wed Oct 24 10:01:35 PDT 2012


Author: dgregor
Date: Wed Oct 24 12:01:35 2012
New Revision: 166587

URL: http://llvm.org/viewvc/llvm-project?rev=166587&view=rev
Log:
Move PreprocessorOptions into the Lex library, and make it intrusively
reference-counted.

Added:
    cfe/trunk/include/clang/Lex/PreprocessorOptions.h
      - copied, changed from r166559, cfe/trunk/include/clang/Frontend/PreprocessorOptions.h
Removed:
    cfe/trunk/include/clang/Frontend/PreprocessorOptions.h
Modified:
    cfe/trunk/include/clang/Frontend/CompilerInvocation.h
    cfe/trunk/lib/ARCMigrate/FileRemapper.cpp
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp
    cfe/trunk/lib/Frontend/InitPreprocessor.cpp

Modified: cfe/trunk/include/clang/Frontend/CompilerInvocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInvocation.h?rev=166587&r1=166586&r2=166587&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CompilerInvocation.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInvocation.h Wed Oct 24 12:01:35 2012
@@ -15,13 +15,13 @@
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Lex/HeaderSearchOptions.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
 #include "clang/Frontend/MigratorOptions.h"
 #include "clang/Frontend/CodeGenOptions.h"
 #include "clang/Frontend/DependencyOutputOptions.h"
 #include "clang/Frontend/FrontendOptions.h"
 #include "clang/Frontend/LangStandard.h"
-#include "clang/Frontend/PreprocessorOptions.h"
 #include "clang/Frontend/PreprocessorOutputOptions.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringRef.h"
@@ -62,6 +62,9 @@
   /// Options controlling the \#include directive.
   IntrusiveRefCntPtr<HeaderSearchOptions> HeaderSearchOpts;
 
+  /// Options controlling the preprocessor (aside from \#include handling).
+  IntrusiveRefCntPtr<PreprocessorOptions> PreprocessorOpts;
+
 public:
   CompilerInvocationBase();
 
@@ -81,6 +84,11 @@
   const HeaderSearchOptions &getHeaderSearchOpts() const {
     return *HeaderSearchOpts;
   }
+
+  PreprocessorOptions &getPreprocessorOpts() { return *PreprocessorOpts; }
+  const PreprocessorOptions &getPreprocessorOpts() const {
+    return *PreprocessorOpts;
+  }
 };
   
 /// \brief Helper class for holding the data necessary to invoke the compiler.
@@ -106,9 +114,6 @@
   /// Options controlling the frontend itself.
   FrontendOptions FrontendOpts;
 
-  /// Options controlling the preprocessor (aside from \#include handling).
-  PreprocessorOptions PreprocessorOpts;
-
   /// Options controlling preprocessed output.
   PreprocessorOutputOptions PreprocessorOutputOpts;
 
@@ -192,11 +197,6 @@
     return FrontendOpts;
   }
 
-  PreprocessorOptions &getPreprocessorOpts() { return PreprocessorOpts; }
-  const PreprocessorOptions &getPreprocessorOpts() const {
-    return PreprocessorOpts;
-  }
-
   PreprocessorOutputOptions &getPreprocessorOutputOpts() {
     return PreprocessorOutputOpts;
   }

Removed: cfe/trunk/include/clang/Frontend/PreprocessorOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PreprocessorOptions.h?rev=166586&view=auto
==============================================================================
--- cfe/trunk/include/clang/Frontend/PreprocessorOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/PreprocessorOptions.h (removed)
@@ -1,224 +0,0 @@
-//===--- PreprocessorOptions.h ----------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_FRONTEND_PREPROCESSOROPTIONS_H_
-#define LLVM_CLANG_FRONTEND_PREPROCESSOROPTIONS_H_
-
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
-#include <cassert>
-#include <string>
-#include <utility>
-#include <vector>
-#include <set>
-
-namespace llvm {
-  class MemoryBuffer;
-}
-
-namespace clang {
-
-class Preprocessor;
-class LangOptions;
-
-/// \brief Enumerate the kinds of standard library that 
-enum ObjCXXARCStandardLibraryKind {
-  ARCXX_nolib,
-  /// \brief libc++
-  ARCXX_libcxx,
-  /// \brief libstdc++
-  ARCXX_libstdcxx
-};
-  
-/// 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;
-
-  unsigned UsePredefines : 1; /// Initialize the preprocessor with the compiler
-                              /// and target specific predefines.
-
-  unsigned DetailedRecord : 1; /// Whether we should maintain a detailed
-                               /// record of all macro definitions and
-                               /// expansions.
-  unsigned DetailedRecordConditionalDirectives : 1; /// Whether in the
-                               /// preprocessing record we should also keep
-                               /// track of locations of conditional directives
-                               /// in non-system files.
-  
-  /// The implicit PCH included at the start of the translation unit, or empty.
-  std::string ImplicitPCHInclude;
-
-  /// \brief Headers that will be converted to chained PCHs in memory.
-  std::vector<std::string> ChainedIncludes;
-
-  /// \brief When true, disables most of the normal validation performed on
-  /// precompiled headers.
-  bool DisablePCHValidation;
-
-  /// \brief When true, disables the use of the stat cache within a
-  /// precompiled header or AST file.
-  bool DisableStatCache;
-
-  /// \brief When true, a PCH with compiler errors will not be rejected.
-  bool AllowPCHWithCompilerErrors;
-
-  /// \brief Dump declarations that are deserialized from PCH, for testing.
-  bool DumpDeserializedPCHDecls;
-
-  /// \brief This is a set of names for decls that we do not want to be
-  /// deserialized, and we emit an error if they are; for testing purposes.
-  std::set<std::string> DeserializedPCHDeclsToErrorOn;
-
-  /// \brief If non-zero, the implicit PCH include is actually a precompiled
-  /// preamble that covers this number of bytes in the main source file.
-  ///
-  /// The boolean indicates whether the preamble ends at the start of a new
-  /// line.
-  std::pair<unsigned, bool> PrecompiledPreambleBytes;
-  
-  /// The implicit PTH input included at the start of the translation unit, or
-  /// empty.
-  std::string ImplicitPTHInclude;
-
-  /// If given, a PTH cache file to use for speeding up header parsing.
-  std::string TokenCache;
-
-  /// \brief True if the SourceManager should report the original file name for
-  /// contents of files that were remapped to other files. Defaults to true.
-  bool RemappedFilesKeepOriginalName;
-
-  /// \brief The set of file remappings, which take existing files on
-  /// the system (the first part of each pair) and gives them the
-  /// contents of other files on the system (the second part of each
-  /// pair).
-  std::vector<std::pair<std::string, std::string> >  RemappedFiles;
-
-  /// \brief The set of file-to-buffer remappings, which take existing files
-  /// on the system (the first part of each pair) and gives them the contents
-  /// of the specified memory buffer (the second part of each pair).
-  std::vector<std::pair<std::string, const llvm::MemoryBuffer *> > 
-    RemappedFileBuffers;
-  
-  /// \brief Whether the compiler instance should retain (i.e., not free)
-  /// the buffers associated with remapped files.
-  ///
-  /// This flag defaults to false; it can be set true only through direct
-  /// manipulation of the compiler invocation object, in cases where the 
-  /// compiler invocation and its buffers will be reused.
-  bool RetainRemappedFileBuffers;
-  
-  /// \brief The Objective-C++ ARC standard library that we should support,
-  /// by providing appropriate definitions to retrofit the standard library
-  /// with support for lifetime-qualified pointers.
-  ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary;
-    
-  /// \brief The path of modules being build, which is used to detect
-  /// cycles in the module dependency graph as modules are being built.
-  ///
-  /// There is no way to set this value from the command line. If we ever need
-  /// to do so (e.g., if on-demand module construction moves out-of-process),
-  /// we can add a cc1-level option to do so.
-  SmallVector<std::string, 2> ModuleBuildPath;
-  
-  typedef std::vector<std::pair<std::string, std::string> >::iterator
-    remapped_file_iterator;
-  typedef std::vector<std::pair<std::string, std::string> >::const_iterator
-    const_remapped_file_iterator;
-  remapped_file_iterator remapped_file_begin() { 
-    return RemappedFiles.begin();
-  }
-  const_remapped_file_iterator remapped_file_begin() const {
-    return RemappedFiles.begin();
-  }
-  remapped_file_iterator remapped_file_end() { 
-    return RemappedFiles.end();
-  }
-  const_remapped_file_iterator remapped_file_end() const { 
-    return RemappedFiles.end();
-  }
-
-  typedef std::vector<std::pair<std::string, const llvm::MemoryBuffer *> >::
-                                  iterator remapped_file_buffer_iterator;
-  typedef std::vector<std::pair<std::string, const llvm::MemoryBuffer *> >::
-                            const_iterator const_remapped_file_buffer_iterator;
-  remapped_file_buffer_iterator remapped_file_buffer_begin() {
-    return RemappedFileBuffers.begin();
-  }
-  const_remapped_file_buffer_iterator remapped_file_buffer_begin() const {
-    return RemappedFileBuffers.begin();
-  }
-  remapped_file_buffer_iterator remapped_file_buffer_end() {
-    return RemappedFileBuffers.end();
-  }
-  const_remapped_file_buffer_iterator remapped_file_buffer_end() const {
-    return RemappedFileBuffers.end();
-  }
-  
-public:
-  PreprocessorOptions() : UsePredefines(true), DetailedRecord(false),
-                          DetailedRecordConditionalDirectives(false),
-                          DisablePCHValidation(false), DisableStatCache(false),
-                          AllowPCHWithCompilerErrors(false),
-                          DumpDeserializedPCHDecls(false),
-                          PrecompiledPreambleBytes(0, true),
-                          RemappedFilesKeepOriginalName(true),
-                          RetainRemappedFileBuffers(false),
-                          ObjCXXARCStandardLibrary(ARCXX_nolib) { }
-
-  void addMacroDef(StringRef Name) {
-    Macros.push_back(std::make_pair(Name, false));
-  }
-  void addMacroUndef(StringRef Name) {
-    Macros.push_back(std::make_pair(Name, true));
-  }
-  void addRemappedFile(StringRef From, StringRef To) {
-    RemappedFiles.push_back(std::make_pair(From, To));
-  }
-  
-  remapped_file_iterator eraseRemappedFile(remapped_file_iterator Remapped) {
-    return RemappedFiles.erase(Remapped);
-  }
-  
-  void addRemappedFile(StringRef From, const llvm::MemoryBuffer * To) {
-    RemappedFileBuffers.push_back(std::make_pair(From, To));
-  }
-  
-  remapped_file_buffer_iterator
-  eraseRemappedFile(remapped_file_buffer_iterator Remapped) {
-    return RemappedFileBuffers.erase(Remapped);
-  }
-  
-  void clearRemappedFiles() {
-    RemappedFiles.clear();
-    RemappedFileBuffers.clear();
-  }
-  
-  /// \brief Reset any options that are not considered when building a
-  /// module.
-  void resetNonModularOptions() {
-    Includes.clear();
-    MacroIncludes.clear();
-    ChainedIncludes.clear();
-    DumpDeserializedPCHDecls = false;
-    ImplicitPCHInclude.clear();
-    ImplicitPTHInclude.clear();
-    TokenCache.clear();
-    RetainRemappedFileBuffers = true;
-    PrecompiledPreambleBytes.first = 0;
-    PrecompiledPreambleBytes.second = 0;
-  }
-};
-
-} // end namespace clang
-
-#endif

Copied: cfe/trunk/include/clang/Lex/PreprocessorOptions.h (from r166559, cfe/trunk/include/clang/Frontend/PreprocessorOptions.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorOptions.h?p2=cfe/trunk/include/clang/Lex/PreprocessorOptions.h&p1=cfe/trunk/include/clang/Frontend/PreprocessorOptions.h&r1=166559&r2=166587&rev=166587&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PreprocessorOptions.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessorOptions.h Wed Oct 24 12:01:35 2012
@@ -7,9 +7,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_FRONTEND_PREPROCESSOROPTIONS_H_
-#define LLVM_CLANG_FRONTEND_PREPROCESSOROPTIONS_H_
+#ifndef LLVM_CLANG_LEX_PREPROCESSOROPTIONS_H_
+#define LLVM_CLANG_LEX_PREPROCESSOROPTIONS_H_
 
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include <cassert>
@@ -38,7 +39,7 @@
   
 /// PreprocessorOptions - This class is used for passing the various options
 /// used in preprocessor initialization to InitializePreprocessor().
-class PreprocessorOptions {
+class PreprocessorOptions : public llvm::RefCountedBase<PreprocessorOptions> {
 public:
   std::vector<std::pair<std::string, bool/*isUndef*/> > Macros;
   std::vector<std::string> Includes;

Modified: cfe/trunk/lib/ARCMigrate/FileRemapper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/FileRemapper.cpp?rev=166587&r1=166586&r2=166587&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/FileRemapper.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/FileRemapper.cpp Wed Oct 24 12:01:35 2012
@@ -8,7 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/ARCMigrate/FileRemapper.h"
-#include "clang/Frontend/PreprocessorOptions.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/Diagnostic.h"
 #include "llvm/Support/MemoryBuffer.h"

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=166587&r1=166586&r2=166587&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Oct 24 12:01:35 2012
@@ -37,14 +37,16 @@
 CompilerInvocationBase::CompilerInvocationBase()
   : LangOpts(new LangOptions()), TargetOpts(new TargetOptions()),
     DiagnosticOpts(new DiagnosticOptions()),
-    HeaderSearchOpts(new HeaderSearchOptions()) {}
+    HeaderSearchOpts(new HeaderSearchOptions()),
+    PreprocessorOpts(new PreprocessorOptions()) {}
 
 CompilerInvocationBase::CompilerInvocationBase(const CompilerInvocationBase &X)
   : RefCountedBase<CompilerInvocation>(),
     LangOpts(new LangOptions(*X.getLangOpts())), 
     TargetOpts(new TargetOptions(X.getTargetOpts())),
     DiagnosticOpts(new DiagnosticOptions(X.getDiagnosticOpts())),
-    HeaderSearchOpts(new HeaderSearchOptions(X.getHeaderSearchOpts())) {}
+    HeaderSearchOpts(new HeaderSearchOptions(X.getHeaderSearchOpts())),
+    PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())) {}
 
 //===----------------------------------------------------------------------===//
 // Utility functions.

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=166587&r1=166586&r2=166587&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Oct 24 12:01:35 2012
@@ -17,9 +17,9 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Frontend/FrontendOptions.h"
-#include "clang/Frontend/PreprocessorOptions.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Serialization/ASTReader.h"





More information about the cfe-commits mailing list