summaryrefslogtreecommitdiffstats
path: root/include/clang/Frontend
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2010-07-15 17:07:12 +0000
committerrdivacky <rdivacky@FreeBSD.org>2010-07-15 17:07:12 +0000
commitf1752835b9d5f0da31f34b18c9f1eb8dcb799ba8 (patch)
tree5e946d69177464379cb1a38ac18206180d763639 /include/clang/Frontend
parent1928da94b55683957759d5c5ff4593a118773394 (diff)
downloadFreeBSD-src-f1752835b9d5f0da31f34b18c9f1eb8dcb799ba8.zip
FreeBSD-src-f1752835b9d5f0da31f34b18c9f1eb8dcb799ba8.tar.gz
Update clang to r108428.
Diffstat (limited to 'include/clang/Frontend')
-rw-r--r--include/clang/Frontend/ASTConsumers.h2
-rw-r--r--include/clang/Frontend/PCHDeserializationListener.h36
-rw-r--r--include/clang/Frontend/PCHReader.h54
-rw-r--r--include/clang/Frontend/PCHWriter.h18
4 files changed, 85 insertions, 25 deletions
diff --git a/include/clang/Frontend/ASTConsumers.h b/include/clang/Frontend/ASTConsumers.h
index 5718979..2d1df44 100644
--- a/include/clang/Frontend/ASTConsumers.h
+++ b/include/clang/Frontend/ASTConsumers.h
@@ -63,7 +63,7 @@ ASTConsumer *CreateDeclContextPrinter();
// times.
ASTConsumer *CreatePCHGenerator(const Preprocessor &PP,
llvm::raw_ostream *OS,
- const PCHReader *Chain,
+ PCHReader *Chain,
const char *isysroot = 0);
// Inheritance viewer: for C++ code, creates a graph of the inheritance
diff --git a/include/clang/Frontend/PCHDeserializationListener.h b/include/clang/Frontend/PCHDeserializationListener.h
new file mode 100644
index 0000000..c9b90e2
--- /dev/null
+++ b/include/clang/Frontend/PCHDeserializationListener.h
@@ -0,0 +1,36 @@
+//===- 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
index 38402732..47e871f 100644
--- a/include/clang/Frontend/PCHReader.h
+++ b/include/clang/Frontend/PCHReader.h
@@ -59,12 +59,22 @@ 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
@@ -91,10 +101,7 @@ public:
/// \brief Receives the contents of the predefines buffer.
///
- /// \param PCHPredef The start of the predefines buffer in the PCH
- /// file.
- ///
- /// \param PCHBufferID The FileID for the PCH 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.
@@ -103,8 +110,7 @@ public:
/// here.
///
/// \returns true to indicate the predefines are invalid or false otherwise.
- virtual bool ReadPredefinesBuffer(llvm::StringRef PCHPredef,
- FileID PCHBufferID,
+ virtual bool ReadPredefinesBuffer(const PCHPredefinesBlocks &Buffers,
llvm::StringRef OriginalFileName,
std::string &SuggestedPredefines) {
return false;
@@ -131,8 +137,7 @@ public:
virtual bool ReadLanguageOptions(const LangOptions &LangOpts);
virtual bool ReadTargetTriple(llvm::StringRef Triple);
- virtual bool ReadPredefinesBuffer(llvm::StringRef PCHPredef,
- FileID PCHBufferID,
+ virtual bool ReadPredefinesBuffer(const PCHPredefinesBlocks &Buffers,
llvm::StringRef OriginalFileName,
std::string &SuggestedPredefines);
virtual void ReadHeaderFileInfo(const HeaderFileInfo &HFI, unsigned ID);
@@ -165,9 +170,12 @@ public:
enum PCHReadResult { Success, Failure, IgnorePCH };
friend class PCHValidator;
private:
- /// \ brief The receiver of some callbacks invoked by PCHReader.
+ /// \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;
@@ -483,15 +491,9 @@ private:
~ReadingKindTracker() { Reader.ReadingKind = PrevKind; }
};
- /// \brief The file ID for the predefines buffer in the PCH file.
- FileID PCHPredefinesBufferID;
-
- /// \brief Pointer to the beginning of the predefines buffer in the
- /// PCH file.
- const char *PCHPredefines;
-
- /// \brief Length of the predefines buffer in the PCH file.
- unsigned PCHPredefinesLen;
+ /// \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.
@@ -509,7 +511,7 @@ private:
void MaybeAddSystemRootToFilename(std::string &Filename);
PCHReadResult ReadPCHBlock();
- bool CheckPredefinesBuffer(llvm::StringRef PCHPredef, FileID PCHBufferID);
+ bool CheckPredefinesBuffers();
bool ParseLineTable(llvm::SmallVectorImpl<uint64_t> &Record);
PCHReadResult ReadSourceManagerBlock();
PCHReadResult ReadSLocEntryRecord(unsigned ID);
@@ -576,6 +578,10 @@ public:
Listener.reset(listener);
}
+ void setDeserializationListener(PCHDeserializationListener *Listener) {
+ DeserializationListener = Listener;
+ }
+
/// \brief Set the Preprocessor to use.
void setPreprocessor(Preprocessor &pp);
@@ -602,6 +608,16 @@ public:
/// \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
diff --git a/include/clang/Frontend/PCHWriter.h b/include/clang/Frontend/PCHWriter.h
index 860ef56..70ad1d7 100644
--- a/include/clang/Frontend/PCHWriter.h
+++ b/include/clang/Frontend/PCHWriter.h
@@ -19,6 +19,7 @@
#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>
@@ -71,7 +72,7 @@ struct UnsafeQualTypeDenseMapInfo {
/// 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 {
+class PCHWriter : public PCHDeserializationListener {
public:
typedef llvm::SmallVector<uint64_t, 64> RecordData;
@@ -79,6 +80,9 @@ 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:
@@ -220,7 +224,7 @@ private:
void WriteSubStmt(Stmt *S);
void WriteBlockInfoBlock();
- void WriteMetadata(ASTContext &Context, const PCHReader *Chain, const char *isysroot);
+ void WriteMetadata(ASTContext &Context, const char *isysroot);
void WriteLanguageOptions(const LangOptions &LangOpts);
void WriteStatCache(MemorizeStatCalls &StatCalls);
void WriteSourceManagerBlock(SourceManager &SourceMgr,
@@ -242,12 +246,12 @@ private:
void WritePCHCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
const char* isysroot);
void WritePCHChain(Sema &SemaRef, MemorizeStatCalls *StatCalls,
- const PCHReader *Chain, const char* isysroot);
+ const char* isysroot);
public:
/// \brief Create a new precompiled header writer that outputs to
/// the given bitstream.
- PCHWriter(llvm::BitstreamWriter &Stream);
+ PCHWriter(llvm::BitstreamWriter &Stream, PCHReader *Chain);
/// \brief Write a precompiled header for the given semantic analysis.
///
@@ -263,7 +267,7 @@ public:
/// \param PPRec Record of the preprocessing actions that occurred while
/// preprocessing this file, e.g., macro instantiations
void WritePCH(Sema &SemaRef, MemorizeStatCalls *StatCalls,
- const PCHReader *Chain, const char* isysroot);
+ const char* isysroot);
/// \brief Emit a source location.
void AddSourceLocation(SourceLocation Loc, RecordData &Record);
@@ -393,6 +397,10 @@ public:
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
OpenPOWER on IntegriCloud