mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 08:06:06 +00:00

If a PCH is used for compilation, SourceManager::isInMainFile() returns true even for the "<built-in>" predefines area. Using -D only for the TU compilation may trigger -Wunused-macros for it. It is admitedly a bit fishy to set a macro only for a TU and not for the PCH, but this works fine if the PCH does not use the macro (I couldn't find a statement on this for Clang, but GCC explicitly allows this in the docs). Differential Revision: https://reviews.llvm.org/D73846
13 lines
417 B
C
13 lines
417 B
C
// Test this without pch.
|
|
// RUN: %clang_cc1 -Wunused-macros -Dunused=1 -fsyntax-only -verify %s
|
|
|
|
// Test with pch.
|
|
// RUN: %clang_cc1 -Wunused-macros -emit-pch -o %t %s
|
|
// RUN: %clang_cc1 -Wunused-macros -Dunused=1 -include-pch %t -fsyntax-only -verify %s
|
|
|
|
// expected-no-diagnostics
|
|
|
|
// -Dunused=1 is intentionally not set for the pch.
|
|
// There still should be no unused warning for a macro from the command line.
|
|
|