diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-10-24 23:41:50 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-10-24 23:41:50 +0000 |
commit | 4c0c7e86645dfa1719d17d70e009ab49347aba62 (patch) | |
tree | a418e94002d9c7a7c6d7352b1cff125c2b256072 /test/PCH | |
parent | 3584972866f39d42aa4029586278022d89451bd9 (diff) |
Teach the PCH validator to check the preprocessor options, especially
the macros that are #define'd or #undef'd on the command line. This
checking happens much earlier than the current macro-definition
checking and is far cleaner, because it does a direct comparison
rather than a diff of the predefines buffers. Moreover, it allows us
to use the result of this check to skip over PCH files within a
directory that have non-matching -D's or -U's on the command
line. Finally, it improves the diagnostics a bit for mismatches,
fixing <rdar://problem/8612222>.
The old predefines-buffer diff'ing will go away in a subsequent commit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166641 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/PCH')
-rw-r--r-- | test/PCH/fuzzy-pch.c | 16 | ||||
-rw-r--r-- | test/PCH/pch-dir.c | 9 |
2 files changed, 21 insertions, 4 deletions
diff --git a/test/PCH/fuzzy-pch.c b/test/PCH/fuzzy-pch.c index 567575346c..7296d1dc89 100644 --- a/test/PCH/fuzzy-pch.c +++ b/test/PCH/fuzzy-pch.c @@ -1,8 +1,14 @@ // Test with pch. // RUN: %clang_cc1 -emit-pch -DFOO -o %t %S/variables.h // RUN: %clang_cc1 -DBAR=int -include-pch %t -fsyntax-only -pedantic %s -// RUN: %clang_cc1 -DFOO -DBAR=int -include-pch %t -Werror %s -// RUN: not %clang_cc1 -DFOO -DBAR=int -DX=5 -include-pch %t -Werror %s +// RUN: %clang_cc1 -DFOO -DBAR=int -include-pch %t %s +// RUN: not %clang_cc1 -DFOO=blah -DBAR=int -include-pch %t %s 2> %t.err +// RUN: FileCheck -check-prefix=CHECK-FOO %s < %t.err +// RUN: not %clang_cc1 -UFOO -include-pch %t %s 2> %t.err +// RUN: FileCheck -check-prefix=CHECK-NOFOO %s < %t.err + +// RUN: not %clang_cc1 -DFOO -undef -include-pch %t %s 2> %t.err +// RUN: FileCheck -check-prefix=CHECK-UNDEF %s < %t.err BAR bar = 17; @@ -17,3 +23,9 @@ BAR bar = 17; #ifndef BAR # error BAR was not defined #endif + +// CHECK-FOO: definition of macro 'FOO' differs between the precompiled header ('1') and the command line ('blah') +// CHECK-NOFOO: macro 'FOO' was defined in the precompiled header but undef'd on the command line + +// CHECK-UNDEF: command line contains '-undef' but precompiled header was not built with it + diff --git a/test/PCH/pch-dir.c b/test/PCH/pch-dir.c index 73a7ba9003..ae841ce0a7 100644 --- a/test/PCH/pch-dir.c +++ b/test/PCH/pch-dir.c @@ -1,14 +1,19 @@ // RUN: mkdir -p %t.h.gch -// RUN: %clang -x c-header %S/pch-dir.h -o %t.h.gch/c.gch +// RUN: %clang -x c-header %S/pch-dir.h -DFOO=foo -o %t.h.gch/c.gch +// RUN: %clang -x c-header %S/pch-dir.h -DFOO=bar -o %t.h.gch/cbar.gch // RUN: %clang -x c++-header -std=c++98 %S/pch-dir.h -o %t.h.gch/cpp.gch -// RUN: %clang -include %t.h -fsyntax-only %s -Xclang -print-stats 2> %t.clog +// RUN: %clang -include %t.h -DFOO=foo -fsyntax-only %s -Xclang -print-stats 2> %t.clog // RUN: FileCheck -check-prefix=C %s < %t.clog +// RUN: %clang -include %t.h -DFOO=bar -DBAR=bar -fsyntax-only %s -Xclang -ast-print > %t.cbarlog +// RUN: FileCheck -check-prefix=CBAR %s < %t.cbarlog // RUN: %clang -x c++ -include %t.h -std=c++98 -fsyntax-only %s -Xclang -print-stats 2> %t.cpplog // RUN: FileCheck -check-prefix=CPP %s < %t.cpplog // RUN: not %clang -x c++ -std=c++11 -include %t.h -fsyntax-only %s 2> %t.cpp11log // RUN: FileCheck -check-prefix=CPP11 %s < %t.cpp11log +// CHECK-CBAR: int bar +int FOO; int get() { #ifdef __cplusplus |