]> granicus.if.org Git - clang/commitdiff
[frontend] Don't include the C++ stdlib for -x assembler-with-cpp
authorAlex Lorenz <arphaman@gmail.com>
Thu, 28 Jun 2018 23:23:45 +0000 (23:23 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Thu, 28 Jun 2018 23:23:45 +0000 (23:23 +0000)
The new C++ stdlib warning added in r335081 gets
triggered when compiling an assembly file with -x assembler-with-cpp.
This commit ensures that the C++ stdlib is not included when compiling assembly.
In general, it's not really useful to include the C++ stdlib search path when
compiling assembly source.

rdar://41359632

Differential Revision: https://reviews.llvm.org/D48736

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335940 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/InitHeaderSearch.cpp
test/Frontend/nostdlib-for-asmpp.s [new file with mode: 0644]

index 85aeec461ba69920be834deb1c6518c75e097f9f..8a70404629d366334676d7fb21d1a6da55979f6d 100644 (file)
@@ -470,8 +470,8 @@ void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
     break;
   }
 
-  if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes &&
-      HSOpts.UseStandardSystemIncludes) {
+  if (Lang.CPlusPlus && !Lang.AsmPreprocessor &&
+      HSOpts.UseStandardCXXIncludes && HSOpts.UseStandardSystemIncludes) {
     if (HSOpts.UseLibcxx) {
       if (triple.isOSDarwin()) {
         // On Darwin, libc++ may be installed alongside the compiler in
diff --git a/test/Frontend/nostdlib-for-asmpp.s b/test/Frontend/nostdlib-for-asmpp.s
new file mode 100644 (file)
index 0000000..330fee3
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: %clang -cc1 -x assembler-with-cpp -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist -std=c++11 -v %s 2>&1 | FileCheck %s
+// The C++ stdlib path should not be included for an assembly source.
+
+// CHECK-NOT: usr/include/c++/
+// CHECK-NOT: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead