aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-04-10 23:10:45 +0000
committerDouglas Gregor <dgregor@apple.com>2009-04-10 23:10:45 +0000
commite1d918e9fe55e3b34401fd5d420c47ea0f9572c9 (patch)
tree6822c3f153c65c33f08ebfb5ee3e1915decacc2a /include
parentc0c0ef061f2aaf054c7a970f28961097e46661f3 (diff)
Compare the predefines buffer in the PCH file with the predefines
buffer generated for the current translation unit. If they are different, complain and then ignore the PCH file. This effectively checks for all compilation options that somehow would affect preprocessor state (-D, -U, -include, the dreaded -imacros, etc.). When we do accept the PCH file, throw away the contents of the predefines buffer rather than parsing them, since all of the results of that parsing are already stored in the PCH file. This eliminates the ugliness with the redefinition of __builtin_va_list, among other things. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68838 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/clang/Basic/DiagnosticFrontendKinds.td5
-rw-r--r--include/clang/Frontend/PCHReader.h16
-rw-r--r--include/clang/Lex/Preprocessor.h1
3 files changed, 17 insertions, 5 deletions
diff --git a/include/clang/Basic/DiagnosticFrontendKinds.td b/include/clang/Basic/DiagnosticFrontendKinds.td
index 9db74e2518..55d1dfacb8 100644
--- a/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -110,4 +110,9 @@ def warn_pch_gc_mode : Warning<
"the PCH file was built with %select{no||hybrid}0 garbage collection but "
"the current translation unit will compiled with %select{no||hybrid}1 "
"garbage collection">;
+def warn_pch_preprocessor : Warning<
+ "the PCH file was built with different preprocessor definitions than the "
+ "current translation unit">;
+def note_predef_in_pch : Note<
+ "preprocessor definitions in PCH file">;
}
diff --git a/include/clang/Frontend/PCHReader.h b/include/clang/Frontend/PCHReader.h
index 0c14df070e..3efb3a55d6 100644
--- a/include/clang/Frontend/PCHReader.h
+++ b/include/clang/Frontend/PCHReader.h
@@ -51,6 +51,10 @@ class Preprocessor;
/// required when traversing the AST. Only those AST nodes that are
/// actually required will be de-serialized.
class PCHReader : public ExternalASTSource {
+public:
+ enum PCHReadResult { Success, Failure, IgnorePCH };
+
+private:
/// \brief The preprocessor that will be loading the source file.
Preprocessor &PP;
@@ -103,10 +107,11 @@ class PCHReader : public ExternalASTSource {
/// DeclContext.
DeclContextOffsetsMap DeclContextOffsets;
- enum PCHReadResult { Success, Failure, IgnorePCH };
-
PCHReadResult ReadPCHBlock();
- bool ReadSourceManagerBlock();
+ bool CheckPredefinesBuffer(const char *PCHPredef,
+ unsigned PCHPredefLen,
+ FileID PCHBufferID);
+ PCHReadResult ReadSourceManagerBlock();
bool ReadPreprocessorBlock();
bool ParseLanguageOptions(const llvm::SmallVectorImpl<uint64_t> &Record);
@@ -125,7 +130,7 @@ public:
~PCHReader();
- bool ReadPCH(const std::string &FileName);
+ PCHReadResult ReadPCH(const std::string &FileName);
/// \brief Resolve a type ID into a type, potentially building a new
/// type.
@@ -176,6 +181,9 @@ public:
/// \brief Report a diagnostic.
DiagnosticBuilder Diag(unsigned DiagID);
+ /// \brief Report a diagnostic.
+ DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID);
+
const IdentifierInfo *GetIdentifierInfo(const RecordData &Record,
unsigned &Idx);
DeclarationName ReadDeclarationName(const RecordData &Record, unsigned &Idx);
diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h
index 656ebed899..47f40b68f6 100644
--- a/include/clang/Lex/Preprocessor.h
+++ b/include/clang/Lex/Preprocessor.h
@@ -788,7 +788,6 @@ class PreprocessorFactory {
public:
virtual ~PreprocessorFactory();
virtual Preprocessor* CreatePreprocessor() = 0;
- virtual bool FinishInitialization(Preprocessor *PP, bool usesPCH);
};
} // end namespace clang