Skip to content

Commit 76f9869

Browse files
committed
[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 llvm-svn: 374798
1 parent c86ba58 commit 76f9869

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,11 @@ class InterfaceStubFunctionsConsumer : public ASTConsumer {
263263
for (const auto &E : Symbols) {
264264
const MangledSymbol &Symbol = E.second;
265265
for (auto Name : Symbol.Names) {
266-
OS << " "
266+
OS << " \""
267267
<< (Symbol.ParentName.empty() || Instance.getLangOpts().CPlusPlus
268268
? ""
269269
: (Symbol.ParentName + "."))
270-
<< Name << ": { Type: ";
270+
<< Name << "\" : { Type: ";
271271
switch (Symbol.Type) {
272272
default:
273273
llvm_unreachable(

clang/test/InterfaceStubs/inline.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ INLINE int foo() {
5656
// RUN: -c -std=gnu89 -xc %s | llvm-nm - 2>&1 | \
5757
// RUN: FileCheck -check-prefix=CHECK-SYMBOLS %s
5858

59-
// CHECK-TAPI-DAG: foo: { Type: Func }
60-
// CHECK-TAPI-DAG: foo.var: { Type: Object, Size: 4 }
59+
// CHECK-TAPI-DAG: "foo" : { Type: Func }
60+
// CHECK-TAPI-DAG: "foo.var" : { Type: Object, Size: 4 }
6161
// CHECK-SYMBOLS-DAG: foo
6262
// CHECK-SYMBOLS-DAG: foo.var
6363
#include "inline.h"

clang/test/InterfaceStubs/object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
// RUN: %clang -fvisibility=default -c -o - -emit-interface-stubs %s | FileCheck -check-prefix=CHECK-SYMBOLS %s
33
// RUN: %clang -fvisibility=default -c -o - %s | llvm-nm - 2>&1 | FileCheck -check-prefix=CHECK-SYMBOLS %s
44

5-
// CHECK-TAPI: data: { Type: Object, Size: 4 }
5+
// CHECK-TAPI: "data" : { Type: Object, Size: 4 }
66
// CHECK-SYMBOLS: data
77
int data = 42;

clang/test/InterfaceStubs/windows.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// REQUIRES: x86-registered-target
2+
// RUN: %clang -target x86_64-windows-msvc -o - %s \
3+
// RUN: -emit-interface-stubs -emit-merged-ifs | FileCheck %s
4+
5+
// CHECK: Symbols:
6+
// CHECK-NEXT: ?helloWindowsMsvc@@YAHXZ
7+
int helloWindowsMsvc();

0 commit comments

Comments
 (0)