summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-07-01 22:24:56 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-07-01 22:24:56 +0000
commitf607234fde4ccbdd0899a1ea92703e720dd83a22 (patch)
tree89c5bf97108475f199b5dc370c950a9cb97fb5dd /clang/test
parent6433f7c84d68039000785d818b2f139354a26f8c (diff)
downloadbcm5719-llvm-f607234fde4ccbdd0899a1ea92703e720dd83a22.tar.gz
bcm5719-llvm-f607234fde4ccbdd0899a1ea92703e720dd83a22.zip
Driver: Handle /GR- in a compatible way with MSVC
There are slight differences between /GR- and -fno-rtti which made mapping one to the other inappropriate. -fno-rtti disables dynamic_cast, typeid, and does not emit RTTI related information for the v-table. /GR- does not generate complete object locators and thus will not reference them in vftables. However, constructs like dynamic_cast and typeid are permitted. This should bring our implementation of RTTI up to semantic parity with MSVC modulo bugs. llvm-svn: 212138
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CodeGenCXX/microsoft-no-rtti-data.cpp21
-rw-r--r--clang/test/Driver/cl-fallback.c9
-rw-r--r--clang/test/Driver/cl-options.c8
3 files changed, 31 insertions, 7 deletions
diff --git a/clang/test/CodeGenCXX/microsoft-no-rtti-data.cpp b/clang/test/CodeGenCXX/microsoft-no-rtti-data.cpp
new file mode 100644
index 00000000000..015b7e69a8d
--- /dev/null
+++ b/clang/test/CodeGenCXX/microsoft-no-rtti-data.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -fno-rtti-data -triple=i386-pc-win32 -o - -emit-llvm | FileCheck %s
+
+// vftable shouldn't have RTTI data in it.
+// CHECK: @"\01??_7S@@6B@" = linkonce_odr unnamed_addr constant [1 x i8*] [i8* bitcast ({{.*}} @"\01??_GS@@UAEPAXI@Z" to i8*)]
+
+struct type_info;
+namespace std { using ::type_info; }
+
+struct S {
+ virtual ~S();
+} s;
+
+struct U : S {
+ virtual ~U();
+};
+
+extern S *getS();
+
+const std::type_info &ti = typeid(*getS());
+const U &u = dynamic_cast<U &>(*getS());
+// CHECK: call i8* @__RTDynamicCast(i8* %0, i32 0, i8* bitcast ({{.*}} @"\01??_R0?AUS@@@8" to i8*), i8* bitcast ({{.*}} @"\01??_R0?AUU@@@8" to i8*), i32 1)
diff --git a/clang/test/Driver/cl-fallback.c b/clang/test/Driver/cl-fallback.c
index 99cf627f7bd..bbc9ad84d6f 100644
--- a/clang/test/Driver/cl-fallback.c
+++ b/clang/test/Driver/cl-fallback.c
@@ -31,6 +31,10 @@
// CHECK: "/Tc" "{{.*cl-fallback.c}}"
// CHECK: "/Fo{{.*cl-fallback.*.obj}}"
+// RUN: %clang_cl /fallback /GR- -### -- %s 2>&1 | FileCheck -check-prefix=GR %s
+// GR: cl.exe
+// GR: "/GR-"
+
// RUN: %clang_cl /fallback /Od -### -- %s 2>&1 | FileCheck -check-prefix=O0 %s
// O0: cl.exe
// O0: "/Od"
@@ -56,15 +60,12 @@
// RUN: FileCheck -check-prefix=ErrWarn %s
// ErrWarn: warning: falling back to {{.*}}cl.exe
-// Don't attempt to run clang -cc1 with /fallback and /GR. It isn't ready yet.
-// RUN: %clang_cl /fallback /c /GR -### -- %s 2>&1 | \
-// RUN: FileCheck -check-prefix=RTTI %s
-// RTTI: warning: cannot compile RTTI yet, falling back to {{.*}}cl.exe
// RUN: %clang_cl /fallback /c /GR /GR- -### -- %s 2>&1 | \
// RUN: FileCheck -check-prefix=NO_RTTI %s
// NO_RTTI: "-cc1"
// NO_RTTI: ||
// NO_RTTI: cl.exe
+// NO_RTTI: "/GR-"
// Don't fall back on non-C or C++ files.
// RUN: %clang_cl /fallback -### -- %S/Inputs/file.ll 2>&1 | FileCheck -check-prefix=LL %s
diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index cd98ec3b72f..90b63259feb 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -289,10 +289,12 @@
// RUN: %clang_cl /Zs /WX -m32 -m64 -### -- 2>&1 %s | FileCheck -check-prefix=MFLAGS %s
// MFLAGS-NOT: argument unused during compilation
-// Use -fno-rtti by default.
-// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
-// NoRTTI: "-fno-rtti"
+// RTTI is on by default. /GR- controls -fno-rtti-data.
+// RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
+// NoRTTI: "-fno-rtti-data"
+// NoRTTI-NOT: "-fno-rtti"
// RUN: %clang_cl /c /GR -### -- %s 2>&1 | FileCheck -check-prefix=RTTI %s
+// RTTI-NOT: "-fno-rtti-data"
// RTTI-NOT: "-fno-rtti"
OpenPOWER on IntegriCloud