mibintc updated this revision to Diff 104911.
mibintc added a subscriber: ilya-biryukov.
mibintc added a comment.

The previous (n-1) version didn't work: I wanted to iterate through the system 
include directories to check for the existence of stdc-predef.h but clang is 
using a different kind of system include option for /usr and /usr/include so 
the iterator didn't find any system includes at all, i don't think there is an 
iterator which will iterate through these special kind of include directories. 
[Kind of embarrassing that I posted that patch which didn't work at all, sorry 
about that.]

This one behaves more like gcc anyway. gcc puts the -include option in there 
regardless, and to suppress the behavior you are to use the -ffreestanding 
option.

I responded to the remarks from Jonas Hahnfeld, making the patch only for Linux.

I'm having trouble with one of the existing tests. These are the ones that 
fail. I don't know how to fix the text. It's a google test and it is using a 
dummy file system with whitelisted directories. @ilya-biryukov Is there a way 
to pass in a command line argument? if so, I could fix it these failures by 
adding -ffreestanding option which suppresses the new behavior. That's how I 
fixed the many test failures which I encountered with this new behavior.

  Extra Tools Unit Tests :: clangd/ClangdTests/ClangdVFSTest.Parse
  Extra Tools Unit Tests :: clangd/ClangdTests/ClangdVFSTest.ParseWithHeader
  Extra Tools Unit Tests :: clangd/ClangdTests/ClangdVFSTest.Reparse

The other test that fails is my own new test! It fails because I don't know how 
to set it up so the test thinks it has a gcc toolchain with version > 4.8. I 
tried using gcc-toolchain set to various other Linux toolchains that i see in 
the test/Driver/Inputs - none of them cause the gcc version to be in the range. 
I also tried using -ccc-installation=Inputs/ which I see being used for gcc 
version parsing. How can I set up the test so that the GCCInstallation has a 
Version >= 4.8?  I test the new functionality from the console on Linux and can 
confirm it's working.

Failing Tests (4): -- the 3 listed above, as well as

  Clang :: Driver/gcc-predef.c -- my new test, the 3rd run which confirms that 
the include is added


Repository:
  rL LLVM

https://reviews.llvm.org/D34158

Files:
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Gnu.h
  lib/Driver/ToolChains/Linux.cpp
  lib/Driver/ToolChains/Linux.h
  test/Driver/Inputs/basic_linux_tree/usr/include/stdc-predef.h
  test/Driver/clang_cpp.c
  test/Driver/crash-report.c
  test/Driver/gcc-predef.c
  test/Index/IBOutletCollection.m
  test/Index/annotate-macro-args.m
  test/Index/annotate-tokens-pp.c
  test/Index/annotate-tokens.c
  test/Index/c-index-getCursor-test.m
  test/Index/get-cursor-macro-args.m
  test/Index/get-cursor.cpp
  unittests/Tooling/TestVisitor.h

Index: lib/Driver/ToolChains/Linux.h
===================================================================
--- lib/Driver/ToolChains/Linux.h
+++ lib/Driver/ToolChains/Linux.h
@@ -31,6 +31,8 @@
   void addLibStdCxxIncludePaths(
       const llvm::opt::ArgList &DriverArgs,
       llvm::opt::ArgStringList &CC1Args) const override;
+  void AddGnuIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+                          llvm::opt::ArgStringList &CC1Args) const;
   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
                           llvm::opt::ArgStringList &CC1Args) const override;
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
Index: lib/Driver/ToolChains/Gnu.cpp
===================================================================
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2329,6 +2329,19 @@
   }
 }
 
+void Generic_GCC::addGnuIncludeArgs(const ArgList &DriverArgs, 
+                                    ArgStringList &CC1Args) const {
+  const Generic_GCC::GCCVersion &Version = GCCInstallation.getVersion();
+  if (!DriverArgs.hasArg(options::OPT_ffreestanding) &&
+      !DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) &&
+      !Version.isOlderThan(4, 8, 0)) {
+    // For gcc >= 4.8.x, gcc will preinclude <stdc-predef.h>
+    // -ffreestanding suppresses this behavior.
+    CC1Args.push_back("-include");
+    CC1Args.push_back("stdc-predef.h");
+  }
+}
+
 void Generic_GCC::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
                                                ArgStringList &CC1Args) const {
   if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
Index: lib/Driver/ToolChains/Linux.cpp
===================================================================
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -705,6 +705,8 @@
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
 
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
+
+  AddGnuIncludeArgs(DriverArgs, CC1Args);
 }
 
 static std::string DetectLibcxxIncludePath(StringRef base) {
@@ -743,6 +745,13 @@
   return "";
 }
 
+void Linux::AddGnuIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+                              llvm::opt::ArgStringList &CC1Args) const {
+  if (GCCInstallation.isValid())
+    addGnuIncludeArgs(DriverArgs, CC1Args);
+}
+
+
 void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
                                      llvm::opt::ArgStringList &CC1Args) const {
   // We need a detected GCC installation on Linux to provide libstdc++'s
Index: lib/Driver/ToolChains/Gnu.h
===================================================================
--- lib/Driver/ToolChains/Gnu.h
+++ lib/Driver/ToolChains/Gnu.h
@@ -325,6 +325,9 @@
                                 const llvm::opt::ArgList &DriverArgs,
                                 llvm::opt::ArgStringList &CC1Args) const;
 
+  void addGnuIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+                         llvm::opt::ArgStringList &CC1Args) const;
+
   /// @}
 
 private:
Index: unittests/Tooling/TestVisitor.h
===================================================================
--- unittests/Tooling/TestVisitor.h
+++ unittests/Tooling/TestVisitor.h
@@ -52,6 +52,7 @@
   /// \brief Runs the current AST visitor over the given code.
   bool runOver(StringRef Code, Language L = Lang_CXX) {
     std::vector<std::string> Args;
+    Args.push_back("-nostdinc");
     switch (L) {
       case Lang_C: Args.push_back("-std=c99"); break;
       case Lang_CXX98: Args.push_back("-std=c++98"); break;
Index: test/Driver/gcc-predef.c
===================================================================
--- test/Driver/gcc-predef.c
+++ test/Driver/gcc-predef.c
@@ -0,0 +1,42 @@
+// Test that gcc preincludes stdc-predef.h on Linux
+//
+// RUN: %clang -c %s --target=i686-unknown-gnu-linux \
+// RUN: -Wno-macro-redefined -D__GNUC__=4 -D__GNUC_MINOR__=7 \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree -Xclang -verify 
+// RUN: %clang -c -DFREESTANDING -ffreestanding %s \
+// RUN: -Wno-macro-redefined -D__GNUC__=4 -D__GNUC_MINOR__=7 \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree -Xclang -verify
+// RUN: %clang -c %s --target=i686-unknown-gnu-linux \
+// RUN: -Wno-macro-redefined -D__GNUC__=4 -D__GNUC_MINOR__=9 \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree -Xclang -verify 
+// RUN: %clang -c -DFREESTANDING -ffreestanding %s \
+// RUN: -Wno-macro-redefined -D__GNUC__=4 -D__GNUC_MINOR__=9 \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree -Xclang -verify
+// expected-no-diagnostics
+
+// Test 1: not freestanding
+#ifndef FREESTANDING
+#if defined( __GNUC__ )
+  #if __GNUC__ > 0 && (__GNUC__ < 4 || __GNUC__ == 4 && __GNUC_MINOR__ < 8)
+    /* Preinclude <stdc-predef.h> only for gcc 4.8 and higher */
+    #if defined( DUMMY_STDC_PREDEF )
+      #error "stdc-predef.h should not be preincluded for gcc < 4.8.x"
+    #endif
+  #else
+    #if !defined( DUMMY_STDC_PREDEF )
+      #error "stdc-predef.h should be preincluded for GNU/Linux 4.8 and higher"
+    #endif
+  #endif
+#endif
+
+// Test 2: freestanding
+#else
+  // Verify -ffreestanding option does not pre-include <stdc-predef.h>.
+  #if defined( DUMMY_STDC_PREDEF )
+    #error "stdc-predef.h should not be preincluded when -ffreestanding"
+  #endif
+#endif
Index: test/Driver/crash-report.c
===================================================================
--- test/Driver/crash-report.c
+++ test/Driver/crash-report.c
@@ -2,7 +2,7 @@
 // RUN: mkdir %t
 // RUN: not env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1              \
 // RUN:  CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1                         \
-// RUN:  %clang -fsyntax-only %s                                         \
+// RUN:  %clang -fsyntax-only -ffreestanding %s                          \
 // RUN:  -F/tmp/ -I /tmp/ -idirafter /tmp/ -iquote /tmp/ -isystem /tmp/  \
 // RUN:  -iprefix /the/prefix -iwithprefix /tmp -iwithprefixbefore /tmp/ \
 // RUN:  -Xclang -internal-isystem -Xclang /tmp/                         \
Index: test/Driver/Inputs/basic_linux_tree/usr/include/stdc-predef.h
===================================================================
--- test/Driver/Inputs/basic_linux_tree/usr/include/stdc-predef.h
+++ test/Driver/Inputs/basic_linux_tree/usr/include/stdc-predef.h
@@ -0,0 +1,6 @@
+#ifndef	_STDC_PREDEF_H
+#define	_STDC_PREDEF_H	1
+
+#define DUMMY_STDC_PREDEF 1
+
+#endif
Index: test/Driver/clang_cpp.c
===================================================================
--- test/Driver/clang_cpp.c
+++ test/Driver/clang_cpp.c
@@ -1,5 +1,5 @@
 // Verify that -include isn't included twice with -save-temps.
-// RUN: %clang -S -o - %s -include %t.h -save-temps -### 2> %t.log
+// RUN: %clang -ffreestanding -S -o - %s -include %t.h -save-temps -### 2> %t.log
 // RUN: FileCheck %s < %t.log
 // CHECK: "-include
 // CHECK-NOT: "-include
Index: test/Index/annotate-macro-args.m
===================================================================
--- test/Index/annotate-macro-args.m
+++ test/Index/annotate-macro-args.m
@@ -1,11 +1,11 @@
 // Test without PCH
-// RUN: c-index-test -test-annotate-tokens=%S/annotate-macro-args.h:9:1:10:1 %s -include %S/annotate-macro-args.h | FileCheck -check-prefix=CHECK1 %s
-// RUN: c-index-test -test-annotate-tokens=%S/annotate-macro-args.h:15:1:16:1 %s -include %S/annotate-macro-args.h | FileCheck -check-prefix=CHECK2 %s
+// RUN: c-index-test -test-annotate-tokens=%S/annotate-macro-args.h:9:1:10:1 -nostdinc  %s -include %S/annotate-macro-args.h | FileCheck -check-prefix=CHECK1 %s
+// RUN: c-index-test -test-annotate-tokens=%S/annotate-macro-args.h:15:1:16:1 -nostdinc  %s -include %S/annotate-macro-args.h | FileCheck -check-prefix=CHECK2 %s
 
 // Test with PCH
-// RUN: c-index-test -write-pch %t.pch -x objective-c-header %S/annotate-macro-args.h -Xclang -detailed-preprocessing-record
-// RUN: c-index-test -test-annotate-tokens=%S/annotate-macro-args.h:9:1:10:1 %s -include-pch %t.pch | FileCheck -check-prefix=CHECK1 %s
-// RUN: c-index-test -test-annotate-tokens=%S/annotate-macro-args.h:15:1:16:1 %s -include-pch %t.pch | FileCheck -check-prefix=CHECK2 %s
+// RUN: c-index-test -write-pch %t.pch -x objective-c-header %S/annotate-macro-args.h -Xclang -detailed-preprocessing-record -nostdinc
+// RUN: c-index-test -test-annotate-tokens=%S/annotate-macro-args.h:9:1:10:1 -nostdinc  %s -include-pch %t.pch | FileCheck -check-prefix=CHECK1 %s
+// RUN: c-index-test -test-annotate-tokens=%S/annotate-macro-args.h:15:1:16:1 -nostdinc  %s -include-pch %t.pch | FileCheck -check-prefix=CHECK2 %s
 
 // CHECK1: Identifier: "MACRO" [9:3 - 9:8] macro expansion=MACRO:6:9
 // CHECK1: Punctuation: "(" [9:8 - 9:9]
Index: test/Index/IBOutletCollection.m
===================================================================
--- test/Index/IBOutletCollection.m
+++ test/Index/IBOutletCollection.m
@@ -5,10 +5,10 @@
 }
 @end
 
-// RUN: c-index-test -cursor-at=%s:4:24 %s | FileCheck -check-prefix=CHECK-CURSOR %s
+// RUN: c-index-test -cursor-at=%s:4:24 -ffreestanding %s | FileCheck -check-prefix=CHECK-CURSOR %s
 // CHECK-CURSOR: ObjCClassRef=Test:3:12
 
-// RUN: c-index-test -test-annotate-tokens=%s:4:1:5:1 %s | FileCheck -check-prefix=CHECK-TOK %s
+// RUN: c-index-test -test-annotate-tokens=%s:4:1:5:1 -ffreestanding %s | FileCheck -check-prefix=CHECK-TOK %s
 // CHECK-TOK: Identifier: "IBOutletCollection" [4:3 - 4:21] macro expansion=IBOutletCollection:1:9
 // FIXME: The following token should belong to the macro expansion cursor.
 // CHECK-TOK: Punctuation: "(" [4:21 - 4:22] attribute(iboutletcollection)= [IBOutletCollection=ObjCInterface]
Index: test/Index/get-cursor.cpp
===================================================================
--- test/Index/get-cursor.cpp
+++ test/Index/get-cursor.cpp
@@ -145,71 +145,71 @@
 
 const int operator""_toint(unsigned long long val) { return int(val); }
 
-// RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s
+// RUN: c-index-test -cursor-at=%s:6:4 -ffreestanding %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s
 // CHECK-COMPLETION-1: CXXConstructor=X:6:3
 // CHECK-COMPLETION-1-NEXT: Completion string: {TypedText X}{LeftParen (}{Placeholder int}{Comma , }{Placeholder int}{RightParen )}
 
-// RUN: c-index-test -cursor-at=%s:31:16 %s | FileCheck -check-prefix=CHECK-COMPLETION-2 %s
+// RUN: c-index-test -cursor-at=%s:31:16 -ffreestanding %s | FileCheck -check-prefix=CHECK-COMPLETION-2 %s
 // CHECK-COMPLETION-2: CXXMethod=getAnotherX:31:5 (Definition)
 // CHECK-COMPLETION-2-NEXT: Completion string: {ResultType X}{TypedText getAnotherX}{LeftParen (}{RightParen )}
 
-// RUN: c-index-test -cursor-at=%s:12:20 %s | FileCheck -check-prefix=CHECK-VALUE-REF %s
-// RUN: c-index-test -cursor-at=%s:13:21 %s | FileCheck -check-prefix=CHECK-VALUE-REF %s
-// RUN: c-index-test -cursor-at=%s:13:28 %s | FileCheck -check-prefix=CHECK-VALUE-REF %s
-// RUN: c-index-test -cursor-at=%s:14:23 %s | FileCheck -check-prefix=CHECK-VALUE-REF %s
+// RUN: c-index-test -cursor-at=%s:12:20 -ffreestanding %s | FileCheck -check-prefix=CHECK-VALUE-REF %s
+// RUN: c-index-test -cursor-at=%s:13:21 -ffreestanding %s | FileCheck -check-prefix=CHECK-VALUE-REF %s
+// RUN: c-index-test -cursor-at=%s:13:28 -ffreestanding %s | FileCheck -check-prefix=CHECK-VALUE-REF %s
+// RUN: c-index-test -cursor-at=%s:14:23 -ffreestanding %s | FileCheck -check-prefix=CHECK-VALUE-REF %s
 // CHECK-VALUE-REF: DeclRefExpr=value:10:12
 
-// RUN: c-index-test -cursor-at=%s:12:18 %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR1 %s
-// RUN: c-index-test -cursor-at=%s:13:18 %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR2 %s
-// RUN: c-index-test -cursor-at=%s:14:19 %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR1 %s
-// RUN: c-index-test -cursor-at=%s:17:10 %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR3 %s
+// RUN: c-index-test -cursor-at=%s:12:18 -ffreestanding %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR1 %s
+// RUN: c-index-test -cursor-at=%s:13:18 -ffreestanding %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR2 %s
+// RUN: c-index-test -cursor-at=%s:14:19 -ffreestanding %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR1 %s
+// RUN: c-index-test -cursor-at=%s:17:10 -ffreestanding %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR3 %s
 // CHECK-TYPE-REF: TypeRef=struct X:3:8
 // CHECK-CONSTRUCTOR1: CallExpr=X:5:3
 // CHECK-CONSTRUCTOR2: CallExpr=X:6:3
 // CHECK-CONSTRUCTOR3: CallExpr=X:4:3
 
-// RUN: c-index-test -cursor-at=%s:23:3 %s | FileCheck -check-prefix=CHECK-RETTYPE %s
-// RUN: c-index-test -cursor-at=%s:26:1 %s | FileCheck -check-prefix=CHECK-RETTYPE %s
+// RUN: c-index-test -cursor-at=%s:23:3 -ffreestanding %s | FileCheck -check-prefix=CHECK-RETTYPE %s
+// RUN: c-index-test -cursor-at=%s:26:1 -ffreestanding %s | FileCheck -check-prefix=CHECK-RETTYPE %s
 // CHECK-RETTYPE: TypeRef=struct X:3:8
 
-// RUN: c-index-test -cursor-at=%s:23:7 %s | FileCheck -check-prefix=CHECK-MEMFUNC-DECL %s
+// RUN: c-index-test -cursor-at=%s:23:7 -ffreestanding %s | FileCheck -check-prefix=CHECK-MEMFUNC-DECL %s
 // CHECK-MEMFUNC-DECL: CXXMethod=getX:23:5
-// RUN: c-index-test -cursor-at=%s:26:7 %s | FileCheck -check-prefix=CHECK-MEMFUNC-DEF %s
+// RUN: c-index-test -cursor-at=%s:26:7 -ffreestanding %s | FileCheck -check-prefix=CHECK-MEMFUNC-DEF %s
 // CHECK-MEMFUNC-DEF: CXXMethod=getX:26:6
 
-// RUN: c-index-test -cursor-at=%s:26:3 %s | FileCheck -check-prefix=CHECK-TYPEREF-Y %s
+// RUN: c-index-test -cursor-at=%s:26:3 -ffreestanding %s | FileCheck -check-prefix=CHECK-TYPEREF-Y %s
 // CHECK-TYPEREF-Y: TypeRef=struct Y:20:8
 
-// RUN: c-index-test -cursor-at=%s:27:10 %s | FileCheck -check-prefix=CHECK-IMPLICIT-MEMREF %s
-// RUN: c-index-test -cursor-at=%s:31:28 %s | FileCheck -check-prefix=CHECK-IMPLICIT-MEMREF %s
+// RUN: c-index-test -cursor-at=%s:27:10 -ffreestanding %s | FileCheck -check-prefix=CHECK-IMPLICIT-MEMREF %s
+// RUN: c-index-test -cursor-at=%s:31:28 -ffreestanding %s | FileCheck -check-prefix=CHECK-IMPLICIT-MEMREF %s
 // CHECK-IMPLICIT-MEMREF: MemberRefExpr=member:21:7
 
-// RUN: c-index-test -cursor-at=%s:35:5 %s | FileCheck -check-prefix=CHECK-DECL %s
+// RUN: c-index-test -cursor-at=%s:35:5 -ffreestanding %s | FileCheck -check-prefix=CHECK-DECL %s
 // CHECK-DECL: VarDecl=foo:35:5
 
-// RUN: c-index-test -cursor-at=%s:21:3 %s | FileCheck -check-prefix=CHECK-MEMBER %s
+// RUN: c-index-test -cursor-at=%s:21:3 -ffreestanding %s | FileCheck -check-prefix=CHECK-MEMBER %s
 // CHECK-MEMBER: FieldDecl=member:21:7 (Definition)
 // CHECK-MEMBER-NEXT: Completion string: {ResultType int}{TypedText member}
 
-// RUN: c-index-test -cursor-at=%s:38:12 -cursor-at=%s:39:5 %s | FileCheck -check-prefix=CHECK-CXXCATCH %s
+// RUN: c-index-test -cursor-at=%s:38:12 -cursor-at=%s:39:5 -ffreestanding %s | FileCheck -check-prefix=CHECK-CXXCATCH %s
 // CHECK-CXXCATCH: TypeRef=struct X:3:8
 // CHECK-CXXCATCH-NEXT: TypeRef=struct X:3:8
 
-// RUN: c-index-test -test-load-source-usrs local %s | FileCheck -check-prefix=CHECK-USR %s
+// RUN: c-index-test -test-load-source-usrs local -ffreestanding %s | FileCheck -check-prefix=CHECK-USR %s
 // CHECK-USR: get-cursor.cpp c:get-cursor.cpp@472@F@test#@e Extent=[38:12 - 38:15]
 // CHECK-USR: get-cursor.cpp c:get-cursor.cpp@483@F@test#@x Extent=[39:5 - 39:8]
 
-// RUN: c-index-test -cursor-at=%s:45:9 %s | FileCheck -check-prefix=CHECK-LOCALCLASS %s
+// RUN: c-index-test -cursor-at=%s:45:9 -ffreestanding %s | FileCheck -check-prefix=CHECK-LOCALCLASS %s
 // CHECK-LOCALCLASS: 45:9 DeclRefExpr=x:44:11 Extent=[45:9 - 45:10] Spelling=x ([45:9 - 45:10])
 
-// RUN: c-index-test -cursor-at=%s:50:23 -cursor-at=%s:55:23 %s | FileCheck -check-prefix=CHECK-TEMPLPARAM %s
+// RUN: c-index-test -cursor-at=%s:50:23 -cursor-at=%s:55:23 -ffreestanding %s | FileCheck -check-prefix=CHECK-TEMPLPARAM %s
 // CHECK-TEMPLPARAM: 50:23 TypeRef=struct X:3:8 Extent=[50:23 - 50:24] Spelling=struct X ([50:23 - 50:24])
 // CHECK-TEMPLPARAM: 55:23 TypeRef=struct X:3:8 Extent=[55:23 - 55:24] Spelling=struct X ([55:23 - 55:24])
 
-// RUN: c-index-test -cursor-at=%s:66:23 %s | FileCheck -check-prefix=CHECK-TEMPLSPEC %s
+// RUN: c-index-test -cursor-at=%s:66:23 -ffreestanding %s | FileCheck -check-prefix=CHECK-TEMPLSPEC %s
 // CHECK-TEMPLSPEC: 66:23 ClassDecl=TC:66:23 (Definition) [Specialization of TC:59:7] Extent=[66:1 - 66:31] Spelling=TC ([66:23 - 66:25])
 
-// RUN: c-index-test -cursor-at=%s:69:3 -cursor-at=%s:70:11 -cursor-at=%s:73:6 -cursor-at=%s:74:6 -cursor-at=%s:77:8 -cursor-at=%s:78:8 -cursor-at=%s:79:8 -cursor-at=%s:80:8 -cursor-at=%s:81:8 -cursor-at=%s:82:8 -cursor-at=%s:85:6 -cursor-at=%s:86:6 -cursor-at=%s:87:6 -cursor-at=%s:88:6 -cursor-at=%s:91:5 -cursor-at=%s:92:5 -cursor-at=%s:93:5 -cursor-at=%s:94:5 -cursor-at=%s:95:5 -cursor-at=%s:96:5 -cursor-at=%s:97:5 -cursor-at=%s:98:5 -cursor-at=%s:100:5 -cursor-at=%s:101:5 -cursor-at=%s:104:6 -cursor-at=%s:105:6 -cursor-at=%s:106:6 -cursor-at=%s:107:6 -cursor-at=%s:108:6 -cursor-at=%s:109:6 -cursor-at=%s:110:6 -cursor-at=%s:111:6 -cursor-at=%s:113:6 -cursor-at=%s:114:6 -cursor-at=%s:117:8 -cursor-at=%s:118:8 -cursor-at=%s:120:8 -cursor-at=%s:121:8 -cursor-at=%s:122:8 -cursor-at=%s:123:8 -cursor-at=%s:124:8 -cursor-at=%s:125:8 -cursor-at=%s:128:6 -cursor-at=%s:129:6 -cursor-at=%s:130:6 -cursor-at=%s:132:3 -cursor-at=%s:146:15 -std=c++11 %s | FileCheck -check-prefix=CHECK-SPELLING %s
+// RUN: c-index-test -cursor-at=%s:69:3 -cursor-at=%s:70:11 -cursor-at=%s:73:6 -cursor-at=%s:74:6 -cursor-at=%s:77:8 -cursor-at=%s:78:8 -cursor-at=%s:79:8 -cursor-at=%s:80:8 -cursor-at=%s:81:8 -cursor-at=%s:82:8 -cursor-at=%s:85:6 -cursor-at=%s:86:6 -cursor-at=%s:87:6 -cursor-at=%s:88:6 -cursor-at=%s:91:5 -cursor-at=%s:92:5 -cursor-at=%s:93:5 -cursor-at=%s:94:5 -cursor-at=%s:95:5 -cursor-at=%s:96:5 -cursor-at=%s:97:5 -cursor-at=%s:98:5 -cursor-at=%s:100:5 -cursor-at=%s:101:5 -cursor-at=%s:104:6 -cursor-at=%s:105:6 -cursor-at=%s:106:6 -cursor-at=%s:107:6 -cursor-at=%s:108:6 -cursor-at=%s:109:6 -cursor-at=%s:110:6 -cursor-at=%s:111:6 -cursor-at=%s:113:6 -cursor-at=%s:114:6 -cursor-at=%s:117:8 -cursor-at=%s:118:8 -cursor-at=%s:120:8 -cursor-at=%s:121:8 -cursor-at=%s:122:8 -cursor-at=%s:123:8 -cursor-at=%s:124:8 -cursor-at=%s:125:8 -cursor-at=%s:128:6 -cursor-at=%s:129:6 -cursor-at=%s:130:6 -cursor-at=%s:132:3 -cursor-at=%s:146:15 -std=c++11 -ffreestanding %s | FileCheck -check-prefix=CHECK-SPELLING %s
 // CHECK-SPELLING: 69:3 CXXConstructor=A:69:3 (default constructor) Extent=[69:3 - 69:6] Spelling=A ([69:3 - 69:4])
 // CHECK-SPELLING: 70:11 CXXDestructor=~A:70:11 (virtual) Extent=[70:3 - 70:15] Spelling=~A ([70:11 - 70:13])
 // CHECK-SPELLING: 73:6 CXXMethod=operator=:73:6 Extent=[73:3 - 73:25] Spelling=operator= ([73:6 - 73:15])
@@ -258,7 +258,7 @@
 // CHECK-SPELLING: 132:12 CXXConversion=operator bool:132:12 (const) Extent=[132:3 - 132:33] Spelling=operator bool ([132:12 - 132:25])
 // CHECK-SPELLING: 146:11 FunctionDecl=operator""_toint:146:11 (Definition) Extent=[146:1 - 146:72] Spelling=operator""_toint ([146:11 - 146:27])
 
-// RUN: c-index-test -cursor-at=%s:141:13 -cursor-at=%s:141:18 -cursor-at=%s:142:11 -std=c++11 %s | FileCheck -check-prefix=CHECK-FORRANGE %s
+// RUN: c-index-test -cursor-at=%s:141:13 -cursor-at=%s:141:18 -cursor-at=%s:142:11 -std=c++11 -ffreestanding %s | FileCheck -check-prefix=CHECK-FORRANGE %s
 // CHECK-FORRANGE: 141:13 VarDecl=lv:141:13 (Definition) Extent=[141:8 - 141:17] Spelling=lv ([141:13 - 141:15])
 // CHECK-FORRANGE: 141:18 DeclRefExpr=coll:140:20 Extent=[141:18 - 141:22] Spelling=coll ([141:18 - 141:22])
 // CHECK-FORRANGE: 142:11 DeclRefExpr=lv:141:13 Extent=[142:11 - 142:13] Spelling=lv ([142:11 - 142:13])
Index: test/Index/c-index-getCursor-test.m
===================================================================
--- test/Index/c-index-getCursor-test.m
+++ test/Index/c-index-getCursor-test.m
@@ -1,4 +1,4 @@
-// RUN: c-index-test -write-pch %t.ast -arch x86_64 -mmacosx-version-min=10.6 -fblocks -x objective-c %s
+// RUN: c-index-test -write-pch %t.ast -arch x86_64 -mmacosx-version-min=10.6 -fblocks -x objective-c -nostdinc %s
 // RUN: c-index-test -test-file-scan %t.ast %s > %t 2>&1 && FileCheck --input-file=%t %s
 @interface Foo 
 {
Index: test/Index/annotate-tokens.c
===================================================================
--- test/Index/annotate-tokens.c
+++ test/Index/annotate-tokens.c
@@ -68,7 +68,7 @@
   reg.field = 1;
 }
 
-// RUN: c-index-test -test-annotate-tokens=%s:4:1:37:1 %s | FileCheck %s
+// RUN: c-index-test -test-annotate-tokens=%s:4:1:37:1 -ffreestanding %s | FileCheck %s
 // CHECK: Identifier: "T" [4:3 - 4:4] TypeRef=T:1:13
 // CHECK: Punctuation: "*" [4:4 - 4:5] VarDecl=t_ptr:4:6 (Definition)
 // CHECK: Identifier: "t_ptr" [4:6 - 4:11] VarDecl=t_ptr:4:6 (Definition)
@@ -191,10 +191,10 @@
 // CHECK: Punctuation: ")" [36:97 - 36:98] FunctionDecl=test:36:63 (unavailable)  (always unavailable: "")
 // CHECK: Punctuation: ";" [36:98 - 36:99]
 
-// RUN: c-index-test -test-annotate-tokens=%s:4:1:165:32 %s | FileCheck %s
-// RUN: c-index-test -test-annotate-tokens=%s:4:1:165:38 %s | FileCheck %s
+// RUN: c-index-test -test-annotate-tokens=%s:4:1:165:32 -ffreestanding %s | FileCheck %s
+// RUN: c-index-test -test-annotate-tokens=%s:4:1:165:38 -ffreestanding %s | FileCheck %s
 
-// RUN: c-index-test -test-annotate-tokens=%s:50:1:55:1 %s | FileCheck %s -check-prefix=CHECK-RANGE1
+// RUN: c-index-test -test-annotate-tokens=%s:50:1:55:1 -ffreestanding %s | FileCheck %s -check-prefix=CHECK-RANGE1
 // CHECK-RANGE1: Keyword: "void" [50:1 - 50:5] FunctionDecl=func1:50:6
 // CHECK-RANGE1: Identifier: "func1" [50:6 - 50:11] FunctionDecl=func1:50:6
 // CHECK-RANGE1: Punctuation: "(" [50:11 - 50:12] FunctionDecl=func1:50:6
@@ -216,7 +216,7 @@
 // CHECK-RANGE1: Literal: "1" [54:10 - 54:11] IntegerLiteral=
 // CHECK-RANGE1: Punctuation: "," [54:11 - 54:12] InitListExpr=
 
-// RUN: c-index-test -test-annotate-tokens=%s:54:1:70:1 %s | FileCheck %s -check-prefix=CHECK-RANGE2
+// RUN: c-index-test -test-annotate-tokens=%s:54:1:70:1 -ffreestanding %s | FileCheck %s -check-prefix=CHECK-RANGE2
 // CHECK-RANGE2: Punctuation: "." [54:5 - 54:6] UnexposedExpr=
 // CHECK-RANGE2: Identifier: "y" [54:6 - 54:7] MemberRef=y:52:1
 // CHECK-RANGE2: Punctuation: "=" [54:8 - 54:9] UnexposedExpr=
@@ -240,6 +240,6 @@
 // CHECK-RANGE2: Punctuation: "." [68:6 - 68:7] MemberRefExpr=field:62:9
 // CHECK-RANGE2: Identifier: "field" [68:7 - 68:12] MemberRefExpr=field:62:9
 
-// RUN: c-index-test -test-annotate-tokens=%s:68:15:68:16 %s | FileCheck %s -check-prefix=CHECK-RANGE3
+// RUN: c-index-test -test-annotate-tokens=%s:68:15:68:16 -ffreestanding %s | FileCheck %s -check-prefix=CHECK-RANGE3
 // CHECK-RANGE3: Literal: "1" [68:15 - 68:16] IntegerLiteral=
 // CHECK-RANGE3-NOT: Punctuation: ";"
Index: test/Index/annotate-tokens-pp.c
===================================================================
--- test/Index/annotate-tokens-pp.c
+++ test/Index/annotate-tokens-pp.c
@@ -42,8 +42,8 @@
 #endif
 };
 
-// RUN: c-index-test -test-annotate-tokens=%s:2:1:44:1 -I%S/Inputs %s | FileCheck %s
-// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-annotate-tokens=%s:2:1:44:1 -I%S/Inputs %s | FileCheck %s
+// RUN: c-index-test -test-annotate-tokens=%s:2:1:44:1 -I%S/Inputs -ffreestanding %s | FileCheck %s
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-annotate-tokens=%s:2:1:44:1 -I%S/Inputs -ffreestanding %s | FileCheck %s
 // CHECK: Punctuation: "#" [2:1 - 2:2] preprocessing directive=
 // CHECK: Identifier: "define" [2:2 - 2:8] preprocessing directive=
 // CHECK: Identifier: "STILL_NOTHING" [2:9 - 2:22] macro definition=STILL_NOTHING
Index: test/Index/get-cursor-macro-args.m
===================================================================
--- test/Index/get-cursor-macro-args.m
+++ test/Index/get-cursor-macro-args.m
@@ -5,17 +5,17 @@
 // RUN:              -cursor-at=%S/get-cursor-macro-args.h:9:22 \
 // RUN:              -cursor-at=%S/get-cursor-macro-args.h:15:12 \
 // RUN:              -cursor-at=%S/get-cursor-macro-args.h:15:20 \
-// RUN:       %s -include %S/get-cursor-macro-args.h | FileCheck %s
+// RUN:       -nostdinc %s -include %S/get-cursor-macro-args.h | FileCheck %s
 
 // Test with PCH
-// RUN: c-index-test -write-pch %t.pch -x objective-c-header %S/get-cursor-macro-args.h
+// RUN: c-index-test -write-pch %t.pch -x objective-c-header -nostdinc %S/get-cursor-macro-args.h
 // RUN: c-index-test -cursor-at=%S/get-cursor-macro-args.h:9:12 \
 // RUN:              -cursor-at=%S/get-cursor-macro-args.h:9:21 \
 // RUN:              -cursor-at=%S/get-cursor-macro-args.h:9:9 \
 // RUN:              -cursor-at=%S/get-cursor-macro-args.h:9:22 \
 // RUN:              -cursor-at=%S/get-cursor-macro-args.h:15:12 \
 // RUN:              -cursor-at=%S/get-cursor-macro-args.h:15:20 \
-// RUN:       %s -include-pch %t.pch | FileCheck %s
+// RUN:       -nostdinc %s -include-pch %t.pch | FileCheck %s
 
 // CHECK:      ObjCClassRef=MyClass:1:12
 // CHECK-NEXT: ObjCMessageExpr=meth:2:8
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to