From eb114da5068e363e2c54fcffc550b137c56f1e7d Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 1 Oct 2010 01:03:07 +0000 Subject: When an identifier that has a macro definition in the original PCH file is somehow changed in a chained PCH file, make sure that we write out the macro definition. Fixes part of . llvm-svn: 115259 --- clang/lib/Serialization/ASTWriter.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'clang/lib/Serialization/ASTWriter.cpp') diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 3f537d21ab5..f5f96ecd24e 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -1276,7 +1276,13 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP) { // Don't emit builtin macros like __LINE__ to the AST file unless they have // been redefined by the header (in which case they are not isBuiltinMacro). // Also skip macros from a AST file if we're chaining. - if (MI->isBuiltinMacro() || (Chain && MI->isFromAST())) + + // FIXME: There is a (probably minor) optimization we could do here, if + // the macro comes from the original PCH but the identifier comes from a + // chained PCH, by storing the offset into the original PCH rather than + // writing the macro definition a second time. + if (MI->isBuiltinMacro() || + (Chain && I->first->isFromAST() && MI->isFromAST())) continue; AddIdentifierRef(I->first, Record); -- cgit v1.2.3