소스 검색

[clang][IFS] Escape mangled names so MS ABI doesn't break YAML parsing.

Microsoft's ABI mangles names differently than Itanium and this breaks the LLVM
yaml parser unless the name is escaped in quotes. Quotes are being added to the
mangled names of the IFS file generation so that llvm-ifs doesn't break when
Windows triples are passed to the driver.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374798 91177308-0d34-0410-b5e6-96231b3b80d8
Puyan Lotfi 5 년 전
부모
커밋
eec4f9b8c3
4개의 변경된 파일12개의 추가작업 그리고 5개의 파일을 삭제
  1. 2 2
      lib/Frontend/InterfaceStubFunctionsConsumer.cpp
  2. 2 2
      test/InterfaceStubs/inline.c
  3. 1 1
      test/InterfaceStubs/object.c
  4. 7 0
      test/InterfaceStubs/windows.cpp

+ 2 - 2
lib/Frontend/InterfaceStubFunctionsConsumer.cpp

@@ -263,11 +263,11 @@ public:
       for (const auto &E : Symbols) {
       for (const auto &E : Symbols) {
         const MangledSymbol &Symbol = E.second;
         const MangledSymbol &Symbol = E.second;
         for (auto Name : Symbol.Names) {
         for (auto Name : Symbol.Names) {
-          OS << "  "
+          OS << "  \""
              << (Symbol.ParentName.empty() || Instance.getLangOpts().CPlusPlus
              << (Symbol.ParentName.empty() || Instance.getLangOpts().CPlusPlus
                      ? ""
                      ? ""
                      : (Symbol.ParentName + "."))
                      : (Symbol.ParentName + "."))
-             << Name << ": { Type: ";
+             << Name << "\" : { Type: ";
           switch (Symbol.Type) {
           switch (Symbol.Type) {
           default:
           default:
             llvm_unreachable(
             llvm_unreachable(

+ 2 - 2
test/InterfaceStubs/inline.c

@@ -56,8 +56,8 @@ INLINE int foo() {
 // RUN: -c -std=gnu89 -xc %s | llvm-nm - 2>&1 | \
 // RUN: -c -std=gnu89 -xc %s | llvm-nm - 2>&1 | \
 // RUN: FileCheck -check-prefix=CHECK-SYMBOLS %s
 // RUN: FileCheck -check-prefix=CHECK-SYMBOLS %s
 
 
-// CHECK-TAPI-DAG: foo: { Type: Func }
-// CHECK-TAPI-DAG: foo.var: { Type: Object, Size: 4 }
+// CHECK-TAPI-DAG: "foo" : { Type: Func }
+// CHECK-TAPI-DAG: "foo.var" : { Type: Object, Size: 4 }
 // CHECK-SYMBOLS-DAG: foo
 // CHECK-SYMBOLS-DAG: foo
 // CHECK-SYMBOLS-DAG: foo.var
 // CHECK-SYMBOLS-DAG: foo.var
 #include "inline.h"
 #include "inline.h"

+ 1 - 1
test/InterfaceStubs/object.c

@@ -2,6 +2,6 @@
 // RUN: %clang -fvisibility=default -c -o - -emit-interface-stubs %s | FileCheck -check-prefix=CHECK-SYMBOLS %s
 // RUN: %clang -fvisibility=default -c -o - -emit-interface-stubs %s | FileCheck -check-prefix=CHECK-SYMBOLS %s
 // RUN: %clang -fvisibility=default -c -o - %s | llvm-nm - 2>&1 | FileCheck -check-prefix=CHECK-SYMBOLS %s
 // RUN: %clang -fvisibility=default -c -o - %s | llvm-nm - 2>&1 | FileCheck -check-prefix=CHECK-SYMBOLS %s
 
 
-// CHECK-TAPI: data: { Type: Object, Size: 4 }
+// CHECK-TAPI: "data" : { Type: Object, Size: 4 }
 // CHECK-SYMBOLS: data
 // CHECK-SYMBOLS: data
 int data = 42;
 int data = 42;

+ 7 - 0
test/InterfaceStubs/windows.cpp

@@ -0,0 +1,7 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang -target x86_64-windows-msvc -o - %s \
+// RUN: -emit-interface-stubs -emit-merged-ifs | FileCheck %s
+
+// CHECK: Symbols:
+// CHECK-NEXT: ?helloWindowsMsvc@@YAHXZ
+int helloWindowsMsvc();