From fa9df7af07fa888feec91b06320b9091d4a3fb52 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Fri, 3 Oct 2014 22:18:49 +0000 Subject: [PATCH] test: Disable standard system includes in %clang_cc1 This adds -nostdsysteminc to the %clang_cc1 expansion, which should make it harder to accidentally write tests that depend on headers in /usr/include. It also updates a few tests that use -isysroot and a darwin triple to omit the triple and use -isystem /usr/include instead, making them a little bit more general. Incidentally, this fixes a test failure I'm seeing on darwin in Modules/stddef.c, that happens because my system finds a stddef.h in /usr/include. llvm-svn: 219030 --- clang/test/Modules/Werror-Wsystem-headers.m | 6 +++--- clang/test/Modules/dependency-gen.m | 4 ++-- clang/test/Modules/module_file_info.m | 6 +++--- clang/test/Modules/validate-system-headers.m | 12 ++++++------ clang/test/PCH/verify_pch.m | 14 +++++++------- clang/test/Preprocessor/headermap-rel2.c | 4 ++-- clang/test/lit.cfg | 3 ++- 7 files changed, 25 insertions(+), 24 deletions(-) diff --git a/clang/test/Modules/Werror-Wsystem-headers.m b/clang/test/Modules/Werror-Wsystem-headers.m index c4cd1a6378cc..7b3424b8074d 100644 --- a/clang/test/Modules/Werror-Wsystem-headers.m +++ b/clang/test/Modules/Werror-Wsystem-headers.m @@ -5,17 +5,17 @@ // Initial module build // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \ -// RUN: -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -fsyntax-only %s -verify +// RUN: -isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify // RUN: cp %t/cstd.pcm %t-saved/cstd.pcm // Even with -Werror don't rebuild a system module // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \ -// RUN: -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -fsyntax-only %s -verify -Werror +// RUN: -isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify -Werror // RUN: diff %t/cstd.pcm %t-saved/cstd.pcm // Unless -Wsystem-headers is on // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fdisable-module-hash \ -// RUN: -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -fsyntax-only %s -verify \ +// RUN: -isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify \ // RUN: -Werror=unused -Wsystem-headers // RUN: not diff %t/cstd.pcm %t-saved/cstd.pcm diff --git a/clang/test/Modules/dependency-gen.m b/clang/test/Modules/dependency-gen.m index dec83848f061..d3d66bfaab21 100644 --- a/clang/test/Modules/dependency-gen.m +++ b/clang/test/Modules/dependency-gen.m @@ -1,7 +1,7 @@ // RUN: rm -rf %t-mcp // RUN: mkdir -p %t-mcp -// RUN: %clang_cc1 -x objective-c -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -dependency-file %t.d.1 -MT %s.o -I %S/Inputs -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s +// RUN: %clang_cc1 -x objective-c -isystem %S/Inputs/System/usr/include -dependency-file %t.d.1 -MT %s.o -I %S/Inputs -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s // RUN: FileCheck %s < %t.d.1 // CHECK: dependency-gen.m // CHECK: Inputs{{.}}diamond_top.h @@ -10,7 +10,7 @@ // CHECK-NOT: stdint.h -// RUN: %clang_cc1 -x objective-c -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -dependency-file %t.d.2 -MT %s.o -I %S/Inputs -sys-header-deps -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s +// RUN: %clang_cc1 -x objective-c -isystem %S/Inputs/System/usr/include -dependency-file %t.d.2 -MT %s.o -I %S/Inputs -sys-header-deps -fsyntax-only -fmodules -fmodules-cache-path=%t-mcp %s // RUN: FileCheck %s -check-prefix=CHECK-SYS < %t.d.2 // CHECK-SYS: dependency-gen.m // CHECK-SYS: Inputs{{.}}diamond_top.h diff --git a/clang/test/Modules/module_file_info.m b/clang/test/Modules/module_file_info.m index 2447a747e3dd..1b0a838bf823 100644 --- a/clang/test/Modules/module_file_info.m +++ b/clang/test/Modules/module_file_info.m @@ -17,8 +17,8 @@ // CHECK: Target options: // CHECK: Triple: -// CHECK: CPU: -// CHECK: ABI: +// CHECK: CPU: +// CHECK: ABI: // CHECK: Diagnostic options: // CHECK: IgnoreWarnings: Yes @@ -28,7 +28,7 @@ // CHECK: Header search options: // CHECK: System root [-isysroot=]: '/' // CHECK: Use builtin include directories [-nobuiltininc]: Yes -// CHECK: Use standard system include directories [-nostdinc]: Yes +// CHECK: Use standard system include directories [-nostdinc]: No // CHECK: Use standard C++ include directories [-nostdinc++]: Yes // CHECK: Use libc++ (rather than libstdc++) [-stdlib=]: diff --git a/clang/test/Modules/validate-system-headers.m b/clang/test/Modules/validate-system-headers.m index 48ea64c5a938..b5e7c6abc401 100644 --- a/clang/test/Modules/validate-system-headers.m +++ b/clang/test/Modules/validate-system-headers.m @@ -5,37 +5,37 @@ //// // Build a module using a system header -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s +// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s // RUN: cp %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved //// // Modify the system header, and confirm that we don't notice without -fmodules-validate-system-headers. // The pcm file in the cache should fail to validate. // RUN: echo ' ' >> %t/Inputs/usr/include/foo.h -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s +// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s // RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved //// // Now make sure we rebuild the module when -fmodules-validate-system-headers is set. -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-validate-system-headers -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s +// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-validate-system-headers -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s // RUN: not diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved //// // This should override -fmodules-validate-once-per-build-session // RUN: cp %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session +// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session // RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved // Modify the system header... // RUN: echo ' ' >> %t/Inputs/usr/include/foo.h // Don't recompile due to -fmodules-validate-once-per-build-session -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session +// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session // RUN: diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved // Now add -fmodules-validate-system-headers and rebuild -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t/Inputs -fmodules -fmodules-validate-system-headers -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session +// RUN: %clang_cc1 -isystem %t/Inputs/usr/include -fmodules -fmodules-validate-system-headers -fmodules-cache-path=%t/ModuleCache -fdisable-module-hash -x objective-c-header -fsyntax-only %s -fbuild-session-timestamp=1390000000 -fmodules-validate-once-per-build-session // RUN: not diff %t/ModuleCache/Foo.pcm %t/Foo.pcm.saved // REQUIRES: shell diff --git a/clang/test/PCH/verify_pch.m b/clang/test/PCH/verify_pch.m index dcfb286e2a11..e905f2537c7f 100644 --- a/clang/test/PCH/verify_pch.m +++ b/clang/test/PCH/verify_pch.m @@ -5,25 +5,25 @@ // RUN: cp %s %t.h // // Precompile -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t -x objective-c-header -emit-pch -o %t.pch %t.h +// RUN: %clang_cc1 -isystem %t/usr/include -x objective-c-header -emit-pch -o %t.pch %t.h // Verify successfully -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t -verify-pch %t.pch +// RUN: %clang_cc1 -isystem %t/usr/include -verify-pch %t.pch // Incompatible lang options ignored -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t -x objective-c -fno-builtin -verify-pch %t.pch +// RUN: %clang_cc1 -isystem %t/usr/include -x objective-c -fno-builtin -verify-pch %t.pch // Stale dependency // RUN: echo ' ' >> %t.h -// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t -verify-pch %t.pch 2> %t.log.2 +// RUN: not %clang_cc1 -isystem %t/usr/include -verify-pch %t.pch 2> %t.log.2 // RUN: FileCheck -check-prefix=CHECK-STALE-DEP %s < %t.log.2 // CHECK-STALE-DEP: file '{{.*}}.h' has been modified since the precompiled header '{{.*}}.pch' was built // Stale dependency in system header -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t -x objective-c-header -emit-pch -o %t.pch %t.h -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t -verify-pch %t.pch +// RUN: %clang_cc1 -isystem %t/usr/include -x objective-c-header -emit-pch -o %t.pch %t.h +// RUN: %clang_cc1 -isystem %t/usr/include -verify-pch %t.pch // RUN: echo ' ' >> %t/usr/include/sys_header.h -// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -isysroot %t -verify-pch %t.pch 2> %t.log.3 +// RUN: not %clang_cc1 -isystem %t/usr/include -verify-pch %t.pch 2> %t.log.3 // RUN: FileCheck -check-prefix=CHECK-STALE-SYS-H %s < %t.log.3 // CHECK-STALE-SYS-H: file '{{.*}}sys_header.h' has been modified since the precompiled header '{{.*}}.pch' was built diff --git a/clang/test/Preprocessor/headermap-rel2.c b/clang/test/Preprocessor/headermap-rel2.c index 430854de0679..d61f3385b22d 100644 --- a/clang/test/Preprocessor/headermap-rel2.c +++ b/clang/test/Preprocessor/headermap-rel2.c @@ -1,8 +1,8 @@ // This uses a headermap with this entry: // someheader.h -> Product/someheader.h -// RUN: %clang_cc1 -triple x86_64-apple-darwin13 -v -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isysroot %S/Inputs/headermap-rel2/system -I %S/Inputs/headermap-rel2 -H -// RUN: %clang_cc1 -triple x86_64-apple-darwin13 -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isysroot %S/Inputs/headermap-rel2/system -I %S/Inputs/headermap-rel2 -H 2> %t.out +// RUN: %clang_cc1 -v -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isystem %S/Inputs/headermap-rel2/system/usr/include -I %S/Inputs/headermap-rel2 -H +// RUN: %clang_cc1 -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isystem %S/Inputs/headermap-rel2/system/usr/include -I %S/Inputs/headermap-rel2 -H 2> %t.out // RUN: FileCheck %s -input-file %t.out // CHECK: Product/someheader.h diff --git a/clang/test/lit.cfg b/clang/test/lit.cfg index f0be64df7e28..cf03129d92d4 100644 --- a/clang/test/lit.cfg +++ b/clang/test/lit.cfg @@ -259,7 +259,8 @@ def makeMSABITriple(triple): # -win32 is not supported for non-x86 targets; use a default. return 'i686-pc-win32' -config.substitutions.append( ('%clang_cc1', '%s -cc1 -internal-isystem %s' +config.substitutions.append( ('%clang_cc1', + '%s -cc1 -internal-isystem %s -nostdsysteminc' % (config.clang, getClangBuiltinIncludeDir(config.clang))) ) config.substitutions.append( ('%clang_cpp', ' ' + config.clang +