[PATCH] D48736: [frontend] Don't include the C++ stdlib for -x assembler-with-cpp

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 28 12:33:59 PDT 2018


arphaman created this revision.
arphaman added a reviewer: bruno.
Herald added a subscriber: dexonsmith.

The new C++ stdlib warning added in https://reviews.llvm.org/D48297 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.


Repository:
  rC Clang

https://reviews.llvm.org/D48736

Files:
  lib/Frontend/InitHeaderSearch.cpp
  test/Frontend/nostdlib-for-asmpp.s


Index: test/Frontend/nostdlib-for-asmpp.s
===================================================================
--- /dev/null
+++ test/Frontend/nostdlib-for-asmpp.s
@@ -0,0 +1,5 @@
+// RUN: %clang -cc1 -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
Index: lib/Frontend/InitHeaderSearch.cpp
===================================================================
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -470,8 +470,8 @@
     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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48736.153368.patch
Type: text/x-patch
Size: 1127 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180628/6dfb38d0/attachment.bin>


More information about the cfe-commits mailing list