r285152 - Treat module headers wrapped by our builtin headers as implicitly being textual
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 25 18:08:55 PDT 2016
Author: rsmith
Date: Tue Oct 25 20:08:55 2016
New Revision: 285152
URL: http://llvm.org/viewvc/llvm-project?rev=285152&view=rev
Log:
Treat module headers wrapped by our builtin headers as implicitly being textual
headers. We previously got this check backwards and treated the wrapper header
as being textual.
This is important because our wrapper headers sometimes inject macros into the
system headers that they #include_next, and sometimes replace them entirely.
Modified:
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/test/Modules/Inputs/System/usr/include/stdbool.h
cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h
cfe/trunk/test/Modules/cstd.m
Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=285152&r1=285151&r2=285152&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Tue Oct 25 20:08:55 2016
@@ -1881,16 +1881,20 @@ void ModuleMapParser::parseHeaderDecl(MM
Module::Header H = {RelativePathName.str(), File};
Map.excludeHeader(ActiveModule, H);
} else {
- // If there is a builtin counterpart to this file, add it now as a textual
- // header, so it can be #include_next'd by the wrapper header, and can
- // receive macros from the wrapper header.
+ // If there is a builtin counterpart to this file, add it now so it can
+ // wrap the system header.
if (BuiltinFile) {
// FIXME: Taking the name from the FileEntry is unstable and can give
// different results depending on how we've previously named that file
// in this build.
Module::Header H = { BuiltinFile->getName(), BuiltinFile };
- Map.addHeader(ActiveModule, H, ModuleMap::ModuleHeaderRole(
- Role | ModuleMap::TextualHeader));
+ Map.addHeader(ActiveModule, H, Role);
+
+ // If we have both a builtin and system version of the file, the
+ // builtin version may want to inject macros into the system header, so
+ // force the system header to be treated as a textual header in this
+ // case.
+ Role = ModuleMap::ModuleHeaderRole(Role | ModuleMap::TextualHeader);
}
// Record this header.
Modified: cfe/trunk/test/Modules/Inputs/System/usr/include/stdbool.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/System/usr/include/stdbool.h?rev=285152&r1=285151&r2=285152&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/System/usr/include/stdbool.h (original)
+++ cfe/trunk/test/Modules/Inputs/System/usr/include/stdbool.h Tue Oct 25 20:08:55 2016
@@ -1 +1 @@
-#include_next <stdbool.h>
+// Testing hack: does not define bool/true/false.
Modified: cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h?rev=285152&r1=285151&r2=285152&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h (original)
+++ cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h Tue Oct 25 20:08:55 2016
@@ -1,2 +1 @@
// stddef.h
-#include_next "stddef.h"
Modified: cfe/trunk/test/Modules/cstd.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/cstd.m?rev=285152&r1=285151&r2=285152&view=diff
==============================================================================
--- cfe/trunk/test/Modules/cstd.m (original)
+++ cfe/trunk/test/Modules/cstd.m Tue Oct 25 20:08:55 2016
@@ -1,5 +1,5 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -fsyntax-only -isystem %S/Inputs/System/usr/include -ffreestanding -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -D__need_wint_t -Werror=implicit-function-declaration %s
+// RUN: %clang_cc1 -fsyntax-only -internal-isystem %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -D__need_wint_t -Werror=implicit-function-declaration %s
@import uses_other_constants;
const double other_value = DBL_MAX;
More information about the cfe-commits
mailing list