aboutsummaryrefslogtreecommitdiff
path: root/include/clang
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2010-07-15 17:07:12 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2010-07-15 17:07:12 +0000
commit4e58654b47e89efbb1a8ca032c08fd354c3b0b61 (patch)
tree5e946d69177464379cb1a38ac18206180d763639 /include/clang
parent4ba675006b5a8edfc48b6a9bd3dcf54a70cc08f2 (diff)
downloadsrc-4e58654b47e89efbb1a8ca032c08fd354c3b0b61.tar.gz
src-4e58654b47e89efbb1a8ca032c08fd354c3b0b61.zip
Update clang to r108428.
Notes
Notes: svn path=/vendor/clang/dist/; revision=210128
Diffstat (limited to 'include/clang')
-rw-r--r--include/clang/AST/DeclBase.h14
-rw-r--r--include/clang/AST/DeclObjC.h2
-rw-r--r--include/clang/AST/Expr.h5
-rw-r--r--include/clang/AST/Type.h29
-rw-r--r--include/clang/Basic/Builtins.def1
-rw-r--r--include/clang/Basic/DiagnosticGroups.td2
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td7
-rw-r--r--include/clang/Basic/FileManager.h8
-rw-r--r--include/clang/Basic/TargetInfo.h14
-rw-r--r--include/clang/Driver/ArgList.h2
-rw-r--r--include/clang/Driver/Driver.h8
-rw-r--r--include/clang/Driver/Options.td6
-rw-r--r--include/clang/Driver/ToolChain.h5
-rw-r--r--include/clang/Driver/Types.def4
-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
-rw-r--r--include/clang/Rewrite/Rewriter.h16
19 files changed, 172 insertions, 61 deletions
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index 2d2407ffb18d..be30b8ed296b 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -92,7 +92,7 @@ public:
/// These are meant as bitmasks, so that searches in
/// C++ can look into the "tag" namespace during ordinary lookup.
///
- /// Decl currently provides 16 bits of IDNS bits.
+ /// Decl currently provides 15 bits of IDNS bits.
enum IdentifierNamespace {
/// Labels, declared with 'x:' and referenced with 'goto x'.
IDNS_Label = 0x0001,
@@ -225,10 +225,10 @@ protected:
// PCHLevel - the "level" of precompiled header/AST file from which this
// declaration was built.
- unsigned PCHLevel : 2;
+ unsigned PCHLevel : 3;
/// IdentifierNamespace - This specifies what IDNS_* namespace this lives in.
- unsigned IdentifierNamespace : 16;
+ unsigned IdentifierNamespace : 15;
private:
#ifndef NDEBUG
@@ -358,14 +358,14 @@ public:
unsigned getPCHLevel() const { return PCHLevel; }
/// \brief The maximum PCH level that any declaration may have.
- static const unsigned MaxPCHLevel = 3;
-
+ static const unsigned MaxPCHLevel = 7;
+
/// \brief Set the PCH level of this declaration.
void setPCHLevel(unsigned Level) {
- assert(Level < MaxPCHLevel && "PCH level exceeds the maximum");
+ assert(Level <= MaxPCHLevel && "PCH level exceeds the maximum");
PCHLevel = Level;
}
-
+
unsigned getIdentifierNamespace() const {
return IdentifierNamespace;
}
diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h
index fb8596f50a0b..30f63d895959 100644
--- a/include/clang/AST/DeclObjC.h
+++ b/include/clang/AST/DeclObjC.h
@@ -242,7 +242,7 @@ public:
/// \brief Determine the type of an expression that sends a message to this
/// function.
QualType getSendResultType() const {
- return getResultType().getCallResultType(getASTContext());
+ return getResultType().getNonLValueExprType(getASTContext());
}
TypeSourceInfo *getResultTypeSourceInfo() const { return ResultTInfo; }
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 807644349e56..ade2b09c80c2 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -1854,6 +1854,10 @@ public:
/// CK_BitCast - Used for reinterpret_cast.
CK_BitCast,
+ /// CK_LValueBitCast - Used for reinterpret_cast of expressions to
+ /// a reference type.
+ CK_LValueBitCast,
+
/// CK_NoOp - Used for const_cast.
CK_NoOp,
@@ -1957,6 +1961,7 @@ private:
// These should not have an inheritance path.
case CK_Unknown:
case CK_BitCast:
+ case CK_LValueBitCast:
case CK_NoOp:
case CK_Dynamic:
case CK_ToUnion:
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index a1a29e6fef6b..4c148e8fa221 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -629,13 +629,15 @@ public:
bool isAtLeastAsQualifiedAs(QualType Other) const;
QualType getNonReferenceType() const;
- /// \brief Determine the type of an expression that calls a function of
- /// with the given result type.
+ /// \brief Determine the type of a (typically non-lvalue) expression with the
+ /// specified result type.
///
- /// This routine removes a top-level reference (since there are no
+ /// This routine should be used for expressions for which the return type is
+ /// explicitly specified (e.g., in a cast or call) and isn't necessarily
+ /// an lvalue. It removes a top-level reference (since there are no
/// expressions of reference type) and deletes top-level cvr-qualifiers
/// from non-class types (in C++) or all types (in C).
- QualType getCallResultType(ASTContext &Context) const;
+ QualType getNonLValueExprType(ASTContext &Context) const;
/// getDesugaredType - Return the specified type with any "sugar" removed from
/// the type. This takes off typedefs, typeof's etc. If the outer level of
@@ -784,19 +786,27 @@ private:
/// \brief Linkage of this type.
mutable unsigned CachedLinkage : 2;
-
+
+ /// \brief FromPCH - Whether this type comes from a PCH file.
+ mutable bool FromPCH : 1;
+
+ /// \brief Set whether this type comes from a PCH file.
+ void setFromPCH(bool V = true) const {
+ FromPCH = V;
+ }
+
protected:
/// \brief Compute the linkage of this type.
virtual Linkage getLinkageImpl() const;
- enum { BitsRemainingInType = 20 };
+ enum { BitsRemainingInType = 19 };
// silence VC++ warning C4355: 'this' : used in base member initializer list
Type *this_() { return this; }
Type(TypeClass tc, QualType Canonical, bool dependent)
: CanonicalType(Canonical.isNull() ? QualType(this_(), 0) : Canonical),
TC(tc), Dependent(dependent), LinkageKnown(false),
- CachedLinkage(NoLinkage) {}
+ CachedLinkage(NoLinkage), FromPCH(false) {}
virtual ~Type() {}
virtual void Destroy(ASTContext& C);
friend class ASTContext;
@@ -804,6 +814,9 @@ protected:
public:
TypeClass getTypeClass() const { return static_cast<TypeClass>(TC); }
+ /// \brief Whether this type comes from a PCH file.
+ bool isFromPCH() const { return FromPCH; }
+
bool isCanonicalUnqualified() const {
return CanonicalType.getTypePtr() == this;
}
@@ -1907,7 +1920,7 @@ public:
/// \brief Determine the type of an expression that calls a function of
/// this type.
QualType getCallResultType(ASTContext &Context) const {
- return getResultType().getCallResultType(Context);
+ return getResultType().getNonLValueExprType(Context);
}
static llvm::StringRef getNameForCallConv(CallingConv CC);
diff --git a/include/clang/Basic/Builtins.def b/include/clang/Basic/Builtins.def
index cad28243a31c..eff4f5e6727b 100644
--- a/include/clang/Basic/Builtins.def
+++ b/include/clang/Basic/Builtins.def
@@ -314,6 +314,7 @@ BUILTIN(__builtin_setjmp, "iv**", "")
BUILTIN(__builtin_longjmp, "vv**i", "r")
BUILTIN(__builtin_unwind_init, "v", "")
BUILTIN(__builtin_eh_return_data_regno, "ii", "nc")
+BUILTIN(__builtin_snprintf, "ic*zcC*.", "nFp:2:")
BUILTIN(__builtin_vsprintf, "ic*cC*a", "nFP:1:")
BUILTIN(__builtin_vsnprintf, "ic*zcC*a", "nFP:2:")
diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td
index 930fe422cff0..49077513c137 100644
--- a/include/clang/Basic/DiagnosticGroups.td
+++ b/include/clang/Basic/DiagnosticGroups.td
@@ -48,6 +48,7 @@ def CXXHexFloats : DiagGroup<"c++-hex-floats">;
def : DiagGroup<"c++0x-compat", [CXXHexFloats]>;
def FourByteMultiChar : DiagGroup<"four-char-constants">;
def : DiagGroup<"idiomatic-parentheses">;
+def IgnoredQualifiers : DiagGroup<"ignored-qualifiers">;
def : DiagGroup<"import">;
def : DiagGroup<"init-self">;
def : DiagGroup<"inline">;
@@ -167,6 +168,7 @@ def Format2 : DiagGroup<"format=2",
def Extra : DiagGroup<"extra", [
MissingFieldInitializers,
+ IgnoredQualifiers,
InitializerOverrides,
SemiBeforeMethodBody,
SignCompare,
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 8fac1edecfa8..01a37fb6f2c6 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -121,7 +121,8 @@ def warn_use_out_of_scope_declaration : Warning<
def err_inline_non_function : Error<
"'inline' can only appear on functions">;
def warn_qual_return_type : Warning<
- "'%0' type qualifier%s1 on return type %plural{1:has|:have}1 no effect">;
+ "'%0' type qualifier%s1 on return type %plural{1:has|:have}1 no effect">,
+ InGroup<IgnoredQualifiers>, DefaultIgnore;
def warn_decl_shadow :
Warning<"declaration shadows a %select{"
@@ -1986,6 +1987,10 @@ def note_precedence_bitwise_first : Note<
"place parentheses around the %0 expression to evaluate it first">;
def note_precedence_bitwise_silence : Note<
"place parentheses around the %0 expression to silence this warning">;
+
+def warn_logical_instead_of_bitwise : Warning<
+ "use of logical %0 with constant operand; switch to bitwise %1 or "
+ "remove constant">, InGroup<DiagGroup<"logical-bitwise-confusion">>;
def err_sizeof_nonfragile_interface : Error<
"invalid application of '%select{alignof|sizeof}1' to interface %0 in "
diff --git a/include/clang/Basic/FileManager.h b/include/clang/Basic/FileManager.h
index d0e0118d99d6..e71f51a0e700 100644
--- a/include/clang/Basic/FileManager.h
+++ b/include/clang/Basic/FileManager.h
@@ -189,7 +189,7 @@ public:
/// getDirectory - Lookup, cache, and verify the specified directory. This
/// returns null if the directory doesn't exist.
///
- const DirectoryEntry *getDirectory(const llvm::StringRef &Filename) {
+ const DirectoryEntry *getDirectory(llvm::StringRef Filename) {
return getDirectory(Filename.begin(), Filename.end());
}
const DirectoryEntry *getDirectory(const char *FileStart,const char *FileEnd);
@@ -197,7 +197,7 @@ public:
/// getFile - Lookup, cache, and verify the specified file. This returns null
/// if the file doesn't exist.
///
- const FileEntry *getFile(const llvm::StringRef &Filename) {
+ const FileEntry *getFile(llvm::StringRef Filename) {
return getFile(Filename.begin(), Filename.end());
}
const FileEntry *getFile(const char *FilenameStart,
@@ -206,8 +206,8 @@ public:
/// \brief Retrieve a file entry for a "virtual" file that acts as
/// if there were a file with the given name on disk. The file
/// itself is not accessed.
- const FileEntry *getVirtualFile(const llvm::StringRef &Filename,
- off_t Size, time_t ModificationTime);
+ const FileEntry *getVirtualFile(llvm::StringRef Filename, off_t Size,
+ time_t ModificationTime);
void PrintStats() const;
};
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h
index 5763a12135e9..9f7debf9c500 100644
--- a/include/clang/Basic/TargetInfo.h
+++ b/include/clang/Basic/TargetInfo.h
@@ -61,6 +61,7 @@ protected:
std::string CXXABI;
unsigned HasAlignMac68kSupport : 1;
+ unsigned RealTypeUsesObjCFPRet : 3;
// TargetInfo Constructor. Default initializes all fields.
TargetInfo(const std::string &T);
@@ -87,6 +88,13 @@ public:
SignedLongLong,
UnsignedLongLong
};
+
+ enum RealType {
+ Float = 0,
+ Double,
+ LongDouble
+ };
+
protected:
IntType SizeType, IntMaxType, UIntMaxType, PtrDiffType, IntPtrType, WCharType,
WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType;
@@ -233,6 +241,12 @@ public:
/// integer type enum. For example, SignedLong -> "L".
static const char *getTypeConstantSuffix(IntType T);
+ /// \brief Check whether the given real type should use the "fpret" flavor of
+ /// Obj-C message passing on this target.
+ bool useObjCFPRetForRealType(RealType T) const {
+ return RealTypeUsesObjCFPRet & (1 << T);
+ }
+
///===---- Other target property query methods --------------------------===//
/// getTargetDefines - Appends the target-specific #define values for this
diff --git a/include/clang/Driver/ArgList.h b/include/clang/Driver/ArgList.h
index 16396daa60ef..257b653f57e6 100644
--- a/include/clang/Driver/ArgList.h
+++ b/include/clang/Driver/ArgList.h
@@ -179,6 +179,8 @@ namespace driver {
Arg *getLastArg(OptSpecifier Id) const;
Arg *getLastArg(OptSpecifier Id0, OptSpecifier Id1) const;
Arg *getLastArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2) const;
+ Arg *getLastArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2,
+ OptSpecifier Id3) const;
/// getArgString - Return the input argument string at \arg Index.
virtual const char *getArgString(unsigned Index) const = 0;
diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h
index 153981f842d3..bb578b516ce3 100644
--- a/include/clang/Driver/Driver.h
+++ b/include/clang/Driver/Driver.h
@@ -62,6 +62,9 @@ public:
/// command line.
std::string Dir;
+ /// The original path to the clang executable.
+ std::string ClangExecutable;
+
/// The path to the compiler resource directory.
std::string ResourceDir;
@@ -163,6 +166,11 @@ public:
const std::string &getTitle() { return DriverTitle; }
void setTitle(std::string Value) { DriverTitle = Value; }
+ /// \brief Get the path to the main clang executable.
+ std::string getClangProgramPath() const {
+ return ClangExecutable;
+ }
+
/// @}
/// @name Primary Functionality
/// @{
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
index 96ec12215b40..73c8e6bda2e4 100644
--- a/include/clang/Driver/Options.td
+++ b/include/clang/Driver/Options.td
@@ -230,6 +230,7 @@ def exported__symbols__list : Separate<"-exported_symbols_list">;
def e : JoinedOrSeparate<"-e">;
def fPIC : Flag<"-fPIC">, Group<f_Group>;
def fPIE : Flag<"-fPIE">, Group<f_Group>;
+def fno_PIE : Flag<"-fno-PIE">, Group<f_Group>;
def faccess_control : Flag<"-faccess-control">, Group<f_Group>;
def fapple_kext : Flag<"-fapple-kext">, Group<f_Group>;
def fasm : Flag<"-fasm">, Group<f_Group>;
@@ -356,6 +357,7 @@ def fpascal_strings : Flag<"-fpascal-strings">, Group<f_Group>;
def fpch_preprocess : Flag<"-fpch-preprocess">, Group<f_Group>;
def fpic : Flag<"-fpic">, Group<f_Group>;
def fpie : Flag<"-fpie">, Group<f_Group>;
+def fno_pie : Flag<"-fno-pie">, Group<f_Group>;
def fprofile_arcs : Flag<"-fprofile-arcs">, Group<f_Group>;
def fprofile_generate : Flag<"-fprofile-generate">, Group<f_Group>;
def framework : Separate<"-framework">, Flags<[LinkerInput]>;
@@ -436,11 +438,11 @@ def mfix_and_continue : Flag<"-mfix-and-continue">, Group<clang_ignored_m_Group>
def mfloat_abi_EQ : Joined<"-mfloat-abi=">, Group<m_Group>;
def mfpu_EQ : Joined<"-mfpu=">, Group<m_Group>;
def mhard_float : Flag<"-mhard-float">, Group<m_Group>;
-def miphoneos_version_min_EQ : Joined<"-miphoneos-version-min=">, Group<m_Group>, Flags<[DriverOption]>;
+def miphoneos_version_min_EQ : Joined<"-miphoneos-version-min=">, Group<m_Group>;
def mios_version_min_EQ : Joined<"-mios-version-min=">, Alias<miphoneos_version_min_EQ>;
def mkernel : Flag<"-mkernel">, Group<m_Group>;
def mllvm : Separate<"-mllvm">;
-def mmacosx_version_min_EQ : Joined<"-mmacosx-version-min=">, Group<m_Group>, Flags<[DriverOption]>;
+def mmacosx_version_min_EQ : Joined<"-mmacosx-version-min=">, Group<m_Group>;
def mmmx : Flag<"-mmmx">, Group<m_x86_Features_Group>;
def mno_3dnowa : Flag<"-mno-3dnowa">, Group<m_x86_Features_Group>;
def mno_3dnow : Flag<"-mno-3dnow">, Group<m_x86_Features_Group>;
diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h
index 2cec22a09d8b..11a153c48ca3 100644
--- a/include/clang/Driver/ToolChain.h
+++ b/include/clang/Driver/ToolChain.h
@@ -84,9 +84,8 @@ public:
// Helper methods
- std::string GetFilePath(const Compilation &C, const char *Name) const;
- std::string GetProgramPath(const Compilation &C, const char *Name,
- bool WantFile = false) const;
+ std::string GetFilePath(const char *Name) const;
+ std::string GetProgramPath(const char *Name, bool WantFile = false) const;
// Platform defaults information
diff --git a/include/clang/Driver/Types.def b/include/clang/Driver/Types.def
index d3a3d29fbc0f..06a8690ce833 100644
--- a/include/clang/Driver/Types.def
+++ b/include/clang/Driver/Types.def
@@ -69,8 +69,8 @@ TYPE("java", Java, INVALID, 0, "u")
// LLVM IR/LTO types. We define separate types for IR and LTO because LTO
// outputs should use the standard suffixes.
-TYPE("ir", LLVM_IR, INVALID, "ll", "")
-TYPE("ir", LLVM_BC, INVALID, "bc", "")
+TYPE("ir", LLVM_IR, INVALID, "ll", "u")
+TYPE("ir", LLVM_BC, INVALID, "bc", "u")
TYPE("lto-ir", LTO_IR, INVALID, "s", "")
TYPE("lto-bc", LTO_BC, INVALID, "o", "")
diff --git a/include/clang/Frontend/ASTConsumers.h b/include/clang/Frontend/ASTConsumers.h
index 5718979ba1db..2d1df44cc968 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 000000000000..c9b90e22c8cd
--- /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 38402732a342..47e871f50aeb 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 860ef56a58ff..70ad1d7c7e78 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
diff --git a/include/clang/Rewrite/Rewriter.h b/include/clang/Rewrite/Rewriter.h
index 0612a15bbf3f..b3d4035628ee 100644
--- a/include/clang/Rewrite/Rewriter.h
+++ b/include/clang/Rewrite/Rewriter.h
@@ -64,7 +64,7 @@ public:
/// the buffer is specified relative to the original SourceBuffer. The
/// text is inserted after the specified location.
///
- void InsertText(unsigned OrigOffset, const llvm::StringRef &Str,
+ void InsertText(unsigned OrigOffset, llvm::StringRef Str,
bool InsertAfter = true);
@@ -72,14 +72,14 @@ public:
/// offset in the buffer is specified relative to the original
/// SourceBuffer. The text is inserted before the specified location. This is
/// method is the same as InsertText with "InsertAfter == false".
- void InsertTextBefore(unsigned OrigOffset, const llvm::StringRef &Str) {
+ void InsertTextBefore(unsigned OrigOffset, llvm::StringRef Str) {
InsertText(OrigOffset, Str, false);
}
/// InsertTextAfter - Insert some text at the specified point, where the
/// offset in the buffer is specified relative to the original SourceBuffer.
/// The text is inserted after the specified location.
- void InsertTextAfter(unsigned OrigOffset, const llvm::StringRef &Str) {
+ void InsertTextAfter(unsigned OrigOffset, llvm::StringRef Str) {
InsertText(OrigOffset, Str);
}
@@ -87,7 +87,7 @@ public:
/// buffer with a new string. This is effectively a combined "remove/insert"
/// operation.
void ReplaceText(unsigned OrigOffset, unsigned OrigLength,
- const llvm::StringRef &NewStr);
+ llvm::StringRef NewStr);
private: // Methods only usable by Rewriter.
@@ -164,7 +164,7 @@ public:
/// InsertText - Insert the specified string at the specified location in the
/// original buffer. This method returns true (and does nothing) if the input
/// location was not rewritable, false otherwise.
- bool InsertText(SourceLocation Loc, const llvm::StringRef &Str,
+ bool InsertText(SourceLocation Loc, llvm::StringRef Str,
bool InsertAfter = true);
/// InsertTextAfter - Insert the specified string at the specified location in
@@ -172,7 +172,7 @@ public:
/// the input location was not rewritable, false otherwise. Text is
/// inserted after any other text that has been previously inserted
/// at the some point (the default behavior for InsertText).
- bool InsertTextAfter(SourceLocation Loc, const llvm::StringRef &Str) {
+ bool InsertTextAfter(SourceLocation Loc, llvm::StringRef Str) {
return InsertText(Loc, Str);
}
@@ -181,7 +181,7 @@ public:
/// location was not rewritable, false otherwise. Text is
/// inserted before any other text that has been previously inserted
/// at the some point.
- bool InsertTextBefore(SourceLocation Loc, const llvm::StringRef &Str) {
+ bool InsertTextBefore(SourceLocation Loc, llvm::StringRef Str) {
return InsertText(Loc, Str, false);
}
@@ -192,7 +192,7 @@ public:
/// buffer with a new string. This is effectively a combined "remove/insert"
/// operation.
bool ReplaceText(SourceLocation Start, unsigned OrigLength,
- const llvm::StringRef &NewStr);
+ llvm::StringRef NewStr);
/// ReplaceStmt - This replaces a Stmt/Expr with another, using the pretty
/// printer to generate the replacement code. This returns true if the input