From 76f9869bf20034d5d722d29999e845a1f9c0505d Mon Sep 17 00:00:00 2001 From: Puyan Lotfi Date: Mon, 14 Oct 2019 18:03:03 +0000 Subject: [PATCH] [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 --- clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp | 4 ++-- clang/test/InterfaceStubs/inline.c | 4 ++-- clang/test/InterfaceStubs/object.c | 2 +- clang/test/InterfaceStubs/windows.cpp | 7 +++++++ 4 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 clang/test/InterfaceStubs/windows.cpp diff --git a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp index 5ce7a36..0b28b78 100644 --- a/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp +++ b/clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp @@ -263,11 +263,11 @@ public: for (const auto &E : Symbols) { const MangledSymbol &Symbol = E.second; for (auto Name : Symbol.Names) { - OS << " " + OS << " \"" << (Symbol.ParentName.empty() || Instance.getLangOpts().CPlusPlus ? "" : (Symbol.ParentName + ".")) - << Name << ": { Type: "; + << Name << "\" : { Type: "; switch (Symbol.Type) { default: llvm_unreachable( diff --git a/clang/test/InterfaceStubs/inline.c b/clang/test/InterfaceStubs/inline.c index 06a58c4..6f0cb51 100644 --- a/clang/test/InterfaceStubs/inline.c +++ b/clang/test/InterfaceStubs/inline.c @@ -56,8 +56,8 @@ INLINE int foo() { // RUN: -c -std=gnu89 -xc %s | llvm-nm - 2>&1 | \ // 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.var #include "inline.h" diff --git a/clang/test/InterfaceStubs/object.c b/clang/test/InterfaceStubs/object.c index 774b79d..0687e2c 100644 --- a/clang/test/InterfaceStubs/object.c +++ b/clang/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 - %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 int data = 42; diff --git a/clang/test/InterfaceStubs/windows.cpp b/clang/test/InterfaceStubs/windows.cpp new file mode 100644 index 0000000..5bf5a68 --- /dev/null +++ b/clang/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(); -- 2.7.4