summaryrefslogtreecommitdiffstats
path: root/include/clang/Frontend
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Frontend')
-rw-r--r--include/clang/Frontend/ASTConsumers.h9
-rw-r--r--include/clang/Frontend/ASTUnit.h341
-rw-r--r--include/clang/Frontend/AnalyzerOptions.h3
-rw-r--r--include/clang/Frontend/CodeGenOptions.h15
-rw-r--r--include/clang/Frontend/CompilerInstance.h59
-rw-r--r--include/clang/Frontend/DeclXML.def20
-rw-r--r--include/clang/Frontend/DiagnosticOptions.h2
-rw-r--r--include/clang/Frontend/DocumentXML.h1
-rw-r--r--include/clang/Frontend/FrontendAction.h14
-rw-r--r--include/clang/Frontend/FrontendActions.h33
-rw-r--r--include/clang/Frontend/FrontendOptions.h16
-rw-r--r--include/clang/Frontend/HeaderSearchOptions.h20
-rw-r--r--include/clang/Frontend/PCHBitCodes.h822
-rw-r--r--include/clang/Frontend/PCHDeserializationListener.h36
-rw-r--r--include/clang/Frontend/PCHReader.h905
-rw-r--r--include/clang/Frontend/PCHWriter.h408
-rw-r--r--include/clang/Frontend/PreprocessorOptions.h67
-rw-r--r--include/clang/Frontend/PreprocessorOutputOptions.h16
-rw-r--r--include/clang/Frontend/StmtXML.def99
-rw-r--r--include/clang/Frontend/TypeXML.def8
-rw-r--r--include/clang/Frontend/Utils.h7
21 files changed, 566 insertions, 2335 deletions
diff --git a/include/clang/Frontend/ASTConsumers.h b/include/clang/Frontend/ASTConsumers.h
index 2d1df44..cca243d 100644
--- a/include/clang/Frontend/ASTConsumers.h
+++ b/include/clang/Frontend/ASTConsumers.h
@@ -29,7 +29,6 @@ class CodeGenOptions;
class Diagnostic;
class FileManager;
class LangOptions;
-class PCHReader;
class Preprocessor;
class TargetOptions;
@@ -58,14 +57,6 @@ ASTConsumer *CreateASTViewer();
// to stderr; this is intended for debugging.
ASTConsumer *CreateDeclContextPrinter();
-// PCH generator: generates a precompiled header file; this file can be used
-// later with the PCHReader (clang -cc1 option -include-pch) to speed up compile
-// times.
-ASTConsumer *CreatePCHGenerator(const Preprocessor &PP,
- llvm::raw_ostream *OS,
- PCHReader *Chain,
- const char *isysroot = 0);
-
// Inheritance viewer: for C++ code, creates a graph of the inheritance
// tree for the given class and displays it with "dotty".
ASTConsumer *CreateInheritanceViewer(const std::string& clsname);
diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h
index 9252358..e3fd4b3 100644
--- a/include/clang/Frontend/ASTUnit.h
+++ b/include/clang/Frontend/ASTUnit.h
@@ -14,19 +14,26 @@
#ifndef LLVM_CLANG_FRONTEND_ASTUNIT_H
#define LLVM_CLANG_FRONTEND_ASTUNIT_H
+#include "clang/Index/ASTLocation.h"
+#include "clang/Serialization/ASTBitCodes.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/CodeCompleteConsumer.h"
#include "clang/Lex/PreprocessingRecord.h"
#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/FileManager.h"
+#include "clang-c/Index.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/OwningPtr.h"
-#include "clang/Basic/FileManager.h"
-#include "clang/Index/ASTLocation.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringMap.h"
#include "llvm/System/Path.h"
+#include "llvm/Support/Timer.h"
#include <map>
#include <string>
#include <vector>
#include <cassert>
#include <utility>
+#include <sys/types.h>
namespace llvm {
class MemoryBuffer;
@@ -34,6 +41,7 @@ namespace llvm {
namespace clang {
class ASTContext;
+class CodeCompleteConsumer;
class CompilerInvocation;
class Decl;
class Diagnostic;
@@ -45,13 +53,14 @@ class SourceManager;
class TargetInfo;
using namespace idx;
-
-/// \brief Utility class for loading a ASTContext from a PCH file.
+
+/// \brief Utility class for loading a ASTContext from an AST file.
///
class ASTUnit {
public:
typedef std::map<FileID, std::vector<PreprocessedEntity *> >
PreprocessedEntitiesByFileMap;
+
private:
llvm::IntrusiveRefCntPtr<Diagnostic> Diagnostics;
llvm::OwningPtr<FileManager> FileMgr;
@@ -61,18 +70,32 @@ private:
llvm::OwningPtr<Preprocessor> PP;
llvm::OwningPtr<ASTContext> Ctx;
+ /// \brief The AST consumer that received information about the translation
+ /// unit as it was parsed or loaded.
+ llvm::OwningPtr<ASTConsumer> Consumer;
+
+ /// \brief The semantic analysis object used to type-check the translation
+ /// unit.
+ llvm::OwningPtr<Sema> TheSema;
+
/// Optional owned invocation, just used to make the invocation used in
/// LoadFromCommandLine available.
llvm::OwningPtr<CompilerInvocation> Invocation;
-
+
// OnlyLocalDecls - when true, walking this AST should only visit declarations
// that come from the AST itself, not from included precompiled headers.
// FIXME: This is temporary; eventually, CIndex will always do this.
bool OnlyLocalDecls;
- /// Track whether the main file was loaded from an AST or not.
+ /// \brief Whether to capture any diagnostics produced.
+ bool CaptureDiagnostics;
+
+ /// \brief Track whether the main file was loaded from an AST or not.
bool MainFileIsAST;
+ /// \brief Whether this AST represents a complete translation unit.
+ bool CompleteTranslationUnit;
+
/// Track the top-level decls which appeared in an ASTUnit which was loaded
/// from a source file.
//
@@ -114,12 +137,189 @@ private:
unsigned int ConcurrencyCheckValue;
static const unsigned int CheckLocked = 28573289;
static const unsigned int CheckUnlocked = 9803453;
+
+ /// \brief Counter that determines when we want to try building a
+ /// precompiled preamble.
+ ///
+ /// If zero, we will never build a precompiled preamble. Otherwise,
+ /// it's treated as a counter that decrements each time we reparse
+ /// without the benefit of a precompiled preamble. When it hits 1,
+ /// we'll attempt to rebuild the precompiled header. This way, if
+ /// building the precompiled preamble fails, we won't try again for
+ /// some number of calls.
+ unsigned PreambleRebuildCounter;
+
+ /// \brief The file in which the precompiled preamble is stored.
+ std::string PreambleFile;
+
+ /// \brief The contents of the preamble that has been precompiled to
+ /// \c PreambleFile.
+ std::vector<char> Preamble;
+
+ /// \brief Whether the preamble ends at the start of a new line.
+ ///
+ /// Used to inform the lexer as to whether it's starting at the beginning of
+ /// a line after skipping the preamble.
+ bool PreambleEndsAtStartOfLine;
+
+ /// \brief The size of the source buffer that we've reserved for the main
+ /// file within the precompiled preamble.
+ unsigned PreambleReservedSize;
+
+ /// \brief Keeps track of the files that were used when computing the
+ /// preamble, with both their buffer size and their modification time.
+ ///
+ /// If any of the files have changed from one compile to the next,
+ /// the preamble must be thrown away.
+ llvm::StringMap<std::pair<off_t, time_t> > FilesInPreamble;
+
+ /// \brief When non-NULL, this is the buffer used to store the contents of
+ /// the main file when it has been padded for use with the precompiled
+ /// preamble.
+ llvm::MemoryBuffer *SavedMainFileBuffer;
+
+ /// \brief When non-NULL, this is the buffer used to store the
+ /// contents of the preamble when it has been padded to build the
+ /// precompiled preamble.
+ llvm::MemoryBuffer *PreambleBuffer;
+
+ /// \brief The number of warnings that occurred while parsing the preamble.
+ ///
+ /// This value will be used to restore the state of the \c Diagnostic object
+ /// when re-using the precompiled preamble. Note that only the
+ /// number of warnings matters, since we will not save the preamble
+ /// when any errors are present.
+ unsigned NumWarningsInPreamble;
+
+ /// \brief The number of diagnostics that were stored when parsing
+ /// the precompiled preamble.
+ ///
+ /// This value is used to determine how many of the stored
+ /// diagnostics should be retained when reparsing in the presence of
+ /// a precompiled preamble.
+ unsigned NumStoredDiagnosticsInPreamble;
+
+ /// \brief The group of timers associated with this translation unit.
+ llvm::OwningPtr<llvm::TimerGroup> TimerGroup;
+
+ /// \brief A list of the serialization ID numbers for each of the top-level
+ /// declarations parsed within the precompiled preamble.
+ std::vector<serialization::DeclID> TopLevelDeclsInPreamble;
+
+ ///
+ /// \defgroup CodeCompleteCaching Code-completion caching
+ ///
+ /// \{
+ ///
+
+ /// \brief Whether we should be caching code-completion results.
+ bool ShouldCacheCodeCompletionResults;
+
+public:
+ /// \brief A cached code-completion result, which may be introduced in one of
+ /// many different contexts.
+ struct CachedCodeCompletionResult {
+ /// \brief The code-completion string corresponding to this completion
+ /// result.
+ CodeCompletionString *Completion;
+
+ /// \brief A bitmask that indicates which code-completion contexts should
+ /// contain this completion result.
+ ///
+ /// The bits in the bitmask correspond to the values of
+ /// CodeCompleteContext::Kind. To map from a completion context kind to a
+ /// bit, subtract one from the completion context kind and shift 1 by that
+ /// number of bits. Many completions can occur in several different
+ /// contexts.
+ unsigned ShowInContexts;
+
+ /// \brief The priority given to this code-completion result.
+ unsigned Priority;
+
+ /// \brief The libclang cursor kind corresponding to this code-completion
+ /// result.
+ CXCursorKind Kind;
+
+ /// \brief The availability of this code-completion result.
+ CXAvailabilityKind Availability;
+
+ /// \brief The simplified type class for a non-macro completion result.
+ SimplifiedTypeClass TypeClass;
+
+ /// \brief The type of a non-macro completion result, stored as a unique
+ /// integer used by the string map of cached completion types.
+ ///
+ /// This value will be zero if the type is not known, or a unique value
+ /// determined by the formatted type string. Se \c CachedCompletionTypes
+ /// for more information.
+ unsigned Type;
+ };
+
+ /// \brief Retrieve the mapping from formatted type names to unique type
+ /// identifiers.
+ llvm::StringMap<unsigned> &getCachedCompletionTypes() {
+ return CachedCompletionTypes;
+ }
+
+private:
+ /// \brief The set of cached code-completion results.
+ std::vector<CachedCodeCompletionResult> CachedCompletionResults;
+
+ /// \brief A mapping from the formatted type name to a unique number for that
+ /// type, which is used for type equality comparisons.
+ llvm::StringMap<unsigned> CachedCompletionTypes;
+
+ /// \brief The number of top-level declarations present the last time we
+ /// cached code-completion results.
+ ///
+ /// The value is used to help detect when we should repopulate the global
+ /// completion cache.
+ unsigned NumTopLevelDeclsAtLastCompletionCache;
+
+ /// \brief The number of reparses left until we'll consider updating the
+ /// code-completion cache.
+ ///
+ /// This is meant to avoid thrashing during reparsing, by not allowing the
+ /// code-completion cache to be updated on every reparse.
+ unsigned CacheCodeCompletionCoolDown;
+
+ /// \brief Bit used by CIndex to mark when a translation unit may be in an
+ /// inconsistent state, and is not safe to free.
+ unsigned UnsafeToFree : 1;
+
+ /// \brief Cache any "global" code-completion results, so that we can avoid
+ /// recomputing them with each completion.
+ void CacheCodeCompletionResults();
+
+ /// \brief Clear out and deallocate
+ void ClearCachedCompletionResults();
+
+ ///
+ /// \}
+ ///
+
+ /// \brief The timers we've created from the various parses, reparses, etc.
+ /// involved in this translation unit.
+ std::vector<llvm::Timer *> Timers;
ASTUnit(const ASTUnit&); // DO NOT IMPLEMENT
ASTUnit &operator=(const ASTUnit &); // DO NOT IMPLEMENT
explicit ASTUnit(bool MainFileIsAST);
+ void CleanTemporaryFiles();
+ bool Parse(llvm::MemoryBuffer *OverrideMainBuffer);
+
+ std::pair<llvm::MemoryBuffer *, std::pair<unsigned, bool> >
+ ComputePreamble(CompilerInvocation &Invocation,
+ unsigned MaxLines, bool &CreatedBuffer);
+
+ llvm::MemoryBuffer *getMainBufferWithPrecompiledPreamble(
+ CompilerInvocation PreambleInvocation,
+ bool AllowRebuild = true,
+ unsigned MaxLines = 0);
+ void RealizeTopLevelDeclsFromPreamble();
+
public:
class ConcurrencyCheck {
volatile ASTUnit &Self;
@@ -143,6 +343,9 @@ public:
bool isMainFileAST() const { return MainFileIsAST; }
+ bool isUnsafeToFree() const { return UnsafeToFree; }
+ void setUnsafeToFree(bool Value) { UnsafeToFree = Value; }
+
const Diagnostic &getDiagnostics() const { return *Diagnostics; }
Diagnostic &getDiagnostics() { return *Diagnostics; }
@@ -155,11 +358,17 @@ public:
const ASTContext &getASTContext() const { return *Ctx.get(); }
ASTContext &getASTContext() { return *Ctx.get(); }
+ bool hasSema() const { return TheSema; }
+ Sema &getSema() const {
+ assert(TheSema && "ASTUnit does not have a Sema object!");
+ return *TheSema;
+ }
+
const FileManager &getFileManager() const { return *FileMgr; }
FileManager &getFileManager() { return *FileMgr; }
const std::string &getOriginalSourceFileName();
- const std::string &getPCHFileName();
+ const std::string &getASTFileName();
/// \brief Add a temporary file that the ASTUnit depends on.
///
@@ -170,16 +379,48 @@ public:
bool getOnlyLocalDecls() const { return OnlyLocalDecls; }
+ /// \brief Retrieve the maximum PCH level of declarations that a
+ /// traversal of the translation unit should consider.
+ unsigned getMaxPCHLevel() const;
+
void setLastASTLocation(ASTLocation ALoc) { LastLoc = ALoc; }
ASTLocation getLastASTLocation() const { return LastLoc; }
- std::vector<Decl*> &getTopLevelDecls() {
+ typedef std::vector<Decl *>::iterator top_level_iterator;
+
+ top_level_iterator top_level_begin() {
+ assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!");
+ if (!TopLevelDeclsInPreamble.empty())
+ RealizeTopLevelDeclsFromPreamble();
+ return TopLevelDecls.begin();
+ }
+
+ top_level_iterator top_level_end() {
+ assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!");
+ if (!TopLevelDeclsInPreamble.empty())
+ RealizeTopLevelDeclsFromPreamble();
+ return TopLevelDecls.end();
+ }
+
+ std::size_t top_level_size() const {
assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!");
- return TopLevelDecls;
+ return TopLevelDeclsInPreamble.size() + TopLevelDecls.size();
}
- const std::vector<Decl*> &getTopLevelDecls() const {
+
+ bool top_level_empty() const {
assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!");
- return TopLevelDecls;
+ return TopLevelDeclsInPreamble.empty() && TopLevelDecls.empty();
+ }
+
+ /// \brief Add a new top-level declaration.
+ void addTopLevelDecl(Decl *D) {
+ TopLevelDecls.push_back(D);
+ }
+
+ /// \brief Add a new top-level declaration, identified by its ID in
+ /// the precompiled preamble.
+ void addTopLevelDeclFromPreamble(serialization::DeclID D) {
+ TopLevelDeclsInPreamble.push_back(D);
}
/// \brief Retrieve the mapping from File IDs to the preprocessed entities
@@ -202,19 +443,40 @@ public:
return StoredDiagnostics;
}
+ typedef std::vector<CachedCodeCompletionResult>::iterator
+ cached_completion_iterator;
+
+ cached_completion_iterator cached_completion_begin() {
+ return CachedCompletionResults.begin();
+ }
+
+ cached_completion_iterator cached_completion_end() {
+ return CachedCompletionResults.end();
+ }
+
+ unsigned cached_completion_size() const {
+ return CachedCompletionResults.size();
+ }
+
+ /// \brief Whether this AST represents a complete translation unit.
+ ///
+ /// If false, this AST is only a partial translation unit, e.g., one
+ /// that might still be used as a precompiled header or preamble.
+ bool isCompleteTranslationUnit() const { return CompleteTranslationUnit; }
+
/// \brief A mapping from a file name to the memory buffer that stores the
/// remapped contents of that file.
typedef std::pair<std::string, const llvm::MemoryBuffer *> RemappedFile;
- /// \brief Create a ASTUnit from a PCH file.
+ /// \brief Create a ASTUnit from an AST file.
///
- /// \param Filename - The PCH file to load.
+ /// \param Filename - The AST file to load.
///
/// \param Diags - The diagnostics engine to use for reporting errors; its
/// lifetime is expected to extend past that of the returned ASTUnit.
///
- /// \returns - The initialized ASTUnit or null if the PCH failed to load.
- static ASTUnit *LoadFromPCHFile(const std::string &Filename,
+ /// \returns - The initialized ASTUnit or null if the AST failed to load.
+ static ASTUnit *LoadFromASTFile(const std::string &Filename,
llvm::IntrusiveRefCntPtr<Diagnostic> Diags,
bool OnlyLocalDecls = false,
RemappedFile *RemappedFiles = 0,
@@ -235,7 +497,10 @@ public:
static ASTUnit *LoadFromCompilerInvocation(CompilerInvocation *CI,
llvm::IntrusiveRefCntPtr<Diagnostic> Diags,
bool OnlyLocalDecls = false,
- bool CaptureDiagnostics = false);
+ bool CaptureDiagnostics = false,
+ bool PrecompilePreamble = false,
+ bool CompleteTranslationUnit = true,
+ bool CacheCodeCompletionResults = false);
/// LoadFromCommandLine - Create an ASTUnit from a vector of command line
/// arguments, which must specify exactly one source file.
@@ -258,7 +523,49 @@ public:
bool OnlyLocalDecls = false,
RemappedFile *RemappedFiles = 0,
unsigned NumRemappedFiles = 0,
- bool CaptureDiagnostics = false);
+ bool CaptureDiagnostics = false,
+ bool PrecompilePreamble = false,
+ bool CompleteTranslationUnit = true,
+ bool CacheCodeCompletionResults = false);
+
+ /// \brief Reparse the source files using the same command-line options that
+ /// were originally used to produce this translation unit.
+ ///
+ /// \returns True if a failure occurred that causes the ASTUnit not to
+ /// contain any translation-unit information, false otherwise.
+ bool Reparse(RemappedFile *RemappedFiles = 0,
+ unsigned NumRemappedFiles = 0);
+
+ /// \brief Perform code completion at the given file, line, and
+ /// column within this translation unit.
+ ///
+ /// \param File The file in which code completion will occur.
+ ///
+ /// \param Line The line at which code completion will occur.
+ ///
+ /// \param Column The column at which code completion will occur.
+ ///
+ /// \param IncludeMacros Whether to include macros in the code-completion
+ /// results.
+ ///
+ /// \param IncludeCodePatterns Whether to include code patterns (such as a
+ /// for loop) in the code-completion results.
+ ///
+ /// FIXME: The Diag, LangOpts, SourceMgr, FileMgr, StoredDiagnostics, and
+ /// OwnedBuffers parameters are all disgusting hacks. They will go away.
+ void CodeComplete(llvm::StringRef File, unsigned Line, unsigned Column,
+ RemappedFile *RemappedFiles, unsigned NumRemappedFiles,
+ bool IncludeMacros, bool IncludeCodePatterns,
+ CodeCompleteConsumer &Consumer,
+ Diagnostic &Diag, LangOptions &LangOpts,
+ SourceManager &SourceMgr, FileManager &FileMgr,
+ llvm::SmallVectorImpl<StoredDiagnostic> &StoredDiagnostics,
+ llvm::SmallVectorImpl<const llvm::MemoryBuffer *> &OwnedBuffers);
+
+ /// \brief Save this translation unit to a file with the given name.
+ ///
+ /// \returns True if an error occurred, false otherwise.
+ bool Save(llvm::StringRef File);
};
} // namespace clang
diff --git a/include/clang/Frontend/AnalyzerOptions.h b/include/clang/Frontend/AnalyzerOptions.h
index ab4aed9..9ed15ba 100644
--- a/include/clang/Frontend/AnalyzerOptions.h
+++ b/include/clang/Frontend/AnalyzerOptions.h
@@ -66,6 +66,7 @@ public:
unsigned AnalyzerDisplayProgress : 1;
unsigned AnalyzeNestedBlocks : 1;
unsigned EagerlyAssume : 1;
+ unsigned IdempotentOps : 1;
unsigned PurgeDead : 1;
unsigned TrimGraph : 1;
unsigned VisualizeEGDot : 1;
@@ -74,6 +75,7 @@ public:
unsigned EnableExperimentalInternalChecks : 1;
unsigned EnableIdempotentOperationChecker : 1;
unsigned InlineCall : 1;
+ unsigned UnoptimizedCFG : 1;
public:
AnalyzerOptions() {
@@ -90,6 +92,7 @@ public:
VisualizeEGUbi = 0;
EnableExperimentalChecks = 0;
EnableExperimentalInternalChecks = 0;
+ UnoptimizedCFG = 0;
}
};
diff --git a/include/clang/Frontend/CodeGenOptions.h b/include/clang/Frontend/CodeGenOptions.h
index 2918f4e..b3f5709 100644
--- a/include/clang/Frontend/CodeGenOptions.h
+++ b/include/clang/Frontend/CodeGenOptions.h
@@ -46,7 +46,14 @@ public:
/// internal state before optimizations are
/// done.
unsigned DisableRedZone : 1; /// Set when -mno-red-zone is enabled.
+ unsigned EmitDeclMetadata : 1; /// Emit special metadata indicating what Decl*
+ /// various IR entities came from. Only useful
+ /// when running CodeGen as a subroutine.
unsigned FunctionSections : 1; /// Set when -ffunction-sections is enabled
+ unsigned HiddenWeakTemplateVTables : 1; /// Emit weak vtables and RTTI for
+ /// template classes with hidden visibility
+ unsigned HiddenWeakVTables : 1; /// Emit weak vtables, RTTI, and thunks with
+ /// hidden visibility
unsigned InstrumentFunctions : 1; /// Set when -finstrument-functions is enabled
unsigned MergeAllConstants : 1; /// Merge identical constants.
unsigned NoCommon : 1; /// Set when -fno-common or C++ is enabled.
@@ -67,9 +74,6 @@ public:
unsigned UnwindTables : 1; /// Emit unwind tables.
unsigned VerifyModule : 1; /// Control whether the module should be run
/// through the LLVM Verifier.
- unsigned EmitDeclMetadata : 1; /// Emit special metadata indicating what Decl*
- /// various IR entities came from. Only useful
- /// when running CodeGen as a subroutine.
/// The code model to use (-mcmodel).
std::string CodeModel;
@@ -108,7 +112,11 @@ public:
DisableFPElim = 0;
DisableLLVMOpts = 0;
DisableRedZone = 0;
+ EmitDeclMetadata = 0;
FunctionSections = 0;
+ HiddenWeakTemplateVTables = 0;
+ HiddenWeakVTables = 0;
+ InstrumentFunctions = 0;
MergeAllConstants = 1;
NoCommon = 0;
NoImplicitFloat = 0;
@@ -125,7 +133,6 @@ public:
UnrollLoops = 0;
UnwindTables = 0;
VerifyModule = 1;
- EmitDeclMetadata = 0;
Inlining = NoInlining;
RelocationModel = "pic";
diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h
index 54ce8bf..1b3c336 100644
--- a/include/clang/Frontend/CompilerInstance.h
+++ b/include/clang/Frontend/CompilerInstance.h
@@ -34,8 +34,9 @@ class DiagnosticClient;
class ExternalASTSource;
class FileManager;
class FrontendAction;
-class PCHReader;
+class ASTReader;
class Preprocessor;
+class Sema;
class SourceManager;
class TargetInfo;
@@ -67,9 +68,6 @@ class CompilerInstance {
/// The diagnostics engine instance.
llvm::IntrusiveRefCntPtr<Diagnostic> Diagnostics;
- /// The diagnostics client instance.
- llvm::OwningPtr<DiagnosticClient> DiagClient;
-
/// The target being compiled for.
llvm::OwningPtr<TargetInfo> Target;
@@ -91,15 +89,15 @@ class CompilerInstance {
/// The code completion consumer.
llvm::OwningPtr<CodeCompleteConsumer> CompletionConsumer;
+ /// \brief The semantic analysis object.
+ llvm::OwningPtr<Sema> TheSema;
+
/// The frontend timer
llvm::OwningPtr<llvm::Timer> FrontendTimer;
/// The list of active output files.
std::list< std::pair<std::string, llvm::raw_ostream*> > OutputFiles;
- /// The PCH reader. Not owned; the ASTContext owns this.
- PCHReader *Reader;
-
void operator=(const CompilerInstance &); // DO NOT IMPLEMENT
CompilerInstance(const CompilerInstance&); // DO NOT IMPLEMENT
public:
@@ -265,18 +263,11 @@ public:
void setDiagnostics(Diagnostic *Value);
DiagnosticClient &getDiagnosticClient() const {
- assert(DiagClient && "Compiler instance has no diagnostic client!");
- return *DiagClient;
+ assert(Diagnostics && Diagnostics->getClient() &&
+ "Compiler instance has no diagnostic client!");
+ return *Diagnostics->getClient();
}
- /// takeDiagnosticClient - Remove the current diagnostics client and give
- /// ownership to the caller.
- DiagnosticClient *takeDiagnosticClient() { return DiagClient.take(); }
-
- /// setDiagnosticClient - Replace the current diagnostics client; the compiler
- /// instance takes ownership of \arg Value.
- void setDiagnosticClient(DiagnosticClient *Value);
-
/// }
/// @name Target Info
/// {
@@ -372,6 +363,10 @@ public:
/// takes ownership of \arg Value.
void setASTContext(ASTContext *Value);
+ /// \brief Replace the current Sema; the compiler instance takes ownership
+ /// of S.
+ void setSema(Sema *S);
+
/// }
/// @name ASTConsumer
/// {
@@ -392,6 +387,18 @@ public:
void setASTConsumer(ASTConsumer *Value);
/// }
+ /// @name Semantic analysis
+ /// {
+ bool hasSema() const { return TheSema != 0; }
+
+ Sema &getSema() const {
+ assert(TheSema && "Compiler instance has no Sema object!");
+ return *TheSema;
+ }
+
+ Sema *takeSema() { return TheSema.take(); }
+
+ /// }
/// @name Code Completion
/// {
@@ -502,17 +509,18 @@ public:
/// Create an external AST source to read a PCH file and attach it to the AST
/// context.
- void createPCHExternalASTSource(llvm::StringRef Path);
+ void createPCHExternalASTSource(llvm::StringRef Path,
+ bool DisablePCHValidation,
+ void *DeserializationListener);
/// Create an external AST source to read a PCH file.
///
/// \return - The new object on success, or null on failure.
static ExternalASTSource *
createPCHExternalASTSource(llvm::StringRef Path, const std::string &Sysroot,
- Preprocessor &PP, ASTContext &Context);
-
- /// Get the PCH reader, if any.
- PCHReader *getPCHReader() { return Reader; }
+ bool DisablePCHValidation,
+ Preprocessor &PP, ASTContext &Context,
+ void *DeserializationListener);
/// Create a code completion consumer using the invocation; note that this
/// will cause the source manager to truncate the input source file at the
@@ -526,8 +534,13 @@ public:
createCodeCompletionConsumer(Preprocessor &PP, const std::string &Filename,
unsigned Line, unsigned Column,
bool UseDebugPrinter, bool ShowMacros,
- bool ShowCodePatterns, llvm::raw_ostream &OS);
+ bool ShowCodePatterns, bool ShowGlobals,
+ llvm::raw_ostream &OS);
+ /// \brief Create the Sema object to be used for parsing.
+ void createSema(bool CompleteTranslationUnit,
+ CodeCompleteConsumer *CompletionConsumer);
+
/// Create the frontend timer and replace any existing one with it.
void createFrontendTimer();
diff --git a/include/clang/Frontend/DeclXML.def b/include/clang/Frontend/DeclXML.def
index 16551ee..1845118 100644
--- a/include/clang/Frontend/DeclXML.def
+++ b/include/clang/Frontend/DeclXML.def
@@ -95,10 +95,10 @@ NODE_XML(FunctionDecl, "Function")
TYPE_ATTRIBUTE_XML(getType()->getAs<FunctionType>()->getResultType())
ATTRIBUTE_XML(getType()->getAs<FunctionType>(), "function_type")
ATTRIBUTE_ENUM_OPT_XML(getStorageClass(), "storage_class")
- ENUM_XML(FunctionDecl::None, "")
- ENUM_XML(FunctionDecl::Extern, "extern")
- ENUM_XML(FunctionDecl::Static, "static")
- ENUM_XML(FunctionDecl::PrivateExtern, "__private_extern__")
+ ENUM_XML(SC_None, "")
+ ENUM_XML(SC_Extern, "extern")
+ ENUM_XML(SC_Static, "static")
+ ENUM_XML(SC_PrivateExtern, "__private_extern__")
END_ENUM_XML
ATTRIBUTE_OPT_XML(isInlineSpecified(), "inline")
//ATTRIBUTE_OPT_XML(isVariadic(), "variadic") // in the type reference
@@ -289,12 +289,12 @@ NODE_XML(VarDecl, "Var")
ATTRIBUTE_XML(getNameAsString(), "name")
TYPE_ATTRIBUTE_XML(getType())
ATTRIBUTE_ENUM_OPT_XML(getStorageClass(), "storage_class")
- ENUM_XML(VarDecl::None, "")
- ENUM_XML(VarDecl::Auto, "auto")
- ENUM_XML(VarDecl::Register, "register")
- ENUM_XML(VarDecl::Extern, "extern")
- ENUM_XML(VarDecl::Static, "static")
- ENUM_XML(VarDecl::PrivateExtern, "__private_extern__")
+ ENUM_XML(SC_None, "")
+ ENUM_XML(SC_Auto, "auto")
+ ENUM_XML(SC_Register, "register")
+ ENUM_XML(SC_Extern, "extern")
+ ENUM_XML(SC_Static, "static")
+ ENUM_XML(SC_PrivateExtern, "__private_extern__")
END_ENUM_XML
SUB_NODE_OPT_XML(Expr) // init expr
END_NODE_XML
diff --git a/include/clang/Frontend/DiagnosticOptions.h b/include/clang/Frontend/DiagnosticOptions.h
index 516dc67..c80bc03 100644
--- a/include/clang/Frontend/DiagnosticOptions.h
+++ b/include/clang/Frontend/DiagnosticOptions.h
@@ -30,6 +30,7 @@ public:
unsigned ShowCarets : 1; /// Show carets in diagnostics.
unsigned ShowFixits : 1; /// Show fixit information.
unsigned ShowSourceRanges : 1; /// Show source ranges in numeric form.
+ unsigned ShowParseableFixits : 1; /// Show machine parseable fix-its.
unsigned ShowOptionNames : 1; /// Show the diagnostic name for mappable
/// diagnostics.
unsigned ShowCategories : 2; /// Show categories: 0 -> none, 1 -> Number,
@@ -83,6 +84,7 @@ public:
ShowOptionNames = 0;
ShowCategories = 0;
ShowSourceRanges = 0;
+ ShowParseableFixits = 0;
VerifyDiagnostics = 0;
BinaryOutput = 0;
ErrorLimit = 0;
diff --git a/include/clang/Frontend/DocumentXML.h b/include/clang/Frontend/DocumentXML.h
index 73d8921..602d846 100644
--- a/include/clang/Frontend/DocumentXML.h
+++ b/include/clang/Frontend/DocumentXML.h
@@ -150,7 +150,6 @@ inline void DocumentXML::addAttribute(const char* pName, const T& value) {
{
llvm::raw_string_ostream buf(repr);
buf << value;
- buf.flush();
}
Out << ' ' << pName << "=\""
diff --git a/include/clang/Frontend/FrontendAction.h b/include/clang/Frontend/FrontendAction.h
index f6a68bf..773543a 100644
--- a/include/clang/Frontend/FrontendAction.h
+++ b/include/clang/Frontend/FrontendAction.h
@@ -145,8 +145,8 @@ public:
/// @{
/// usesPreprocessorOnly - Does this action only use the preprocessor? If so
- /// no AST context will be created and this action will be invalid with PCH
- /// inputs.
+ /// no AST context will be created and this action will be invalid with AST
+ /// file inputs.
virtual bool usesPreprocessorOnly() const = 0;
/// usesCompleteTranslationUnit - For AST based actions, should the
@@ -225,8 +225,14 @@ protected:
llvm::StringRef InFile) = 0;
public:
- virtual bool ParseArgs(const std::vector<std::string>& arg) = 0;
- virtual void PrintHelp(llvm::raw_ostream&) = 0;
+ /// ParseArgs - Parse the given plugin command line arguments.
+ ///
+ /// \param CI - The compiler instance, for use in reporting diagnostics.
+ /// \return True if the parsing succeeded; otherwise the plugin will be
+ /// destroyed and no action run. The plugin is responsible for using the
+ /// CompilerInstance's Diagnostic object to report errors.
+ virtual bool ParseArgs(const CompilerInstance &CI,
+ const std::vector<std::string> &arg) = 0;
};
/// PreprocessorFrontendAction - Abstract base class to use for preprocessor
diff --git a/include/clang/Frontend/FrontendActions.h b/include/clang/Frontend/FrontendActions.h
index 26262cf..7b8063c 100644
--- a/include/clang/Frontend/FrontendActions.h
+++ b/include/clang/Frontend/FrontendActions.h
@@ -74,6 +74,17 @@ protected:
virtual bool usesCompleteTranslationUnit() { return false; }
virtual bool hasASTFileSupport() const { return false; }
+
+public:
+ /// \brief Compute the AST consumer arguments that will be used to
+ /// create the PCHGenerator instance returned by CreateASTConsumer.
+ ///
+ /// \returns true if an error occurred, false otherwise.
+ static bool ComputeASTConsumerArguments(CompilerInstance &CI,
+ llvm::StringRef InFile,
+ std::string &Sysroot,
+ llvm::raw_ostream *&OS,
+ bool &Chaining);
};
class InheritanceViewAction : public ASTFrontendAction {
@@ -134,6 +145,16 @@ public:
virtual bool hasCodeCompletionSupport() const;
};
+class PrintPreambleAction : public FrontendAction {
+protected:
+ void ExecuteAction();
+ virtual ASTConsumer *CreateASTConsumer(CompilerInstance &, llvm::StringRef) {
+ return 0;
+ }
+
+ virtual bool usesPreprocessorOnly() const { return true; }
+};
+
//===----------------------------------------------------------------------===//
// Preprocessor Actions
//===----------------------------------------------------------------------===//
@@ -153,28 +174,18 @@ protected:
void ExecuteAction();
};
-class ParseOnlyAction : public PreprocessorFrontendAction {
-protected:
- void ExecuteAction();
-};
-
class PreprocessOnlyAction : public PreprocessorFrontendAction {
protected:
void ExecuteAction();
};
-class PrintParseAction : public PreprocessorFrontendAction {
-protected:
- void ExecuteAction();
-};
-
class PrintPreprocessedAction : public PreprocessorFrontendAction {
protected:
void ExecuteAction();
virtual bool hasPCHSupport() const { return true; }
};
-
+
} // end namespace clang
#endif
diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h
index 4010ea6..4c16d08 100644
--- a/include/clang/Frontend/FrontendOptions.h
+++ b/include/clang/Frontend/FrontendOptions.h
@@ -25,6 +25,7 @@ namespace frontend {
ASTPrintXML, ///< Parse ASTs and print them in XML.
ASTView, ///< Parse ASTs and view them in Graphviz.
BoostCon, ///< BoostCon mode.
+ CreateModule, ///< Create module definition
DumpRawTokens, ///< Dump out raw tokens.
DumpTokens, ///< Dump out preprocessed tokens.
EmitAssembly, ///< Emit a .s file.
@@ -39,11 +40,10 @@ namespace frontend {
GeneratePTH, ///< Generate pre-tokenized header.
InheritanceView, ///< View C++ inheritance for a specified class.
InitOnly, ///< Only execute frontend initialization.
- ParseNoop, ///< Parse with noop callbacks.
- ParsePrintCallbacks, ///< Parse and print each callback.
ParseSyntaxOnly, ///< Parse and perform semantic analysis.
PluginAction, ///< Run a plugin action, \see ActionName.
PrintDeclContext, ///< Print DeclContext and their Decls.
+ PrintPreamble, ///< Print the "preamble" of the input file
PrintPreprocessedInput, ///< -E mode.
RewriteMacros, ///< Expand macros but not #includes.
RewriteObjC, ///< ObjC->C Rewriter.
@@ -60,21 +60,25 @@ public:
/// completion results.
unsigned DisableFree : 1; ///< Disable memory freeing on exit.
unsigned RelocatablePCH : 1; ///< When generating PCH files,
- /// instruct the PCH writer to create
+ /// instruct the AST writer to create
/// relocatable PCH files.
unsigned ChainedPCH : 1; ///< When generating PCH files,
- /// instruct the PCH writer to create
+ /// instruct the AST writer to create
/// chained PCH files.
unsigned ShowHelp : 1; ///< Show the -help text.
unsigned ShowMacrosInCodeCompletion : 1; ///< Show macros in code completion
/// results.
unsigned ShowCodePatternsInCodeCompletion : 1; ///< Show code patterns in code
/// completion results.
+ unsigned ShowGlobalSymbolsInCodeCompletion : 1; ///< Show top-level decls in
+ /// code completion results.
unsigned ShowStats : 1; ///< Show frontend performance
/// metrics and statistics.
unsigned ShowTimers : 1; ///< Show timers for individual
/// actions.
unsigned ShowVersion : 1; ///< Show the -version text.
+ unsigned FixWhatYouCan : 1; ///< Apply fixes even if there are
+ /// unfixable errors.
/// The input files and their types.
std::vector<std::pair<InputKind, std::string> > Inputs;
@@ -106,6 +110,9 @@ public:
/// \brief The list of AST files to merge.
std::vector<std::string> ASTMergeFiles;
+ /// \brief The list of modules to import.
+ std::vector<std::string> Modules;
+
/// \brief A list of arguments to forward to LLVM's option processing; this
/// should only be used for debugging and experimental features.
std::vector<std::string> LLVMArgs;
@@ -121,6 +128,7 @@ public:
ShowHelp = 0;
ShowMacrosInCodeCompletion = 0;
ShowCodePatternsInCodeCompletion = 0;
+ ShowGlobalSymbolsInCodeCompletion = 1;
ShowStats = 0;
ShowTimers = 0;
ShowVersion = 0;
diff --git a/include/clang/Frontend/HeaderSearchOptions.h b/include/clang/Frontend/HeaderSearchOptions.h
index c668245..588d32b 100644
--- a/include/clang/Frontend/HeaderSearchOptions.h
+++ b/include/clang/Frontend/HeaderSearchOptions.h
@@ -35,11 +35,16 @@ public:
frontend::IncludeDirGroup Group;
unsigned IsUserSupplied : 1;
unsigned IsFramework : 1;
-
- Entry(llvm::StringRef _Path, frontend::IncludeDirGroup _Group,
- bool _IsUserSupplied, bool _IsFramework)
- : Path(_Path), Group(_Group), IsUserSupplied(_IsUserSupplied),
- IsFramework(_IsFramework) {}
+
+ /// IsSysRootRelative - This is true if an absolute path should be treated
+ /// relative to the sysroot, or false if it should always be the absolute
+ /// path.
+ unsigned IsSysRootRelative : 1;
+
+ Entry(llvm::StringRef path, frontend::IncludeDirGroup group,
+ bool isUserSupplied, bool isFramework, bool isSysRootRelative)
+ : Path(path), Group(group), IsUserSupplied(isUserSupplied),
+ IsFramework(isFramework), IsSysRootRelative(isSysRootRelative) {}
};
/// If non-empty, the directory to use as a "virtual system root" for include
@@ -85,8 +90,9 @@ public:
/// AddPath - Add the \arg Path path to the specified \arg Group list.
void AddPath(llvm::StringRef Path, frontend::IncludeDirGroup Group,
- bool IsUserSupplied, bool IsFramework) {
- UserEntries.push_back(Entry(Path, Group, IsUserSupplied, IsFramework));
+ bool IsUserSupplied, bool IsFramework, bool IsSysRootRelative) {
+ UserEntries.push_back(Entry(Path, Group, IsUserSupplied, IsFramework,
+ IsSysRootRelative));
}
};
diff --git a/include/clang/Frontend/PCHBitCodes.h b/include/clang/Frontend/PCHBitCodes.h
deleted file mode 100644
index 27a2b7d..0000000
--- a/include/clang/Frontend/PCHBitCodes.h
+++ /dev/null
@@ -1,822 +0,0 @@
-//===- PCHBitCodes.h - Enum values for the PCH bitcode format ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This header defines Bitcode enum values for Clang precompiled header files.
-//
-// The enum values defined in this file should be considered permanent. If
-// new features are added, they should have values added at the end of the
-// respective lists.
-//
-//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_FRONTEND_PCHBITCODES_H
-#define LLVM_CLANG_FRONTEND_PCHBITCODES_H
-
-#include "llvm/Bitcode/BitCodes.h"
-#include "llvm/System/DataTypes.h"
-
-namespace clang {
- namespace pch {
- /// \brief PCH major version number supported by this version of
- /// Clang.
- ///
- /// Whenever the PCH format changes in a way that makes it
- /// incompatible with previous versions (such that a reader
- /// designed for the previous version could not support reading
- /// the new version), this number should be increased.
- ///
- /// Version 4 of PCH files also requires that the version control branch and
- /// revision match exactly, since there is no backward compatibility of
- /// PCH files at this time.
- const unsigned VERSION_MAJOR = 4;
-
- /// \brief PCH minor version number supported by this version of
- /// Clang.
- ///
- /// Whenever the PCH format changes in a way that is still
- /// compatible with previous versions (such that a reader designed
- /// for the previous version could still support reading the new
- /// version by ignoring new kinds of subblocks), this number
- /// should be increased.
- const unsigned VERSION_MINOR = 0;
-
- /// \brief An ID number that refers to a declaration in a PCH file.
- ///
- /// The ID numbers of declarations are consecutive (in order of
- /// discovery) and start at 2. 0 is reserved for NULL, and 1 is
- /// reserved for the translation unit declaration.
- typedef uint32_t DeclID;
-
- /// \brief An ID number that refers to a type in a PCH file.
- ///
- /// The ID of a type is partitioned into two parts: the lower
- /// three bits are used to store the const/volatile/restrict
- /// qualifiers (as with QualType) and the upper bits provide a
- /// type index. The type index values are partitioned into two
- /// sets. The values below NUM_PREDEF_TYPE_IDs are predefined type
- /// IDs (based on the PREDEF_TYPE_*_ID constants), with 0 as a
- /// placeholder for "no type". Values from NUM_PREDEF_TYPE_IDs are
- /// other types that have serialized representations.
- typedef uint32_t TypeID;
-
- /// \brief An ID number that refers to an identifier in a PCH
- /// file.
- typedef uint32_t IdentID;
-
- typedef uint32_t SelectorID;
-
- /// \brief Describes the various kinds of blocks that occur within
- /// a PCH file.
- enum BlockIDs {
- /// \brief The PCH block, which acts as a container around the
- /// full PCH block.
- PCH_BLOCK_ID = llvm::bitc::FIRST_APPLICATION_BLOCKID,
-
- /// \brief The block containing information about the source
- /// manager.
- SOURCE_MANAGER_BLOCK_ID,
-
- /// \brief The block containing information about the
- /// preprocessor.
- PREPROCESSOR_BLOCK_ID,
-
- /// \brief The block containing the definitions of all of the
- /// types and decls used within the PCH file.
- DECLTYPES_BLOCK_ID
- };
-
- /// \brief Record types that occur within the PCH block itself.
- enum PCHRecordTypes {
- /// \brief Record code for the offsets of each type.
- ///
- /// The TYPE_OFFSET constant describes the record that occurs
- /// within the PCH block. The record itself is an array of offsets that
- /// point into the declarations and types block (identified by
- /// DECLTYPES_BLOCK_ID). The index into the array is based on the ID
- /// of a type. For a given type ID @c T, the lower three bits of
- /// @c T are its qualifiers (const, volatile, restrict), as in
- /// the QualType class. The upper bits, after being shifted and
- /// subtracting NUM_PREDEF_TYPE_IDS, are used to index into the
- /// TYPE_OFFSET block to determine the offset of that type's
- /// corresponding record within the DECLTYPES_BLOCK_ID block.
- TYPE_OFFSET = 1,
-
- /// \brief Record code for the offsets of each decl.
- ///
- /// The DECL_OFFSET constant describes the record that occurs
- /// within the block identified by DECL_OFFSETS_BLOCK_ID within
- /// the PCH block. The record itself is an array of offsets that
- /// point into the declarations and types block (identified by
- /// DECLTYPES_BLOCK_ID). The declaration ID is an index into this
- /// record, after subtracting one to account for the use of
- /// declaration ID 0 for a NULL declaration pointer. Index 0 is
- /// reserved for the translation unit declaration.
- DECL_OFFSET = 2,
-
- /// \brief Record code for the language options table.
- ///
- /// The record with this code contains the contents of the
- /// LangOptions structure. We serialize the entire contents of
- /// the structure, and let the reader decide which options are
- /// actually important to check.
- LANGUAGE_OPTIONS = 3,
-
- /// \brief PCH metadata, including the PCH file version number
- /// and the target triple used to build the PCH file.
- METADATA = 4,
-
- /// \brief Record code for the table of offsets of each
- /// identifier ID.
- ///
- /// The offset table contains offsets into the blob stored in
- /// the IDENTIFIER_TABLE record. Each offset points to the
- /// NULL-terminated string that corresponds to that identifier.
- IDENTIFIER_OFFSET = 5,
-
- /// \brief Record code for the identifier table.
- ///
- /// The identifier table is a simple blob that contains
- /// NULL-terminated strings for all of the identifiers
- /// referenced by the PCH file. The IDENTIFIER_OFFSET table
- /// contains the mapping from identifier IDs to the characters
- /// in this blob. Note that the starting offsets of all of the
- /// identifiers are odd, so that, when the identifier offset
- /// table is loaded in, we can use the low bit to distinguish
- /// between offsets (for unresolved identifier IDs) and
- /// IdentifierInfo pointers (for already-resolved identifier
- /// IDs).
- IDENTIFIER_TABLE = 6,
-
- /// \brief Record code for the array of external definitions.
- ///
- /// The PCH file contains a list of all of the unnamed external
- /// definitions present within the parsed headers, stored as an
- /// array of declaration IDs. These external definitions will be
- /// reported to the AST consumer after the PCH file has been
- /// read, since their presence can affect the semantics of the
- /// program (e.g., for code generation).
- EXTERNAL_DEFINITIONS = 7,
-
- /// \brief Record code for the set of non-builtin, special
- /// types.
- ///
- /// This record contains the type IDs for the various type nodes
- /// that are constructed during semantic analysis (e.g.,
- /// __builtin_va_list). The SPECIAL_TYPE_* constants provide
- /// offsets into this record.
- SPECIAL_TYPES = 8,
-
- /// \brief Record code for the extra statistics we gather while
- /// generating a PCH file.
- STATISTICS = 9,
-
- /// \brief Record code for the array of tentative definitions.
- TENTATIVE_DEFINITIONS = 10,
-
- /// \brief Record code for the array of locally-scoped external
- /// declarations.
- LOCALLY_SCOPED_EXTERNAL_DECLS = 11,
-
- /// \brief Record code for the table of offsets into the
- /// Objective-C method pool.
- SELECTOR_OFFSETS = 12,
-
- /// \brief Record code for the Objective-C method pool,
- METHOD_POOL = 13,
-
- /// \brief The value of the next __COUNTER__ to dispense.
- /// [PP_COUNTER_VALUE, Val]
- PP_COUNTER_VALUE = 14,
-
- /// \brief Record code for the table of offsets into the block
- /// of source-location information.
- SOURCE_LOCATION_OFFSETS = 15,
-
- /// \brief Record code for the set of source location entries
- /// that need to be preloaded by the PCH reader.
- ///
- /// This set contains the source location entry for the
- /// predefines buffer and for any file entries that need to be
- /// preloaded.
- SOURCE_LOCATION_PRELOADS = 16,
-
- /// \brief Record code for the stat() cache.
- STAT_CACHE = 17,
-
- /// \brief Record code for the set of ext_vector type names.
- EXT_VECTOR_DECLS = 18,
-
- /// \brief Record code for the original file that was used to
- /// generate the precompiled header.
- ORIGINAL_FILE_NAME = 19,
-
- /// Record #20 intentionally left blank.
-
- /// \brief Record code for the version control branch and revision
- /// information of the compiler used to build this PCH file.
- VERSION_CONTROL_BRANCH_REVISION = 21,
-
- /// \brief Record code for the array of unused static functions.
- UNUSED_STATIC_FUNCS = 22,
-
- /// \brief Record code for the table of offsets to macro definition
- /// entries in the preprocessing record.
- MACRO_DEFINITION_OFFSETS = 23,
-
- /// \brief Record code for the array of VTable uses.
- VTABLE_USES = 24,
-
- /// \brief Record code for the array of dynamic classes.
- DYNAMIC_CLASSES = 25,
-
- /// \brief Record code for the chained PCH metadata, including the
- /// PCH version and the name of the PCH this is chained to.
- CHAINED_METADATA = 26
-
- };
-
- /// \brief Record types used within a source manager block.
- enum SourceManagerRecordTypes {
- /// \brief Describes a source location entry (SLocEntry) for a
- /// file.
- SM_SLOC_FILE_ENTRY = 1,
- /// \brief Describes a source location entry (SLocEntry) for a
- /// buffer.
- SM_SLOC_BUFFER_ENTRY = 2,
- /// \brief Describes a blob that contains the data for a buffer
- /// entry. This kind of record always directly follows a
- /// SM_SLOC_BUFFER_ENTRY record.
- SM_SLOC_BUFFER_BLOB = 3,
- /// \brief Describes a source location entry (SLocEntry) for a
- /// macro instantiation.
- SM_SLOC_INSTANTIATION_ENTRY = 4,
- /// \brief Describes the SourceManager's line table, with
- /// information about #line directives.
- SM_LINE_TABLE = 5
- };
-
- /// \brief Record types used within a preprocessor block.
- enum PreprocessorRecordTypes {
- // The macros in the PP section are a PP_MACRO_* instance followed by a
- // list of PP_TOKEN instances for each token in the definition.
-
- /// \brief An object-like macro definition.
- /// [PP_MACRO_OBJECT_LIKE, IdentInfoID, SLoc, IsUsed]
- PP_MACRO_OBJECT_LIKE = 1,
-
- /// \brief A function-like macro definition.
- /// [PP_MACRO_FUNCTION_LIKE, <ObjectLikeStuff>, IsC99Varargs, IsGNUVarars,
- /// NumArgs, ArgIdentInfoID* ]
- PP_MACRO_FUNCTION_LIKE = 2,
-
- /// \brief Describes one token.
- /// [PP_TOKEN, SLoc, Length, IdentInfoID, Kind, Flags]
- PP_TOKEN = 3,
-
- /// \brief Describes a macro instantiation within the preprocessing
- /// record.
- PP_MACRO_INSTANTIATION = 4,
-
- /// \brief Describes a macro definition within the preprocessing record.
- PP_MACRO_DEFINITION = 5
- };
-
- /// \defgroup PCHAST Precompiled header AST constants
- ///
- /// The constants in this group describe various components of the
- /// abstract syntax tree within a precompiled header.
- ///
- /// @{
-
- /// \brief Predefined type IDs.
- ///
- /// These type IDs correspond to predefined types in the AST
- /// context, such as built-in types (int) and special place-holder
- /// types (the <overload> and <dependent> type markers). Such
- /// types are never actually serialized, since they will be built
- /// by the AST context when it is created.
- enum PredefinedTypeIDs {
- /// \brief The NULL type.
- PREDEF_TYPE_NULL_ID = 0,
- /// \brief The void type.
- PREDEF_TYPE_VOID_ID = 1,
- /// \brief The 'bool' or '_Bool' type.
- PREDEF_TYPE_BOOL_ID = 2,
- /// \brief The 'char' type, when it is unsigned.
- PREDEF_TYPE_CHAR_U_ID = 3,
- /// \brief The 'unsigned char' type.
- PREDEF_TYPE_UCHAR_ID = 4,
- /// \brief The 'unsigned short' type.
- PREDEF_TYPE_USHORT_ID = 5,
- /// \brief The 'unsigned int' type.
- PREDEF_TYPE_UINT_ID = 6,
- /// \brief The 'unsigned long' type.
- PREDEF_TYPE_ULONG_ID = 7,
- /// \brief The 'unsigned long long' type.
- PREDEF_TYPE_ULONGLONG_ID = 8,
- /// \brief The 'char' type, when it is signed.
- PREDEF_TYPE_CHAR_S_ID = 9,
- /// \brief The 'signed char' type.
- PREDEF_TYPE_SCHAR_ID = 10,
- /// \brief The C++ 'wchar_t' type.
- PREDEF_TYPE_WCHAR_ID = 11,
- /// \brief The (signed) 'short' type.
- PREDEF_TYPE_SHORT_ID = 12,
- /// \brief The (signed) 'int' type.
- PREDEF_TYPE_INT_ID = 13,
- /// \brief The (signed) 'long' type.
- PREDEF_TYPE_LONG_ID = 14,
- /// \brief The (signed) 'long long' type.
- PREDEF_TYPE_LONGLONG_ID = 15,
- /// \brief The 'float' type.
- PREDEF_TYPE_FLOAT_ID = 16,
- /// \brief The 'double' type.
- PREDEF_TYPE_DOUBLE_ID = 17,
- /// \brief The 'long double' type.
- PREDEF_TYPE_LONGDOUBLE_ID = 18,
- /// \brief The placeholder type for overloaded function sets.
- PREDEF_TYPE_OVERLOAD_ID = 19,
- /// \brief The placeholder type for dependent types.
- PREDEF_TYPE_DEPENDENT_ID = 20,
- /// \brief The '__uint128_t' type.
- PREDEF_TYPE_UINT128_ID = 21,
- /// \brief The '__int128_t' type.
- PREDEF_TYPE_INT128_ID = 22,
- /// \brief The type of 'nullptr'.
- PREDEF_TYPE_NULLPTR_ID = 23,
- /// \brief The C++ 'char16_t' type.
- PREDEF_TYPE_CHAR16_ID = 24,
- /// \brief The C++ 'char32_t' type.
- PREDEF_TYPE_CHAR32_ID = 25,
- /// \brief The ObjC 'id' type.
- PREDEF_TYPE_OBJC_ID = 26,
- /// \brief The ObjC 'Class' type.
- PREDEF_TYPE_OBJC_CLASS = 27,
- /// \brief The ObjC 'SEL' type.
- PREDEF_TYPE_OBJC_SEL = 28
- };
-
- /// \brief The number of predefined type IDs that are reserved for
- /// the PREDEF_TYPE_* constants.
- ///
- /// Type IDs for non-predefined types will start at
- /// NUM_PREDEF_TYPE_IDs.
- const unsigned NUM_PREDEF_TYPE_IDS = 100;
-
- /// \brief Record codes for each kind of type.
- ///
- /// These constants describe the type records that can occur within a
- /// block identified by DECLTYPES_BLOCK_ID in the PCH file. Each
- /// constant describes a record for a specific type class in the
- /// AST.
- enum TypeCode {
- /// \brief An ExtQualType record.
- TYPE_EXT_QUAL = 1,
- /// \brief A ComplexType record.
- TYPE_COMPLEX = 3,
- /// \brief A PointerType record.
- TYPE_POINTER = 4,
- /// \brief A BlockPointerType record.
- TYPE_BLOCK_POINTER = 5,
- /// \brief An LValueReferenceType record.
- TYPE_LVALUE_REFERENCE = 6,
- /// \brief An RValueReferenceType record.
- TYPE_RVALUE_REFERENCE = 7,
- /// \brief A MemberPointerType record.
- TYPE_MEMBER_POINTER = 8,
- /// \brief A ConstantArrayType record.
- TYPE_CONSTANT_ARRAY = 9,
- /// \brief An IncompleteArrayType record.
- TYPE_INCOMPLETE_ARRAY = 10,
- /// \brief A VariableArrayType record.
- TYPE_VARIABLE_ARRAY = 11,
- /// \brief A VectorType record.
- TYPE_VECTOR = 12,
- /// \brief An ExtVectorType record.
- TYPE_EXT_VECTOR = 13,
- /// \brief A FunctionNoProtoType record.
- TYPE_FUNCTION_NO_PROTO = 14,
- /// \brief A FunctionProtoType record.
- TYPE_FUNCTION_PROTO = 15,
- /// \brief A TypedefType record.
- TYPE_TYPEDEF = 16,
- /// \brief A TypeOfExprType record.
- TYPE_TYPEOF_EXPR = 17,
- /// \brief A TypeOfType record.
- TYPE_TYPEOF = 18,
- /// \brief A RecordType record.
- TYPE_RECORD = 19,
- /// \brief An EnumType record.
- TYPE_ENUM = 20,
- /// \brief An ObjCInterfaceType record.
- TYPE_OBJC_INTERFACE = 21,
- /// \brief An ObjCObjectPointerType record.
- TYPE_OBJC_OBJECT_POINTER = 22,
- /// \brief a DecltypeType record.
- TYPE_DECLTYPE = 23,
- /// \brief An ElaboratedType record.
- TYPE_ELABORATED = 24,
- /// \brief A SubstTemplateTypeParmType record.
- TYPE_SUBST_TEMPLATE_TYPE_PARM = 25,
- /// \brief An UnresolvedUsingType record.
- TYPE_UNRESOLVED_USING = 26,
- /// \brief An InjectedClassNameType record.
- TYPE_INJECTED_CLASS_NAME = 27,
- /// \brief An ObjCObjectType record.
- TYPE_OBJC_OBJECT = 28,
- /// \brief An TemplateTypeParmType record.
- TYPE_TEMPLATE_TYPE_PARM = 29,
- /// \brief An TemplateSpecializationType record.
- TYPE_TEMPLATE_SPECIALIZATION = 30,
- /// \brief A DependentNameType record.
- TYPE_DEPENDENT_NAME = 31,
- /// \brief A DependentTemplateSpecializationType record.
- TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION = 32,
- /// \brief A DependentSizedArrayType record.
- TYPE_DEPENDENT_SIZED_ARRAY = 33
- };
-
- /// \brief The type IDs for special types constructed by semantic
- /// analysis.
- ///
- /// The constants in this enumeration are indices into the
- /// SPECIAL_TYPES record.
- enum SpecialTypeIDs {
- /// \brief __builtin_va_list
- SPECIAL_TYPE_BUILTIN_VA_LIST = 0,
- /// \brief Objective-C "id" type
- SPECIAL_TYPE_OBJC_ID = 1,
- /// \brief Objective-C selector type
- SPECIAL_TYPE_OBJC_SELECTOR = 2,
- /// \brief Objective-C Protocol type
- SPECIAL_TYPE_OBJC_PROTOCOL = 3,
- /// \brief Objective-C Class type
- SPECIAL_TYPE_OBJC_CLASS = 4,
- /// \brief CFConstantString type
- SPECIAL_TYPE_CF_CONSTANT_STRING = 5,
- /// \brief Objective-C fast enumeration state type
- SPECIAL_TYPE_OBJC_FAST_ENUMERATION_STATE = 6,
- /// \brief C FILE typedef type
- SPECIAL_TYPE_FILE = 7,
- /// \brief C jmp_buf typedef type
- SPECIAL_TYPE_jmp_buf = 8,
- /// \brief C sigjmp_buf typedef type
- SPECIAL_TYPE_sigjmp_buf = 9,
- /// \brief Objective-C "id" redefinition type
- SPECIAL_TYPE_OBJC_ID_REDEFINITION = 10,
- /// \brief Objective-C "Class" redefinition type
- SPECIAL_TYPE_OBJC_CLASS_REDEFINITION = 11,
- /// \brief Block descriptor type for Blocks CodeGen
- SPECIAL_TYPE_BLOCK_DESCRIPTOR = 12,
- /// \brief Block extedned descriptor type for Blocks CodeGen
- SPECIAL_TYPE_BLOCK_EXTENDED_DESCRIPTOR = 13,
- /// \brief Objective-C "SEL" redefinition type
- SPECIAL_TYPE_OBJC_SEL_REDEFINITION = 14,
- /// \brief NSConstantString type
- SPECIAL_TYPE_NS_CONSTANT_STRING = 15,
- /// \brief Whether __[u]int128_t identifier is installed.
- SPECIAL_TYPE_INT128_INSTALLED = 16
- };
-
- /// \brief Record codes for each kind of declaration.
- ///
- /// These constants describe the declaration records that can occur within
- /// a declarations block (identified by DECLS_BLOCK_ID). Each
- /// constant describes a record for a specific declaration class
- /// in the AST.
- enum DeclCode {
- /// \brief Attributes attached to a declaration.
- DECL_ATTR = 50,
- /// \brief A TranslationUnitDecl record.
- DECL_TRANSLATION_UNIT,
- /// \brief A TypedefDecl record.
- DECL_TYPEDEF,
- /// \brief An EnumDecl record.
- DECL_ENUM,
- /// \brief A RecordDecl record.
- DECL_RECORD,
- /// \brief An EnumConstantDecl record.
- DECL_ENUM_CONSTANT,
- /// \brief A FunctionDecl record.
- DECL_FUNCTION,
- /// \brief A ObjCMethodDecl record.
- DECL_OBJC_METHOD,
- /// \brief A ObjCInterfaceDecl record.
- DECL_OBJC_INTERFACE,
- /// \brief A ObjCProtocolDecl record.
- DECL_OBJC_PROTOCOL,
- /// \brief A ObjCIvarDecl record.
- DECL_OBJC_IVAR,
- /// \brief A ObjCAtDefsFieldDecl record.
- DECL_OBJC_AT_DEFS_FIELD,
- /// \brief A ObjCClassDecl record.
- DECL_OBJC_CLASS,
- /// \brief A ObjCForwardProtocolDecl record.
- DECL_OBJC_FORWARD_PROTOCOL,
- /// \brief A ObjCCategoryDecl record.
- DECL_OBJC_CATEGORY,
- /// \brief A ObjCCategoryImplDecl record.
- DECL_OBJC_CATEGORY_IMPL,
- /// \brief A ObjCImplementationDecl record.
- DECL_OBJC_IMPLEMENTATION,
- /// \brief A ObjCCompatibleAliasDecl record.
- DECL_OBJC_COMPATIBLE_ALIAS,
- /// \brief A ObjCPropertyDecl record.
- DECL_OBJC_PROPERTY,
- /// \brief A ObjCPropertyImplDecl record.
- DECL_OBJC_PROPERTY_IMPL,
- /// \brief A FieldDecl record.
- DECL_FIELD,
- /// \brief A VarDecl record.
- DECL_VAR,
- /// \brief An ImplicitParamDecl record.
- DECL_IMPLICIT_PARAM,
- /// \brief A ParmVarDecl record.
- DECL_PARM_VAR,
- /// \brief A FileScopeAsmDecl record.
- DECL_FILE_SCOPE_ASM,
- /// \brief A BlockDecl record.
- DECL_BLOCK,
- /// \brief A record that stores the set of declarations that are
- /// lexically stored within a given DeclContext.
- ///
- /// The record itself is an array of declaration IDs, in the
- /// order in which those declarations were added to the
- /// declaration context. This data is used when iterating over
- /// the contents of a DeclContext, e.g., via
- /// DeclContext::decls_begin()/DeclContext::decls_end().
- DECL_CONTEXT_LEXICAL,
- /// \brief A record that stores the set of declarations that are
- /// visible from a given DeclContext.
- ///
- /// The record itself stores a set of mappings, each of which
- /// associates a declaration name with one or more declaration
- /// IDs. This data is used when performing qualified name lookup
- /// into a DeclContext via DeclContext::lookup.
- DECL_CONTEXT_VISIBLE,
- /// \brief A NamespaceDecl rcord.
- DECL_NAMESPACE,
- /// \brief A NamespaceAliasDecl record.
- DECL_NAMESPACE_ALIAS,
- /// \brief A UsingDecl record.
- DECL_USING,
- /// \brief A UsingShadowDecl record.
- DECL_USING_SHADOW,
- /// \brief A UsingDirecitveDecl record.
- DECL_USING_DIRECTIVE,
- /// \brief An UnresolvedUsingValueDecl record.
- DECL_UNRESOLVED_USING_VALUE,
- /// \brief An UnresolvedUsingTypenameDecl record.
- DECL_UNRESOLVED_USING_TYPENAME,
- /// \brief A LinkageSpecDecl record.
- DECL_LINKAGE_SPEC,
- /// \brief A CXXRecordDecl record.
- DECL_CXX_RECORD,
- /// \brief A CXXMethodDecl record.
- DECL_CXX_METHOD,
- /// \brief A CXXConstructorDecl record.
- DECL_CXX_CONSTRUCTOR,
- /// \brief A CXXDestructorDecl record.
- DECL_CXX_DESTRUCTOR,
- /// \brief A CXXConversionDecl record.
- DECL_CXX_CONVERSION,
- /// \brief An AccessSpecDecl record.
- DECL_ACCESS_SPEC,
-
- // FIXME: Implement serialization for these decl types. This just
- // allocates the order in which
- DECL_FRIEND,
- DECL_FRIEND_TEMPLATE,
- DECL_CLASS_TEMPLATE,
- DECL_CLASS_TEMPLATE_SPECIALIZATION,
- DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION,
- DECL_FUNCTION_TEMPLATE,
- DECL_TEMPLATE_TYPE_PARM,
- DECL_NON_TYPE_TEMPLATE_PARM,
- DECL_TEMPLATE_TEMPLATE_PARM,
- DECL_STATIC_ASSERT
- };
-
- /// \brief Record codes for each kind of statement or expression.
- ///
- /// These constants describe the records that describe statements
- /// or expressions. These records occur within type and declarations
- /// block, so they begin with record values of 100. Each constant
- /// describes a record for a specific statement or expression class in the
- /// AST.
- enum StmtCode {
- /// \brief A marker record that indicates that we are at the end
- /// of an expression.
- STMT_STOP = 100,
- /// \brief A NULL expression.
- STMT_NULL_PTR,
- /// \brief A NullStmt record.
- STMT_NULL,
- /// \brief A CompoundStmt record.
- STMT_COMPOUND,
- /// \brief A CaseStmt record.
- STMT_CASE,
- /// \brief A DefaultStmt record.
- STMT_DEFAULT,
- /// \brief A LabelStmt record.
- STMT_LABEL,
- /// \brief An IfStmt record.
- STMT_IF,
- /// \brief A SwitchStmt record.
- STMT_SWITCH,
- /// \brief A WhileStmt record.
- STMT_WHILE,
- /// \brief A DoStmt record.
- STMT_DO,
- /// \brief A ForStmt record.
- STMT_FOR,
- /// \brief A GotoStmt record.
- STMT_GOTO,
- /// \brief An IndirectGotoStmt record.
- STMT_INDIRECT_GOTO,
- /// \brief A ContinueStmt record.
- STMT_CONTINUE,
- /// \brief A BreakStmt record.
- STMT_BREAK,
- /// \brief A ReturnStmt record.
- STMT_RETURN,
- /// \brief A DeclStmt record.
- STMT_DECL,
- /// \brief An AsmStmt record.
- STMT_ASM,
- /// \brief A PredefinedExpr record.
- EXPR_PREDEFINED,
- /// \brief A DeclRefExpr record.
- EXPR_DECL_REF,
- /// \brief An IntegerLiteral record.
- EXPR_INTEGER_LITERAL,
- /// \brief A FloatingLiteral record.
- EXPR_FLOATING_LITERAL,
- /// \brief An ImaginaryLiteral record.
- EXPR_IMAGINARY_LITERAL,
- /// \brief A StringLiteral record.
- EXPR_STRING_LITERAL,
- /// \brief A CharacterLiteral record.
- EXPR_CHARACTER_LITERAL,
- /// \brief A ParenExpr record.
- EXPR_PAREN,
- /// \brief A ParenListExpr record.
- EXPR_PAREN_LIST,
- /// \brief A UnaryOperator record.
- EXPR_UNARY_OPERATOR,
- /// \brief An OffsetOfExpr record.
- EXPR_OFFSETOF,
- /// \brief A SizefAlignOfExpr record.
- EXPR_SIZEOF_ALIGN_OF,
- /// \brief An ArraySubscriptExpr record.
- EXPR_ARRAY_SUBSCRIPT,
- /// \brief A CallExpr record.
- EXPR_CALL,
- /// \brief A MemberExpr record.
- EXPR_MEMBER,
- /// \brief A BinaryOperator record.
- EXPR_BINARY_OPERATOR,
- /// \brief A CompoundAssignOperator record.
- EXPR_COMPOUND_ASSIGN_OPERATOR,
- /// \brief A ConditionOperator record.
- EXPR_CONDITIONAL_OPERATOR,
- /// \brief An ImplicitCastExpr record.
- EXPR_IMPLICIT_CAST,
- /// \brief A CStyleCastExpr record.
- EXPR_CSTYLE_CAST,
- /// \brief A CompoundLiteralExpr record.
- EXPR_COMPOUND_LITERAL,
- /// \brief An ExtVectorElementExpr record.
- EXPR_EXT_VECTOR_ELEMENT,
- /// \brief An InitListExpr record.
- EXPR_INIT_LIST,
- /// \brief A DesignatedInitExpr record.
- EXPR_DESIGNATED_INIT,
- /// \brief An ImplicitValueInitExpr record.
- EXPR_IMPLICIT_VALUE_INIT,
- /// \brief A VAArgExpr record.
- EXPR_VA_ARG,
- /// \brief An AddrLabelExpr record.
- EXPR_ADDR_LABEL,
- /// \brief A StmtExpr record.
- EXPR_STMT,
- /// \brief A TypesCompatibleExpr record.
- EXPR_TYPES_COMPATIBLE,
- /// \brief A ChooseExpr record.
- EXPR_CHOOSE,
- /// \brief A GNUNullExpr record.
- EXPR_GNU_NULL,
- /// \brief A ShuffleVectorExpr record.
- EXPR_SHUFFLE_VECTOR,
- /// \brief BlockExpr
- EXPR_BLOCK,
- /// \brief A BlockDeclRef record.
- EXPR_BLOCK_DECL_REF,
-
- // Objective-C
-
- /// \brief An ObjCStringLiteral record.
- EXPR_OBJC_STRING_LITERAL,
- /// \brief An ObjCEncodeExpr record.
- EXPR_OBJC_ENCODE,
- /// \brief An ObjCSelectorExpr record.
- EXPR_OBJC_SELECTOR_EXPR,
- /// \brief An ObjCProtocolExpr record.
- EXPR_OBJC_PROTOCOL_EXPR,
- /// \brief An ObjCIvarRefExpr record.
- EXPR_OBJC_IVAR_REF_EXPR,
- /// \brief An ObjCPropertyRefExpr record.
- EXPR_OBJC_PROPERTY_REF_EXPR,
- /// \brief An ObjCImplicitSetterGetterRefExpr record.
- EXPR_OBJC_KVC_REF_EXPR,
- /// \brief An ObjCMessageExpr record.
- EXPR_OBJC_MESSAGE_EXPR,
- /// \brief An ObjCSuperExpr record.
- EXPR_OBJC_SUPER_EXPR,
- /// \brief An ObjCIsa Expr record.
- EXPR_OBJC_ISA,
-
- /// \brief An ObjCForCollectionStmt record.
- STMT_OBJC_FOR_COLLECTION,
- /// \brief An ObjCAtCatchStmt record.
- STMT_OBJC_CATCH,
- /// \brief An ObjCAtFinallyStmt record.
- STMT_OBJC_FINALLY,
- /// \brief An ObjCAtTryStmt record.
- STMT_OBJC_AT_TRY,
- /// \brief An ObjCAtSynchronizedStmt record.
- STMT_OBJC_AT_SYNCHRONIZED,
- /// \brief An ObjCAtThrowStmt record.
- STMT_OBJC_AT_THROW,
-
- // C++
-
- /// \brief A CXXOperatorCallExpr record.
- EXPR_CXX_OPERATOR_CALL,
- /// \brief A CXXMemberCallExpr record.
- EXPR_CXX_MEMBER_CALL,
- /// \brief A CXXConstructExpr record.
- EXPR_CXX_CONSTRUCT,
- /// \brief A CXXTemporaryObjectExpr record.
- EXPR_CXX_TEMPORARY_OBJECT,
- // \brief A CXXStaticCastExpr record.
- EXPR_CXX_STATIC_CAST,
- // \brief A CXXDynamicCastExpr record.
- EXPR_CXX_DYNAMIC_CAST,
- // \brief A CXXReinterpretCastExpr record.
- EXPR_CXX_REINTERPRET_CAST,
- // \brief A CXXConstCastExpr record.
- EXPR_CXX_CONST_CAST,
- // \brief A CXXFunctionalCastExpr record.
- EXPR_CXX_FUNCTIONAL_CAST,
- // \brief A CXXBoolLiteralExpr record.
- EXPR_CXX_BOOL_LITERAL,
- EXPR_CXX_NULL_PTR_LITERAL, // CXXNullPtrLiteralExpr
- EXPR_CXX_TYPEID_EXPR, // CXXTypeidExpr (of expr).
- EXPR_CXX_TYPEID_TYPE, // CXXTypeidExpr (of type).
- EXPR_CXX_THIS, // CXXThisExpr
- EXPR_CXX_THROW, // CXXThrowExpr
- EXPR_CXX_DEFAULT_ARG, // CXXDefaultArgExpr
- EXPR_CXX_BIND_TEMPORARY, // CXXBindTemporaryExpr
- EXPR_CXX_BIND_REFERENCE, // CXXBindReferenceExpr
-
- EXPR_CXX_SCALAR_VALUE_INIT, // CXXScalarValueInitExpr
- EXPR_CXX_NEW, // CXXNewExpr
- EXPR_CXX_DELETE, // CXXDeleteExpr
- EXPR_CXX_PSEUDO_DESTRUCTOR, // CXXPseudoDestructorExpr
-
- EXPR_CXX_EXPR_WITH_TEMPORARIES, // CXXExprWithTemporaries
-
- EXPR_CXX_DEPENDENT_SCOPE_MEMBER, // CXXDependentScopeMemberExpr
- EXPR_CXX_DEPENDENT_SCOPE_DECL_REF, // DependentScopeDeclRefExpr
- EXPR_CXX_UNRESOLVED_CONSTRUCT, // CXXUnresolvedConstructExpr
- EXPR_CXX_UNRESOLVED_MEMBER, // UnresolvedMemberExpr
- EXPR_CXX_UNRESOLVED_LOOKUP, // UnresolvedLookupExpr
-
- EXPR_CXX_UNARY_TYPE_TRAIT // UnaryTypeTraitExpr
- };
-
- /// \brief The kinds of designators that can occur in a
- /// DesignatedInitExpr.
- enum DesignatorTypes {
- /// \brief Field designator where only the field name is known.
- DESIG_FIELD_NAME = 0,
- /// \brief Field designator where the field has been resolved to
- /// a declaration.
- DESIG_FIELD_DECL = 1,
- /// \brief Array designator.
- DESIG_ARRAY = 2,
- /// \brief GNU array range designator.
- DESIG_ARRAY_RANGE = 3
- };
-
- /// @}
- }
-} // end namespace clang
-
-#endif
diff --git a/include/clang/Frontend/PCHDeserializationListener.h b/include/clang/Frontend/PCHDeserializationListener.h
deleted file mode 100644
index c9b90e2..0000000
--- a/include/clang/Frontend/PCHDeserializationListener.h
+++ /dev/null
@@ -1,36 +0,0 @@
-//===- PCHDeserializationListener.h - Decl/Type PCH Read Events -*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines the PCHDeserializationListener class, which is notified
-// by the PCHReader whenever a type or declaration is deserialized.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_FRONTEND_PCH_DESERIALIZATION_LISTENER_H
-#define LLVM_CLANG_FRONTEND_PCH_DESERIALIZATION_LISTENER_H
-
-#include "clang/Frontend/PCHBitCodes.h"
-
-namespace clang {
-
-class Decl;
-class QualType;
-
-class PCHDeserializationListener {
-protected:
- ~PCHDeserializationListener() {}
-
-public:
- virtual void TypeRead(pch::TypeID ID, QualType T) = 0;
- virtual void DeclRead(pch::DeclID ID, const Decl *D) = 0;
-};
-
-}
-
-#endif
diff --git a/include/clang/Frontend/PCHReader.h b/include/clang/Frontend/PCHReader.h
deleted file mode 100644
index 47e871f..0000000
--- a/include/clang/Frontend/PCHReader.h
+++ /dev/null
@@ -1,905 +0,0 @@
-//===--- PCHReader.h - Precompiled Headers Reader ---------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines the PCHReader class, which reads a precompiled header.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_FRONTEND_PCH_READER_H
-#define LLVM_CLANG_FRONTEND_PCH_READER_H
-
-#include "clang/Frontend/PCHBitCodes.h"
-#include "clang/AST/DeclarationName.h"
-#include "clang/Sema/ExternalSemaSource.h"
-#include "clang/AST/DeclObjC.h"
-#include "clang/AST/Type.h"
-#include "clang/AST/TemplateBase.h"
-#include "clang/Lex/ExternalPreprocessorSource.h"
-#include "clang/Lex/PreprocessingRecord.h"
-#include "clang/Basic/Diagnostic.h"
-#include "clang/Basic/IdentifierTable.h"
-#include "clang/Basic/SourceManager.h"
-#include "llvm/ADT/APFloat.h"
-#include "llvm/ADT/APInt.h"
-#include "llvm/ADT/APSInt.h"
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/OwningPtr.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Bitcode/BitstreamReader.h"
-#include "llvm/System/DataTypes.h"
-#include <deque>
-#include <map>
-#include <string>
-#include <utility>
-#include <vector>
-
-namespace llvm {
- class MemoryBuffer;
-}
-
-namespace clang {
-
-class AddrLabelExpr;
-class ASTConsumer;
-class ASTContext;
-class Attr;
-class Decl;
-class DeclContext;
-class NestedNameSpecifier;
-class CXXBaseSpecifier;
-class CXXBaseOrMemberInitializer;
-class GotoStmt;
-class LabelStmt;
-class MacroDefinition;
-class NamedDecl;
-class PCHDeserializationListener;
-class Preprocessor;
-class Sema;
-class SwitchCase;
-class PCHReader;
-struct HeaderFileInfo;
-
-struct PCHPredefinesBlock {
- /// \brief The file ID for this predefines buffer in a PCH file.
- FileID BufferID;
-
- /// \brief This predefines buffer in a PCH file.
- llvm::StringRef Data;
-};
-typedef llvm::SmallVector<PCHPredefinesBlock, 2> PCHPredefinesBlocks;
-
-/// \brief Abstract interface for callback invocations by the PCHReader.
-///
-/// While reading a PCH file, the PCHReader will call the methods of the
-/// listener to pass on specific information. Some of the listener methods can
-/// return true to indicate to the PCHReader that the information (and
-/// consequently the PCH file) is invalid.
-class PCHReaderListener {
-public:
- virtual ~PCHReaderListener();
-
- /// \brief Receives the language options.
- ///
- /// \returns true to indicate the options are invalid or false otherwise.
- virtual bool ReadLanguageOptions(const LangOptions &LangOpts) {
- return false;
- }
-
- /// \brief Receives the target triple.
- ///
- /// \returns true to indicate the target triple is invalid or false otherwise.
- virtual bool ReadTargetTriple(llvm::StringRef Triple) {
- return false;
- }
-
- /// \brief Receives the contents of the predefines buffer.
- ///
- /// \param Buffers Information about the predefines buffers.
- ///
- /// \param OriginalFileName The original file name for the PCH, which will
- /// appear as an entry in the predefines buffer.
- ///
- /// \param SuggestedPredefines If necessary, additional definitions are added
- /// here.
- ///
- /// \returns true to indicate the predefines are invalid or false otherwise.
- virtual bool ReadPredefinesBuffer(const PCHPredefinesBlocks &Buffers,
- llvm::StringRef OriginalFileName,
- std::string &SuggestedPredefines) {
- return false;
- }
-
- /// \brief Receives a HeaderFileInfo entry.
- virtual void ReadHeaderFileInfo(const HeaderFileInfo &HFI, unsigned ID) {}
-
- /// \brief Receives __COUNTER__ value.
- virtual void ReadCounter(unsigned Value) {}
-};
-
-/// \brief PCHReaderListener implementation to validate the information of
-/// the PCH file against an initialized Preprocessor.
-class PCHValidator : public PCHReaderListener {
- Preprocessor &PP;
- PCHReader &Reader;
-
- unsigned NumHeaderInfos;
-
-public:
- PCHValidator(Preprocessor &PP, PCHReader &Reader)
- : PP(PP), Reader(Reader), NumHeaderInfos(0) {}
-
- virtual bool ReadLanguageOptions(const LangOptions &LangOpts);
- virtual bool ReadTargetTriple(llvm::StringRef Triple);
- virtual bool ReadPredefinesBuffer(const PCHPredefinesBlocks &Buffers,
- llvm::StringRef OriginalFileName,
- std::string &SuggestedPredefines);
- virtual void ReadHeaderFileInfo(const HeaderFileInfo &HFI, unsigned ID);
- virtual void ReadCounter(unsigned Value);
-
-private:
- void Error(const char *Msg);
-};
-
-/// \brief Reads a precompiled head containing the contents of a
-/// translation unit.
-///
-/// The PCHReader class reads a bitstream (produced by the PCHWriter
-/// class) containing the serialized representation of a given
-/// abstract syntax tree and its supporting data structures. An
-/// instance of the PCHReader can be attached to an ASTContext object,
-/// which will provide access to the contents of the PCH file.
-///
-/// The PCH reader provides lazy de-serialization of declarations, as
-/// required when traversing the AST. Only those AST nodes that are
-/// actually required will be de-serialized.
-class PCHReader
- : public ExternalPreprocessorSource,
- public ExternalPreprocessingRecordSource,
- public ExternalSemaSource,
- public IdentifierInfoLookup,
- public ExternalIdentifierLookup,
- public ExternalSLocEntrySource {
-public:
- enum PCHReadResult { Success, Failure, IgnorePCH };
- friend class PCHValidator;
-private:
- /// \brief The receiver of some callbacks invoked by PCHReader.
- llvm::OwningPtr<PCHReaderListener> Listener;
-
- /// \brief The receiver of deserialization events.
- PCHDeserializationListener *DeserializationListener;
-
- SourceManager &SourceMgr;
- FileManager &FileMgr;
- Diagnostic &Diags;
-
- /// \brief The semantic analysis object that will be processing the
- /// PCH file and the translation unit that uses it.
- Sema *SemaObj;
-
- /// \brief The preprocessor that will be loading the source file.
- Preprocessor *PP;
-
- /// \brief The AST context into which we'll read the PCH file.
- ASTContext *Context;
-
- /// \brief The PCH stat cache installed by this PCHReader, if any.
- ///
- /// The dynamic type of this stat cache is always PCHStatCache
- void *StatCache;
-
- /// \brief The AST consumer.
- ASTConsumer *Consumer;
-
- /// \brief The bitstream reader from which we'll read the PCH file.
- llvm::BitstreamReader StreamFile;
- llvm::BitstreamCursor Stream;
-
- /// \brief The cursor to the start of the preprocessor block, which stores
- /// all of the macro definitions.
- llvm::BitstreamCursor MacroCursor;
-
- /// DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block. It
- /// has read all the abbreviations at the start of the block and is ready to
- /// jump around with these in context.
- llvm::BitstreamCursor DeclsCursor;
-
- /// \brief The file name of the PCH file.
- std::string FileName;
-
- /// \brief The memory buffer that stores the data associated with
- /// this PCH file.
- llvm::OwningPtr<llvm::MemoryBuffer> Buffer;
-
- /// \brief Offset type for all of the source location entries in the
- /// PCH file.
- const uint32_t *SLocOffsets;
-
- /// \brief The number of source location entries in the PCH file.
- unsigned TotalNumSLocEntries;
-
- /// \brief Cursor used to read source location entries.
- llvm::BitstreamCursor SLocEntryCursor;
-
- /// \brief Offset of each type within the bitstream, indexed by the
- /// type ID, or the representation of a Type*.
- const uint32_t *TypeOffsets;
-
- /// \brief Types that have already been loaded from the PCH file.
- ///
- /// When the pointer at index I is non-NULL, the type with
- /// ID = (I + 1) << 3 has already been loaded from the PCH file.
- std::vector<QualType> TypesLoaded;
-
- /// \brief Offset of each declaration within the bitstream, indexed
- /// by the declaration ID (-1).
- const uint32_t *DeclOffsets;
-
- /// \brief Declarations that have already been loaded from the PCH file.
- ///
- /// When the pointer at index I is non-NULL, the declaration with ID
- /// = I + 1 has already been loaded.
- std::vector<Decl *> DeclsLoaded;
-
- typedef llvm::DenseMap<const DeclContext *, std::pair<uint64_t, uint64_t> >
- DeclContextOffsetsMap;
-
- /// \brief Offsets of the lexical and visible declarations for each
- /// DeclContext.
- DeclContextOffsetsMap DeclContextOffsets;
-
- /// \brief Actual data for the on-disk hash table.
- ///
- // This pointer points into a memory buffer, where the on-disk hash
- // table for identifiers actually lives.
- const char *IdentifierTableData;
-
- /// \brief A pointer to an on-disk hash table of opaque type
- /// IdentifierHashTable.
- void *IdentifierLookupTable;
-
- /// \brief Offsets into the identifier table data.
- ///
- /// This array is indexed by the identifier ID (-1), and provides
- /// the offset into IdentifierTableData where the string data is
- /// stored.
- const uint32_t *IdentifierOffsets;
-
- /// \brief A vector containing identifiers that have already been
- /// loaded.
- ///
- /// If the pointer at index I is non-NULL, then it refers to the
- /// IdentifierInfo for the identifier with ID=I+1 that has already
- /// been loaded.
- std::vector<IdentifierInfo *> IdentifiersLoaded;
-
- /// \brief A pointer to an on-disk hash table of opaque type
- /// PCHMethodPoolLookupTable.
- ///
- /// This hash table provides the instance and factory methods
- /// associated with every selector known in the PCH file.
- void *MethodPoolLookupTable;
-
- /// \brief A pointer to the character data that comprises the method
- /// pool.
- ///
- /// The SelectorOffsets table refers into this memory.
- const unsigned char *MethodPoolLookupTableData;
-
- /// \brief The number of selectors stored in the method pool itself.
- unsigned TotalSelectorsInMethodPool;
-
- /// \brief Offsets into the method pool lookup table's data array
- /// where each selector resides.
- const uint32_t *SelectorOffsets;
-
- /// \brief The total number of selectors stored in the PCH file.
- unsigned TotalNumSelectors;
-
- /// \brief A vector containing selectors that have already been loaded.
- ///
- /// This vector is indexed by the Selector ID (-1). NULL selector
- /// entries indicate that the particular selector ID has not yet
- /// been loaded.
- llvm::SmallVector<Selector, 16> SelectorsLoaded;
-
- /// \brief Offsets of all of the macro definitions in the preprocessing
- /// record in the PCH file.
- const uint32_t *MacroDefinitionOffsets;
-
- /// \brief The macro definitions we have already loaded.
- llvm::SmallVector<MacroDefinition *, 16> MacroDefinitionsLoaded;
-
- /// \brief The number of preallocated preprocessing entities in the
- /// preprocessing record.
- unsigned NumPreallocatedPreprocessingEntities;
-
- /// \brief The set of external definitions stored in the the PCH
- /// file.
- llvm::SmallVector<uint64_t, 16> ExternalDefinitions;
-
- /// \brief The set of tentative definitions stored in the the PCH
- /// file.
- llvm::SmallVector<uint64_t, 16> TentativeDefinitions;
-
- /// \brief The set of unused static functions stored in the the PCH
- /// file.
- llvm::SmallVector<uint64_t, 16> UnusedStaticFuncs;
-
- /// \brief The set of locally-scoped external declarations stored in
- /// the the PCH file.
- llvm::SmallVector<uint64_t, 16> LocallyScopedExternalDecls;
-
- /// \brief The set of ext_vector type declarations stored in the the
- /// PCH file.
- llvm::SmallVector<uint64_t, 4> ExtVectorDecls;
-
- /// \brief The set of VTable uses of CXXRecordDecls stored in the PCH file.
- llvm::SmallVector<uint64_t, 64> VTableUses;
-
- /// \brief The set of dynamic CXXRecord declarations stored in the PCH file.
- llvm::SmallVector<uint64_t, 16> DynamicClasses;
-
- /// \brief The set of Objective-C category definitions stored in the
- /// the PCH file.
- llvm::SmallVector<uint64_t, 4> ObjCCategoryImpls;
-
- /// \brief The original file name that was used to build the PCH file, which
- /// may have been modified for relocatable-pch support.
- std::string OriginalFileName;
-
- /// \brief The actual original file name that was used to build the PCH file.
- std::string ActualOriginalFileName;
-
- /// \brief Whether this precompiled header is a relocatable PCH file.
- bool RelocatablePCH;
-
- /// \brief The system include root to be used when loading the
- /// precompiled header.
- const char *isysroot;
-
- /// \brief Mapping from switch-case IDs in the PCH file to
- /// switch-case statements.
- std::map<unsigned, SwitchCase *> SwitchCaseStmts;
-
- /// \brief Mapping from label statement IDs in the PCH file to label
- /// statements.
- std::map<unsigned, LabelStmt *> LabelStmts;
-
- /// \brief Mapping from label IDs to the set of "goto" statements
- /// that point to that label before the label itself has been
- /// de-serialized.
- std::multimap<unsigned, GotoStmt *> UnresolvedGotoStmts;
-
- /// \brief Mapping from label IDs to the set of address label
- /// expressions that point to that label before the label itself has
- /// been de-serialized.
- std::multimap<unsigned, AddrLabelExpr *> UnresolvedAddrLabelExprs;
-
- /// \brief The number of stat() calls that hit/missed the stat
- /// cache.
- unsigned NumStatHits, NumStatMisses;
-
- /// \brief The number of source location entries de-serialized from
- /// the PCH file.
- unsigned NumSLocEntriesRead;
-
- /// \brief The number of statements (and expressions) de-serialized
- /// from the PCH file.
- unsigned NumStatementsRead;
-
- /// \brief The total number of statements (and expressions) stored
- /// in the PCH file.
- unsigned TotalNumStatements;
-
- /// \brief The number of macros de-serialized from the PCH file.
- unsigned NumMacrosRead;
-
- /// \brief The number of method pool entries that have been read.
- unsigned NumMethodPoolSelectorsRead;
-
- /// \brief The number of times we have looked into the global method
- /// pool and not found anything.
- unsigned NumMethodPoolMisses;
-
- /// \brief The total number of macros stored in the PCH file.
- unsigned TotalNumMacros;
-
- /// Number of lexical decl contexts read/total.
- unsigned NumLexicalDeclContextsRead, TotalLexicalDeclContexts;
-
- /// Number of visible decl contexts read/total.
- unsigned NumVisibleDeclContextsRead, TotalVisibleDeclContexts;
-
- /// \brief When a type or declaration is being loaded from the PCH file, an
- /// instantance of this RAII object will be available on the stack to
- /// indicate when we are in a recursive-loading situation.
- class LoadingTypeOrDecl {
- PCHReader &Reader;
- LoadingTypeOrDecl *Parent;
-
- LoadingTypeOrDecl(const LoadingTypeOrDecl&); // do not implement
- LoadingTypeOrDecl &operator=(const LoadingTypeOrDecl&); // do not implement
-
- public:
- explicit LoadingTypeOrDecl(PCHReader &Reader);
- ~LoadingTypeOrDecl();
- };
- friend class LoadingTypeOrDecl;
-
- /// \brief If we are currently loading a type or declaration, points to the
- /// most recent LoadingTypeOrDecl object on the stack.
- LoadingTypeOrDecl *CurrentlyLoadingTypeOrDecl;
-
- /// \brief An IdentifierInfo that has been loaded but whose top-level
- /// declarations of the same name have not (yet) been loaded.
- struct PendingIdentifierInfo {
- IdentifierInfo *II;
- llvm::SmallVector<uint32_t, 4> DeclIDs;
- };
-
- /// \brief The set of identifiers that were read while the PCH reader was
- /// (recursively) loading declarations.
- ///
- /// The declarations on the identifier chain for these identifiers will be
- /// loaded once the recursive loading has completed.
- std::deque<PendingIdentifierInfo> PendingIdentifierInfos;
-
- /// \brief FIXME: document!
- llvm::SmallVector<uint64_t, 16> SpecialTypes;
-
- /// \brief Contains declarations and definitions that will be
- /// "interesting" to the ASTConsumer, when we get that AST consumer.
- ///
- /// "Interesting" declarations are those that have data that may
- /// need to be emitted, such as inline function definitions or
- /// Objective-C protocols.
- std::deque<Decl *> InterestingDecls;
-
- /// \brief When reading a Stmt tree, Stmt operands are placed in this stack.
- llvm::SmallVector<Stmt *, 16> StmtStack;
-
- /// \brief What kind of records we are reading.
- enum ReadingKind {
- Read_Decl, Read_Type, Read_Stmt
- };
-
- /// \brief What kind of records we are reading.
- ReadingKind ReadingKind;
-
- /// \brief RAII object to change the reading kind.
- class ReadingKindTracker {
- PCHReader &Reader;
- enum ReadingKind PrevKind;
-
- ReadingKindTracker(const ReadingKindTracker&); // do not implement
- ReadingKindTracker &operator=(const ReadingKindTracker&);// do not implement
-
- public:
- ReadingKindTracker(enum ReadingKind newKind, PCHReader &reader)
- : Reader(reader), PrevKind(Reader.ReadingKind) {
- Reader.ReadingKind = newKind;
- }
-
- ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; }
- };
-
- /// \brief All predefines buffers in all PCH files, to be treated as if
- /// concatenated.
- PCHPredefinesBlocks PCHPredefinesBuffers;
-
- /// \brief Suggested contents of the predefines buffer, after this
- /// PCH file has been processed.
- ///
- /// In most cases, this string will be empty, because the predefines
- /// buffer computed to build the PCH file will be identical to the
- /// predefines buffer computed from the command line. However, when
- /// there are differences that the PCH reader can work around, this
- /// predefines buffer may contain additional definitions.
- std::string SuggestedPredefines;
-
- /// \brief Reads a statement from the specified cursor.
- Stmt *ReadStmtFromStream(llvm::BitstreamCursor &Cursor);
-
- void MaybeAddSystemRootToFilename(std::string &Filename);
-
- PCHReadResult ReadPCHBlock();
- bool CheckPredefinesBuffers();
- bool ParseLineTable(llvm::SmallVectorImpl<uint64_t> &Record);
- PCHReadResult ReadSourceManagerBlock();
- PCHReadResult ReadSLocEntryRecord(unsigned ID);
-
- bool ParseLanguageOptions(const llvm::SmallVectorImpl<uint64_t> &Record);
- QualType ReadTypeRecord(uint64_t Offset);
- void LoadedDecl(unsigned Index, Decl *D);
- Decl *ReadDeclRecord(uint64_t Offset, unsigned Index);
-
- void PassInterestingDeclsToConsumer();
-
- /// \brief Produce an error diagnostic and return true.
- ///
- /// This routine should only be used for fatal errors that have to
- /// do with non-routine failures (e.g., corrupted PCH file).
- void Error(const char *Msg);
-
- PCHReader(const PCHReader&); // do not implement
- PCHReader &operator=(const PCHReader &); // do not implement
-public:
- typedef llvm::SmallVector<uint64_t, 64> RecordData;
-
- /// \brief Load the PCH file and validate its contents against the given
- /// Preprocessor.
- ///
- /// \param PP the preprocessor associated with the context in which this
- /// precompiled header will be loaded.
- ///
- /// \param Context the AST context that this precompiled header will be
- /// loaded into.
- ///
- /// \param isysroot If non-NULL, the system include path specified by the
- /// user. This is only used with relocatable PCH files. If non-NULL,
- /// a relocatable PCH file will use the default path "/".
- PCHReader(Preprocessor &PP, ASTContext *Context, const char *isysroot = 0);
-
- /// \brief Load the PCH file without using any pre-initialized Preprocessor.
- ///
- /// The necessary information to initialize a Preprocessor later can be
- /// obtained by setting a PCHReaderListener.
- ///
- /// \param SourceMgr the source manager into which the precompiled header
- /// will be loaded.
- ///
- /// \param FileMgr the file manager into which the precompiled header will
- /// be loaded.
- ///
- /// \param Diags the diagnostics system to use for reporting errors and
- /// warnings relevant to loading the precompiled header.
- ///
- /// \param isysroot If non-NULL, the system include path specified by the
- /// user. This is only used with relocatable PCH files. If non-NULL,
- /// a relocatable PCH file will use the default path "/".
- PCHReader(SourceManager &SourceMgr, FileManager &FileMgr,
- Diagnostic &Diags, const char *isysroot = 0);
- ~PCHReader();
-
- /// \brief Load the precompiled header designated by the given file
- /// name.
- PCHReadResult ReadPCH(const std::string &FileName);
-
- /// \brief Set the PCH callbacks listener.
- void setListener(PCHReaderListener *listener) {
- Listener.reset(listener);
- }
-
- void setDeserializationListener(PCHDeserializationListener *Listener) {
- DeserializationListener = Listener;
- }
-
- /// \brief Set the Preprocessor to use.
- void setPreprocessor(Preprocessor &pp);
-
- /// \brief Sets and initializes the given Context.
- void InitializeContext(ASTContext &Context);
-
- /// \brief Retrieve the name of the PCH file
- const std::string &getFileName() const { return FileName; }
-
- /// \brief Retrieve the name of the original source file name
- const std::string &getOriginalSourceFile() { return OriginalFileName; }
-
- /// \brief Retrieve the name of the original source file name
- /// directly from the PCH file, without actually loading the PCH
- /// file.
- static std::string getOriginalSourceFile(const std::string &PCHFileName,
- Diagnostic &Diags);
-
- /// \brief Returns the suggested contents of the predefines buffer,
- /// which contains a (typically-empty) subset of the predefines
- /// build prior to including the precompiled header.
- const std::string &getSuggestedPredefines() { return SuggestedPredefines; }
-
- /// \brief Read preprocessed entities into the
- virtual void ReadPreprocessedEntities();
-
- /// \brief Returns the number of types found in this file.
- unsigned getTotalNumTypes() const {
- return static_cast<unsigned>(TypesLoaded.size());
- }
-
- /// \brief Returns the number of declarations found in this file.
- unsigned getTotalNumDecls() const {
- return static_cast<unsigned>(DeclsLoaded.size());
- }
-
- /// \brief Reads a TemplateArgumentLocInfo appropriate for the
- /// given TemplateArgument kind.
- TemplateArgumentLocInfo
- GetTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,
- const RecordData &Record, unsigned &Idx);
-
- /// \brief Reads a TemplateArgumentLoc.
- TemplateArgumentLoc ReadTemplateArgumentLoc(const RecordData &Record,
- unsigned &Idx);
-
- /// \brief Reads a declarator info from the given record.
- TypeSourceInfo *GetTypeSourceInfo(const RecordData &Record,
- unsigned &Idx);
-
- /// \brief Resolve and return the translation unit declaration.
- TranslationUnitDecl *GetTranslationUnitDecl();
-
- /// \brief Resolve a type ID into a type, potentially building a new
- /// type.
- QualType GetType(pch::TypeID ID);
-
- /// \brief Resolve a declaration ID into a declaration, potentially
- /// building a new declaration.
- Decl *GetDecl(pch::DeclID ID);
- virtual Decl *GetExternalDecl(uint32_t ID);
-
- /// \brief Resolve the offset of a statement into a statement.
- ///
- /// This operation will read a new statement from the external
- /// source each time it is called, and is meant to be used via a
- /// LazyOffsetPtr (which is used by Decls for the body of functions, etc).
- virtual Stmt *GetExternalDeclStmt(uint64_t Offset);
-
- /// ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the
- /// specified cursor. Read the abbreviations that are at the top of the block
- /// and then leave the cursor pointing into the block.
- bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID);
-
- /// \brief Finds all the visible declarations with a given name.
- /// The current implementation of this method just loads the entire
- /// lookup table as unmaterialized references.
- virtual DeclContext::lookup_result
- FindExternalVisibleDeclsByName(const DeclContext *DC,
- DeclarationName Name);
-
- /// \brief Read all of the declarations lexically stored in a
- /// declaration context.
- ///
- /// \param DC The declaration context whose declarations will be
- /// read.
- ///
- /// \param Decls Vector that will contain the declarations loaded
- /// from the external source. The caller is responsible for merging
- /// these declarations with any declarations already stored in the
- /// declaration context.
- ///
- /// \returns true if there was an error while reading the
- /// declarations for this declaration context.
- virtual bool FindExternalLexicalDecls(const DeclContext *DC,
- llvm::SmallVectorImpl<Decl*> &Decls);
-
- /// \brief Function that will be invoked when we begin parsing a new
- /// translation unit involving this external AST source.
- ///
- /// This function will provide all of the external definitions to
- /// the ASTConsumer.
- virtual void StartTranslationUnit(ASTConsumer *Consumer);
-
- /// \brief Print some statistics about PCH usage.
- virtual void PrintStats();
-
- /// \brief Initialize the semantic source with the Sema instance
- /// being used to perform semantic analysis on the abstract syntax
- /// tree.
- virtual void InitializeSema(Sema &S);
-
- /// \brief Inform the semantic consumer that Sema is no longer available.
- virtual void ForgetSema() { SemaObj = 0; }
-
- /// \brief Retrieve the IdentifierInfo for the named identifier.
- ///
- /// This routine builds a new IdentifierInfo for the given identifier. If any
- /// declarations with this name are visible from translation unit scope, their
- /// declarations will be deserialized and introduced into the declaration
- /// chain of the identifier.
- virtual IdentifierInfo *get(const char *NameStart, const char *NameEnd);
- IdentifierInfo *get(llvm::StringRef Name) {
- return get(Name.begin(), Name.end());
- }
-
- /// \brief Load the contents of the global method pool for a given
- /// selector.
- ///
- /// \returns a pair of Objective-C methods lists containing the
- /// instance and factory methods, respectively, with this selector.
- virtual std::pair<ObjCMethodList, ObjCMethodList>
- ReadMethodPool(Selector Sel);
-
- void SetIdentifierInfo(unsigned ID, IdentifierInfo *II);
- void SetGloballyVisibleDecls(IdentifierInfo *II,
- const llvm::SmallVectorImpl<uint32_t> &DeclIDs,
- bool Nonrecursive = false);
-
- /// \brief Report a diagnostic.
- DiagnosticBuilder Diag(unsigned DiagID);
-
- /// \brief Report a diagnostic.
- DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID);
-
- IdentifierInfo *DecodeIdentifierInfo(unsigned Idx);
-
- IdentifierInfo *GetIdentifierInfo(const RecordData &Record, unsigned &Idx) {
- return DecodeIdentifierInfo(Record[Idx++]);
- }
-
- virtual IdentifierInfo *GetIdentifier(unsigned ID) {
- return DecodeIdentifierInfo(ID);
- }
-
- /// \brief Read the source location entry with index ID.
- virtual void ReadSLocEntry(unsigned ID);
-
- Selector DecodeSelector(unsigned Idx);
-
- virtual Selector GetExternalSelector(uint32_t ID);
- uint32_t GetNumExternalSelectors();
-
- Selector GetSelector(const RecordData &Record, unsigned &Idx) {
- return DecodeSelector(Record[Idx++]);
- }
-
- /// \brief Read a declaration name.
- DeclarationName ReadDeclarationName(const RecordData &Record, unsigned &Idx);
-
- NestedNameSpecifier *ReadNestedNameSpecifier(const RecordData &Record,
- unsigned &Idx);
-
- /// \brief Read a template name.
- TemplateName ReadTemplateName(const RecordData &Record, unsigned &Idx);
-
- /// \brief Read a template argument.
- TemplateArgument ReadTemplateArgument(const RecordData &Record,unsigned &Idx);
-
- /// \brief Read a template parameter list.
- TemplateParameterList *ReadTemplateParameterList(const RecordData &Record,
- unsigned &Idx);
-
- /// \brief Read a template argument array.
- void
- ReadTemplateArgumentList(llvm::SmallVector<TemplateArgument, 8> &TemplArgs,
- const RecordData &Record, unsigned &Idx);
-
- /// \brief Read a UnresolvedSet structure.
- void ReadUnresolvedSet(UnresolvedSetImpl &Set,
- const RecordData &Record, unsigned &Idx);
-
- /// \brief Read a C++ base specifier.
- CXXBaseSpecifier ReadCXXBaseSpecifier(const RecordData &Record,unsigned &Idx);
-
- /// \brief Read a source location.
- SourceLocation ReadSourceLocation(const RecordData &Record, unsigned& Idx) {
- return SourceLocation::getFromRawEncoding(Record[Idx++]);
- }
-
- /// \brief Read a source range.
- SourceRange ReadSourceRange(const RecordData &Record, unsigned& Idx);
-
- /// \brief Read an integral value
- llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx);
-
- /// \brief Read a signed integral value
- llvm::APSInt ReadAPSInt(const RecordData &Record, unsigned &Idx);
-
- /// \brief Read a floating-point value
- llvm::APFloat ReadAPFloat(const RecordData &Record, unsigned &Idx);
-
- // \brief Read a string
- std::string ReadString(const RecordData &Record, unsigned &Idx);
-
- CXXTemporary *ReadCXXTemporary(const RecordData &Record, unsigned &Idx);
-
- /// \brief Reads attributes from the current stream position.
- Attr *ReadAttributes();
-
- /// \brief Reads a statement.
- Stmt *ReadStmt();
-
- /// \brief Reads an expression.
- Expr *ReadExpr();
-
- /// \brief Reads a sub-statement operand during statement reading.
- Stmt *ReadSubStmt() {
- assert(ReadingKind == Read_Stmt &&
- "Should be called only during statement reading!");
- // Subexpressions are stored from last to first, so the next Stmt we need
- // is at the back of the stack.
- assert(!StmtStack.empty() && "Read too many sub statements!");
- return StmtStack.pop_back_val();
- }
-
- /// \brief Reads a sub-expression operand during statement reading.
- Expr *ReadSubExpr();
-
- /// \brief Reads the macro record located at the given offset.
- void ReadMacroRecord(uint64_t Offset);
-
- /// \brief Read the set of macros defined by this external macro source.
- virtual void ReadDefinedMacros();
-
- /// \brief Retrieve the macro definition with the given ID.
- MacroDefinition *getMacroDefinition(pch::IdentID ID);
-
- /// \brief Retrieve the AST context that this PCH reader
- /// supplements.
- ASTContext *getContext() { return Context; }
-
- // \brief Contains declarations that were loaded before we have
- // access to a Sema object.
- llvm::SmallVector<NamedDecl *, 16> PreloadedDecls;
-
- /// \brief Retrieve the semantic analysis object used to analyze the
- /// translation unit in which the precompiled header is being
- /// imported.
- Sema *getSema() { return SemaObj; }
-
- /// \brief Retrieve the stream that this PCH reader is reading from.
- llvm::BitstreamCursor &getStream() { return Stream; }
- llvm::BitstreamCursor &getDeclsCursor() { return DeclsCursor; }
-
- /// \brief Retrieve the identifier table associated with the
- /// preprocessor.
- IdentifierTable &getIdentifierTable();
-
- /// \brief Record that the given ID maps to the given switch-case
- /// statement.
- void RecordSwitchCaseID(SwitchCase *SC, unsigned ID);
-
- /// \brief Retrieve the switch-case statement with the given ID.
- SwitchCase *getSwitchCaseWithID(unsigned ID);
-
- /// \brief Record that the given label statement has been
- /// deserialized and has the given ID.
- void RecordLabelStmt(LabelStmt *S, unsigned ID);
-
- /// \brief Set the label of the given statement to the label
- /// identified by ID.
- ///
- /// Depending on the order in which the label and other statements
- /// referencing that label occur, this operation may complete
- /// immediately (updating the statement) or it may queue the
- /// statement to be back-patched later.
- void SetLabelOf(GotoStmt *S, unsigned ID);
-
- /// \brief Set the label of the given expression to the label
- /// identified by ID.
- ///
- /// Depending on the order in which the label and other statements
- /// referencing that label occur, this operation may complete
- /// immediately (updating the statement) or it may queue the
- /// statement to be back-patched later.
- void SetLabelOf(AddrLabelExpr *S, unsigned ID);
-};
-
-/// \brief Helper class that saves the current stream position and
-/// then restores it when destroyed.
-struct SavedStreamPosition {
- explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor)
- : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) { }
-
- ~SavedStreamPosition() {
- Cursor.JumpToBit(Offset);
- }
-
-private:
- llvm::BitstreamCursor &Cursor;
- uint64_t Offset;
-};
-
-inline void PCHValidator::Error(const char *Msg) {
- Reader.Error(Msg);
-}
-
-} // end namespace clang
-
-#endif
diff --git a/include/clang/Frontend/PCHWriter.h b/include/clang/Frontend/PCHWriter.h
deleted file mode 100644
index 70ad1d7..0000000
--- a/include/clang/Frontend/PCHWriter.h
+++ /dev/null
@@ -1,408 +0,0 @@
-//===--- PCHWriter.h - Precompiled Headers Writer ---------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines the PCHWriter class, which writes a precompiled
-// header containing a serialized representation of a translation
-// unit.
-//
-//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_FRONTEND_PCH_WRITER_H
-#define LLVM_CLANG_FRONTEND_PCH_WRITER_H
-
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclarationName.h"
-#include "clang/AST/TemplateBase.h"
-#include "clang/Frontend/PCHBitCodes.h"
-#include "clang/Frontend/PCHDeserializationListener.h"
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/SmallVector.h"
-#include <map>
-#include <queue>
-
-namespace llvm {
- class APFloat;
- class APInt;
- class BitstreamWriter;
-}
-
-namespace clang {
-
-class ASTContext;
-class NestedNameSpecifier;
-class CXXBaseSpecifier;
-class CXXBaseOrMemberInitializer;
-class LabelStmt;
-class MacroDefinition;
-class MemorizeStatCalls;
-class PCHReader;
-class Preprocessor;
-class Sema;
-class SourceManager;
-class SwitchCase;
-class TargetInfo;
-
-/// A structure for putting "fast"-unqualified QualTypes into a
-/// DenseMap. This uses the standard pointer hash function.
-struct UnsafeQualTypeDenseMapInfo {
- static inline bool isEqual(QualType A, QualType B) { return A == B; }
- static inline QualType getEmptyKey() {
- return QualType::getFromOpaquePtr((void*) 1);
- }
- static inline QualType getTombstoneKey() {
- return QualType::getFromOpaquePtr((void*) 2);
- }
- static inline unsigned getHashValue(QualType T) {
- assert(!T.getLocalFastQualifiers() &&
- "hash invalid for types with fast quals");
- uintptr_t v = reinterpret_cast<uintptr_t>(T.getAsOpaquePtr());
- return (unsigned(v) >> 4) ^ (unsigned(v) >> 9);
- }
-};
-
-/// \brief Writes a precompiled header containing the contents of a
-/// translation unit.
-///
-/// The PCHWriter class produces a bitstream containing the serialized
-/// representation of a given abstract syntax tree and its supporting
-/// data structures. This bitstream can be de-serialized via an
-/// instance of the PCHReader class.
-class PCHWriter : public PCHDeserializationListener {
-public:
- typedef llvm::SmallVector<uint64_t, 64> RecordData;
-
-private:
- /// \brief The bitstream writer used to emit this precompiled header.
- llvm::BitstreamWriter &Stream;
-
- /// \brief The reader of existing PCH files, if we're chaining.
- PCHReader *Chain;
-
- /// \brief Stores a declaration or a type to be written to the PCH file.
- class DeclOrType {
- public:
- DeclOrType(Decl *D) : Stored(D), IsType(false) { }
- DeclOrType(QualType T) : Stored(T.getAsOpaquePtr()), IsType(true) { }
-
- bool isType() const { return IsType; }
- bool isDecl() const { return !IsType; }
-
- QualType getType() const {
- assert(isType() && "Not a type!");
- return QualType::getFromOpaquePtr(Stored);
- }
-
- Decl *getDecl() const {
- assert(isDecl() && "Not a decl!");
- return static_cast<Decl *>(Stored);
- }
-
- private:
- void *Stored;
- bool IsType;
- };
-
- /// \brief The declarations and types to emit.
- std::queue<DeclOrType> DeclTypesToEmit;
-
- /// \brief Map that provides the ID numbers of each declaration within
- /// the output stream.
- ///
- /// The ID numbers of declarations are consecutive (in order of
- /// discovery) and start at 2. 1 is reserved for the translation
- /// unit, while 0 is reserved for NULL.
- llvm::DenseMap<const Decl *, pch::DeclID> DeclIDs;
-
- /// \brief Offset of each declaration in the bitstream, indexed by
- /// the declaration's ID.
- std::vector<uint32_t> DeclOffsets;
-
- /// \brief Map that provides the ID numbers of each type within the
- /// output stream.
- ///
- /// The ID numbers of types are consecutive (in order of discovery)
- /// and start at 1. 0 is reserved for NULL. When types are actually
- /// stored in the stream, the ID number is shifted by 2 bits to
- /// allow for the const/volatile qualifiers.
- ///
- /// Keys in the map never have const/volatile qualifiers.
- llvm::DenseMap<QualType, pch::TypeID, UnsafeQualTypeDenseMapInfo> TypeIDs;
-
- /// \brief Offset of each type in the bitstream, indexed by
- /// the type's ID.
- std::vector<uint32_t> TypeOffsets;
-
- /// \brief The type ID that will be assigned to the next new type.
- pch::TypeID NextTypeID;
-
- /// \brief Map that provides the ID numbers of each identifier in
- /// the output stream.
- ///
- /// The ID numbers for identifiers are consecutive (in order of
- /// discovery), starting at 1. An ID of zero refers to a NULL
- /// IdentifierInfo.
- llvm::DenseMap<const IdentifierInfo *, pch::IdentID> IdentifierIDs;
-
- /// \brief Offsets of each of the identifier IDs into the identifier
- /// table.
- std::vector<uint32_t> IdentifierOffsets;
-
- /// \brief Map that provides the ID numbers of each Selector.
- llvm::DenseMap<Selector, pch::SelectorID> SelectorIDs;
-
- /// \brief Offset of each selector within the method pool/selector
- /// table, indexed by the Selector ID (-1).
- std::vector<uint32_t> SelectorOffsets;
-
- /// \brief A vector of all Selectors (ordered by ID).
- std::vector<Selector> SelVector;
-
- /// \brief Offsets of each of the macro identifiers into the
- /// bitstream.
- ///
- /// For each identifier that is associated with a macro, this map
- /// provides the offset into the bitstream where that macro is
- /// defined.
- llvm::DenseMap<const IdentifierInfo *, uint64_t> MacroOffsets;
-
- /// \brief Mapping from macro definitions (as they occur in the preprocessing
- /// record) to the index into the macro definitions table.
- llvm::DenseMap<const MacroDefinition *, pch::IdentID> MacroDefinitions;
-
- /// \brief Mapping from the macro definition indices in \c MacroDefinitions
- /// to the corresponding offsets within the preprocessor block.
- std::vector<uint32_t> MacroDefinitionOffsets;
-
- /// \brief Declarations encountered that might be external
- /// definitions.
- ///
- /// We keep track of external definitions (as well as tentative
- /// definitions) as we are emitting declarations to the PCH
- /// file. The PCH file contains a separate record for these external
- /// definitions, which are provided to the AST consumer by the PCH
- /// reader. This is behavior is required to properly cope with,
- /// e.g., tentative variable definitions that occur within
- /// headers. The declarations themselves are stored as declaration
- /// IDs, since they will be written out to an EXTERNAL_DEFINITIONS
- /// record.
- llvm::SmallVector<uint64_t, 16> ExternalDefinitions;
-
- /// \brief Statements that we've encountered while serializing a
- /// declaration or type.
- llvm::SmallVector<Stmt *, 16> StmtsToEmit;
-
- /// \brief Statements collection to use for PCHWriter::AddStmt().
- /// It will point to StmtsToEmit unless it is overriden.
- llvm::SmallVector<Stmt *, 16> *CollectedStmts;
-
- /// \brief Mapping from SwitchCase statements to IDs.
- std::map<SwitchCase *, unsigned> SwitchCaseIDs;
-
- /// \brief Mapping from LabelStmt statements to IDs.
- std::map<LabelStmt *, unsigned> LabelIDs;
-
- /// \brief The number of statements written to the PCH file.
- unsigned NumStatements;
-
- /// \brief The number of macros written to the PCH file.
- unsigned NumMacros;
-
- /// \brief The number of lexical declcontexts written to the PCH
- /// file.
- unsigned NumLexicalDeclContexts;
-
- /// \brief The number of visible declcontexts written to the PCH
- /// file.
- unsigned NumVisibleDeclContexts;
-
- /// \brief Write the given subexpression to the bitstream.
- void WriteSubStmt(Stmt *S);
-
- void WriteBlockInfoBlock();
- void WriteMetadata(ASTContext &Context, const char *isysroot);
- void WriteLanguageOptions(const LangOptions &LangOpts);
- void WriteStatCache(MemorizeStatCalls &StatCalls);
- void WriteSourceManagerBlock(SourceManager &SourceMgr,
- const Preprocessor &PP,
- const char* isysroot);
- void WritePreprocessor(const Preprocessor &PP);
- void WriteType(QualType T);
- uint64_t WriteDeclContextLexicalBlock(ASTContext &Context, DeclContext *DC);
- uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC);
-
- void WriteMethodPool(Sema &SemaRef);
- void WriteIdentifierTable(Preprocessor &PP);
- void WriteAttributeRecord(const Attr *Attr);
-
- unsigned ParmVarDeclAbbrev;
- void WriteDeclsBlockAbbrevs();
- void WriteDecl(ASTContext &Context, Decl *D);
-
- void WritePCHCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
- const char* isysroot);
- void WritePCHChain(Sema &SemaRef, MemorizeStatCalls *StatCalls,
- const char* isysroot);
-
-public:
- /// \brief Create a new precompiled header writer that outputs to
- /// the given bitstream.
- PCHWriter(llvm::BitstreamWriter &Stream, PCHReader *Chain);
-
- /// \brief Write a precompiled header for the given semantic analysis.
- ///
- /// \param SemaRef a reference to the semantic analysis object that processed
- /// the AST to be written into the precompiled header.
- ///
- /// \param StatCalls the object that cached all of the stat() calls made while
- /// searching for source files and headers.
- ///
- /// \param isysroot if non-NULL, write a relocatable PCH file whose headers
- /// are relative to the given system root.
- ///
- /// \param PPRec Record of the preprocessing actions that occurred while
- /// preprocessing this file, e.g., macro instantiations
- void WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls,
- const char* isysroot);
-
- /// \brief Emit a source location.
- void AddSourceLocation(SourceLocation Loc, RecordData &Record);
-
- /// \brief Emit a source range.
- void AddSourceRange(SourceRange Range, RecordData &Record);
-
- /// \brief Emit an integral value.
- void AddAPInt(const llvm::APInt &Value, RecordData &Record);
-
- /// \brief Emit a signed integral value.
- void AddAPSInt(const llvm::APSInt &Value, RecordData &Record);
-
- /// \brief Emit a floating-point value.
- void AddAPFloat(const llvm::APFloat &Value, RecordData &Record);
-
- /// \brief Emit a reference to an identifier.
- void AddIdentifierRef(const IdentifierInfo *II, RecordData &Record);
-
- /// \brief Emit a Selector (which is a smart pointer reference).
- void AddSelectorRef(Selector, RecordData &Record);
-
- /// \brief Emit a CXXTemporary.
- void AddCXXTemporary(const CXXTemporary *Temp, RecordData &Record);
-
- /// \brief Get the unique number used to refer to the given
- /// identifier.
- pch::IdentID getIdentifierRef(const IdentifierInfo *II);
-
- /// \brief Retrieve the offset of the macro definition for the given
- /// identifier.
- ///
- /// The identifier must refer to a macro.
- uint64_t getMacroOffset(const IdentifierInfo *II) {
- assert(MacroOffsets.find(II) != MacroOffsets.end() &&
- "Identifier does not name a macro");
- return MacroOffsets[II];
- }
-
- /// \brief Retrieve the ID number corresponding to the given macro
- /// definition.
- pch::IdentID getMacroDefinitionID(MacroDefinition *MD);
-
- /// \brief Emit a reference to a type.
- void AddTypeRef(QualType T, RecordData &Record);
-
- /// \brief Emits a reference to a declarator info.
- void AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordData &Record);
-
- /// \brief Emits a template argument location info.
- void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,
- const TemplateArgumentLocInfo &Arg,
- RecordData &Record);
-
- /// \brief Emits a template argument location.
- void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg,
- RecordData &Record);
-
- /// \brief Emit a reference to a declaration.
- void AddDeclRef(const Decl *D, RecordData &Record);
-
- /// \brief Determine the declaration ID of an already-emitted
- /// declaration.
- pch::DeclID getDeclID(const Decl *D);
-
- /// \brief Emit a declaration name.
- void AddDeclarationName(DeclarationName Name, RecordData &Record);
-
- /// \brief Emit a nested name specifier.
- void AddNestedNameSpecifier(NestedNameSpecifier *NNS, RecordData &Record);
-
- /// \brief Emit a template name.
- void AddTemplateName(TemplateName Name, RecordData &Record);
-
- /// \brief Emit a template argument.
- void AddTemplateArgument(const TemplateArgument &Arg, RecordData &Record);
-
- /// \brief Emit a template parameter list.
- void AddTemplateParameterList(const TemplateParameterList *TemplateParams,
- RecordData &Record);
-
- /// \brief Emit a template argument list.
- void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs,
- RecordData &Record);
-
- /// \brief Emit a UnresolvedSet structure.
- void AddUnresolvedSet(const UnresolvedSetImpl &Set, RecordData &Record);
-
- /// brief Emit a C++ base specifier.
- void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base, RecordData &Record);
-
- /// \brief Add a string to the given record.
- void AddString(const std::string &Str, RecordData &Record);
-
- /// \brief Note that the identifier II occurs at the given offset
- /// within the identifier table.
- void SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset);
-
- /// \brief Note that the selector Sel occurs at the given offset
- /// within the method pool/selector table.
- void SetSelectorOffset(Selector Sel, uint32_t Offset);
-
- /// \brief Add the given statement or expression to the queue of
- /// statements to emit.
- ///
- /// This routine should be used when emitting types and declarations
- /// that have expressions as part of their formulation. Once the
- /// type or declaration has been written, call FlushStmts() to write
- /// the corresponding statements just after the type or
- /// declaration.
- void AddStmt(Stmt *S) {
- CollectedStmts->push_back(S);
- }
-
- /// \brief Flush all of the statements and expressions that have
- /// been added to the queue via AddStmt().
- void FlushStmts();
-
- /// \brief Record an ID for the given switch-case statement.
- unsigned RecordSwitchCaseID(SwitchCase *S);
-
- /// \brief Retrieve the ID for the given switch-case statement.
- unsigned getSwitchCaseID(SwitchCase *S);
-
- /// \brief Retrieve the ID for the given label statement, which may
- /// or may not have been emitted yet.
- unsigned GetLabelID(LabelStmt *S);
-
- unsigned getParmVarDeclAbbrev() const { return ParmVarDeclAbbrev; }
-
- // PCHDeserializationListener implementation
- void TypeRead(pch::TypeID ID, QualType T);
- void DeclRead(pch::DeclID ID, const Decl *D);
-};
-
-} // end namespace clang
-
-#endif
diff --git a/include/clang/Frontend/PreprocessorOptions.h b/include/clang/Frontend/PreprocessorOptions.h
index 891359b..851c1f0 100644
--- a/include/clang/Frontend/PreprocessorOptions.h
+++ b/include/clang/Frontend/PreprocessorOptions.h
@@ -43,6 +43,17 @@ public:
/// The implicit PCH included at the start of the translation unit, or empty.
std::string ImplicitPCHInclude;
+ /// \brief When true, disables most of the normal validation performed on
+ /// precompiled headers.
+ bool DisablePCHValidation;
+
+ /// \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;
@@ -62,26 +73,53 @@ public:
std::vector<std::pair<std::string, const llvm::MemoryBuffer *> >
RemappedFileBuffers;
- typedef std::vector<std::pair<std::string, std::string> >::const_iterator
+ /// \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;
+
+ typedef std::vector<std::pair<std::string, std::string> >::iterator
remapped_file_iterator;
- remapped_file_iterator remapped_file_begin() const {
+ typedef std::vector<std::pair<std::string, std::string> >::const_iterator
+ const_remapped_file_iterator;
+ remapped_file_iterator remapped_file_begin() {
return RemappedFiles.begin();
}
- remapped_file_iterator remapped_file_end() const {
+ 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 *> >::
- const_iterator remapped_file_buffer_iterator;
- remapped_file_buffer_iterator remapped_file_buffer_begin() const {
+ 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();
}
- remapped_file_buffer_iterator remapped_file_buffer_end() const {
+ 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) {}
+ PreprocessorOptions() : UsePredefines(true), DetailedRecord(false),
+ DisablePCHValidation(false),
+ PrecompiledPreambleBytes(0, true),
+ RetainRemappedFileBuffers(false) { }
void addMacroDef(llvm::StringRef Name) {
Macros.push_back(std::make_pair(Name, false));
@@ -92,9 +130,24 @@ public:
void addRemappedFile(llvm::StringRef From, llvm::StringRef To) {
RemappedFiles.push_back(std::make_pair(From, To));
}
+
+ remapped_file_iterator eraseRemappedFile(remapped_file_iterator Remapped) {
+ return RemappedFiles.erase(Remapped);
+ }
+
void addRemappedFile(llvm::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();
+ }
};
} // end namespace clang
diff --git a/include/clang/Frontend/PreprocessorOutputOptions.h b/include/clang/Frontend/PreprocessorOutputOptions.h
index a712a3d..82517c5 100644
--- a/include/clang/Frontend/PreprocessorOutputOptions.h
+++ b/include/clang/Frontend/PreprocessorOutputOptions.h
@@ -16,19 +16,21 @@ namespace clang {
/// output (e.g., -E).
class PreprocessorOutputOptions {
public:
- unsigned ShowCPP : 1; ///< Print normal preprocessed output.
- unsigned ShowMacros : 1; ///< Print macro definitions.
- unsigned ShowLineMarkers : 1; ///< Show #line markers.
- unsigned ShowComments : 1; ///< Show comments.
- unsigned ShowMacroComments : 1; ///< Show comments, even in macros.
+ unsigned ShowCPP : 1; ///< Print normal preprocessed output.
+ unsigned ShowComments : 1; ///< Show comments.
+ unsigned ShowHeaderIncludes : 1; ///< Show header inclusions (-H).
+ unsigned ShowLineMarkers : 1; ///< Show #line markers.
+ unsigned ShowMacroComments : 1; ///< Show comments, even in macros.
+ unsigned ShowMacros : 1; ///< Print macro definitions.
public:
PreprocessorOutputOptions() {
ShowCPP = 1;
- ShowMacros = 0;
- ShowLineMarkers = 1;
ShowComments = 0;
+ ShowHeaderIncludes = 0;
+ ShowLineMarkers = 1;
ShowMacroComments = 0;
+ ShowMacros = 0;
}
};
diff --git a/include/clang/Frontend/StmtXML.def b/include/clang/Frontend/StmtXML.def
index f63761a..c03a5a8 100644
--- a/include/clang/Frontend/StmtXML.def
+++ b/include/clang/Frontend/StmtXML.def
@@ -241,20 +241,19 @@ NODE_XML(UnaryOperator, "UnaryOperator") // op(expr) or (expr)op
ATTRIBUTE_FILE_LOCATION_XML
TYPE_ATTRIBUTE_XML(getType())
ATTRIBUTE_ENUM_XML(getOpcode(), "kind")
- ENUM_XML(UnaryOperator::PostInc, "postinc")
- ENUM_XML(UnaryOperator::PostDec, "postdec")
- ENUM_XML(UnaryOperator::PreInc, "preinc")
- ENUM_XML(UnaryOperator::PreDec, "predec")
- ENUM_XML(UnaryOperator::AddrOf, "addrof")
- ENUM_XML(UnaryOperator::Deref, "deref")
- ENUM_XML(UnaryOperator::Plus, "plus")
- ENUM_XML(UnaryOperator::Minus, "minus")
- ENUM_XML(UnaryOperator::Not, "not") // bitwise not
- ENUM_XML(UnaryOperator::LNot, "lnot") // boolean not
- ENUM_XML(UnaryOperator::Real, "__real")
- ENUM_XML(UnaryOperator::Imag, "__imag")
- ENUM_XML(UnaryOperator::Extension, "__extension__")
- ENUM_XML(UnaryOperator::OffsetOf, "__builtin_offsetof")
+ ENUM_XML(UO_PostInc, "postinc")
+ ENUM_XML(UO_PostDec, "postdec")
+ ENUM_XML(UO_PreInc, "preinc")
+ ENUM_XML(UO_PreDec, "predec")
+ ENUM_XML(UO_AddrOf, "addrof")
+ ENUM_XML(UO_Deref, "deref")
+ ENUM_XML(UO_Plus, "plus")
+ ENUM_XML(UO_Minus, "minus")
+ ENUM_XML(UO_Not, "not") // bitwise not
+ ENUM_XML(UO_LNot, "lnot") // boolean not
+ ENUM_XML(UO_Real, "__real")
+ ENUM_XML(UO_Imag, "__imag")
+ ENUM_XML(UO_Extension, "__extension__")
END_ENUM_XML
SUB_NODE_XML(Expr) // expr
END_NODE_XML
@@ -263,38 +262,38 @@ NODE_XML(BinaryOperator, "BinaryOperator") // (expr1) op (expr2)
ATTRIBUTE_FILE_LOCATION_XML
TYPE_ATTRIBUTE_XML(getType())
ATTRIBUTE_ENUM_XML(getOpcode(), "kind")
- ENUM_XML(BinaryOperator::PtrMemD , "ptrmemd")
- ENUM_XML(BinaryOperator::PtrMemI , "ptrmemi")
- ENUM_XML(BinaryOperator::Mul , "mul")
- ENUM_XML(BinaryOperator::Div , "div")
- ENUM_XML(BinaryOperator::Rem , "rem")
- ENUM_XML(BinaryOperator::Add , "add")
- ENUM_XML(BinaryOperator::Sub , "sub")
- ENUM_XML(BinaryOperator::Shl , "shl")
- ENUM_XML(BinaryOperator::Shr , "shr")
- ENUM_XML(BinaryOperator::LT , "lt")
- ENUM_XML(BinaryOperator::GT , "gt")
- ENUM_XML(BinaryOperator::LE , "le")
- ENUM_XML(BinaryOperator::GE , "ge")
- ENUM_XML(BinaryOperator::EQ , "eq")
- ENUM_XML(BinaryOperator::NE , "ne")
- ENUM_XML(BinaryOperator::And , "and") // bitwise and
- ENUM_XML(BinaryOperator::Xor , "xor")
- ENUM_XML(BinaryOperator::Or , "or") // bitwise or
- ENUM_XML(BinaryOperator::LAnd , "land") // boolean and
- ENUM_XML(BinaryOperator::LOr , "lor") // boolean or
- ENUM_XML(BinaryOperator::Assign , "assign")
- ENUM_XML(BinaryOperator::MulAssign, "mulassign")
- ENUM_XML(BinaryOperator::DivAssign, "divassign")
- ENUM_XML(BinaryOperator::RemAssign, "remassign")
- ENUM_XML(BinaryOperator::AddAssign, "addassign")
- ENUM_XML(BinaryOperator::SubAssign, "subassign")
- ENUM_XML(BinaryOperator::ShlAssign, "shlassign")
- ENUM_XML(BinaryOperator::ShrAssign, "shrassign")
- ENUM_XML(BinaryOperator::AndAssign, "andassign")
- ENUM_XML(BinaryOperator::XorAssign, "xorassign")
- ENUM_XML(BinaryOperator::OrAssign , "orassign")
- ENUM_XML(BinaryOperator::Comma , "comma")
+ ENUM_XML(BO_PtrMemD , "ptrmemd")
+ ENUM_XML(BO_PtrMemI , "ptrmemi")
+ ENUM_XML(BO_Mul , "mul")
+ ENUM_XML(BO_Div , "div")
+ ENUM_XML(BO_Rem , "rem")
+ ENUM_XML(BO_Add , "add")
+ ENUM_XML(BO_Sub , "sub")
+ ENUM_XML(BO_Shl , "shl")
+ ENUM_XML(BO_Shr , "shr")
+ ENUM_XML(BO_LT , "lt")
+ ENUM_XML(BO_GT , "gt")
+ ENUM_XML(BO_LE , "le")
+ ENUM_XML(BO_GE , "ge")
+ ENUM_XML(BO_EQ , "eq")
+ ENUM_XML(BO_NE , "ne")
+ ENUM_XML(BO_And , "and") // bitwise and
+ ENUM_XML(BO_Xor , "xor")
+ ENUM_XML(BO_Or , "or") // bitwise or
+ ENUM_XML(BO_LAnd , "land") // boolean and
+ ENUM_XML(BO_LOr , "lor") // boolean or
+ ENUM_XML(BO_Assign , "assign")
+ ENUM_XML(BO_MulAssign, "mulassign")
+ ENUM_XML(BO_DivAssign, "divassign")
+ ENUM_XML(BO_RemAssign, "remassign")
+ ENUM_XML(BO_AddAssign, "addassign")
+ ENUM_XML(BO_SubAssign, "subassign")
+ ENUM_XML(BO_ShlAssign, "shlassign")
+ ENUM_XML(BO_ShrAssign, "shrassign")
+ ENUM_XML(BO_AndAssign, "andassign")
+ ENUM_XML(BO_XorAssign, "xorassign")
+ ENUM_XML(BO_OrAssign , "orassign")
+ ENUM_XML(BO_Comma , "comma")
END_ENUM_XML
SUB_NODE_XML(Expr) // expr1
SUB_NODE_XML(Expr) // expr2
@@ -445,6 +444,14 @@ NODE_XML(CXXOperatorCallExpr, "CXXOperatorCallExpr") // fnexpr(arg1, arg2, ..
SUB_NODE_SEQUENCE_XML(Expr) // arg1..argN
END_NODE_XML
+NODE_XML(CXXConstructExpr, "CXXConstructExpr") // ctor(arg1, arg2, ...)
+ ATTRIBUTE_FILE_LOCATION_XML
+ TYPE_ATTRIBUTE_XML(getType())
+ ATTRIBUTE_XML(getNumArgs(), "num_args") // unsigned
+ SUB_NODE_XML(Expr) // fnexpr
+ SUB_NODE_SEQUENCE_XML(Expr) // arg1..argN
+END_NODE_XML
+
NODE_XML(CXXNamedCastExpr, "CXXNamedCastExpr") // xxx_cast<type>(expr)
ATTRIBUTE_FILE_LOCATION_XML
TYPE_ATTRIBUTE_XML(getType())
diff --git a/include/clang/Frontend/TypeXML.def b/include/clang/Frontend/TypeXML.def
index e8cb4a6..1536c92 100644
--- a/include/clang/Frontend/TypeXML.def
+++ b/include/clang/Frontend/TypeXML.def
@@ -278,18 +278,10 @@ NODE_XML(UnresolvedUsingType, "UnresolvedUsing")
ID_ATTRIBUTE_XML
END_NODE_XML
-NODE_XML(DependentTypeOfExprType, "DependentTypeOfExpr")
- ID_ATTRIBUTE_XML
-END_NODE_XML
-
NODE_XML(DecltypeType, "Decltype")
ID_ATTRIBUTE_XML
END_NODE_XML
-NODE_XML(DependentDecltypeType, "DependentDecltype")
- ID_ATTRIBUTE_XML
-END_NODE_XML
-
//===----------------------------------------------------------------------===//
#undef NODE_XML
#undef ID_ATTRIBUTE_XML
diff --git a/include/clang/Frontend/Utils.h b/include/clang/Frontend/Utils.h
index f37cc01..fe722db 100644
--- a/include/clang/Frontend/Utils.h
+++ b/include/clang/Frontend/Utils.h
@@ -23,6 +23,7 @@ class Triple;
namespace clang {
class ASTConsumer;
+class CompilerInstance;
class Decl;
class DependencyOutputOptions;
class Diagnostic;
@@ -31,7 +32,6 @@ class HeaderSearch;
class HeaderSearchOptions;
class IdentifierTable;
class LangOptions;
-class MinimalAction;
class Preprocessor;
class PreprocessorOptions;
class PreprocessorOutputOptions;
@@ -65,11 +65,6 @@ void ProcessWarningOptions(Diagnostic &Diags, const DiagnosticOptions &Opts);
void DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream* OS,
const PreprocessorOutputOptions &Opts);
-/// CreatePrintParserActionsAction - Return the actions implementation that
-/// implements the -parse-print-callbacks option.
-MinimalAction *CreatePrintParserActionsAction(Preprocessor &PP,
- llvm::raw_ostream* OS);
-
/// CheckDiagnostics - Gather the expected diagnostics and check them.
bool CheckDiagnostics(Preprocessor &PP);
OpenPOWER on IntegriCloud