mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 01:06:06 +00:00
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 <rdar://problem/8499034>. llvm-svn: 115259
This commit is contained in:
parent
220d971ace
commit
eb114da506
@ -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);
|
||||
|
@ -2,3 +2,4 @@ void f() __attribute__((unavailable));
|
||||
void g();
|
||||
#define g() f()
|
||||
#define h() f()
|
||||
#define x x
|
||||
|
@ -2,3 +2,4 @@
|
||||
#undef g
|
||||
#undef h
|
||||
#define h() g()
|
||||
int x;
|
||||
|
@ -6,8 +6,9 @@
|
||||
// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-macro-override2.h -include-pch %t1 -chained-pch
|
||||
// RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s
|
||||
|
||||
void foo() {
|
||||
int foo() {
|
||||
f();
|
||||
g();
|
||||
h();
|
||||
return x;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user