r244922 - Turn off __has_feature(cxx_rtti) when -fno-rtti-data is present
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 13 10:56:49 PDT 2015
Author: rnk
Date: Thu Aug 13 12:56:49 2015
New Revision: 244922
URL: http://llvm.org/viewvc/llvm-project?rev=244922&view=rev
Log:
Turn off __has_feature(cxx_rtti) when -fno-rtti-data is present
-fno-rtti-data makes it so that vtables emitted in the current TU lack
RTTI data. This means that dynamic_cast usually fails at runtime. Users
of the existing cxx_rtti feature expect all of RTTI to work, not just
some of it.
Chromium bug for context: http://crbug.com/518191
Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/Lexer/has_feature_rtti.cpp
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=244922&r1=244921&r2=244922&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Thu Aug 13 12:56:49 2015
@@ -1076,7 +1076,7 @@ static bool HasFeature(const Preprocesso
.Case("blocks", LangOpts.Blocks)
.Case("c_thread_safety_attributes", true)
.Case("cxx_exceptions", LangOpts.CXXExceptions)
- .Case("cxx_rtti", LangOpts.RTTI)
+ .Case("cxx_rtti", LangOpts.RTTI && LangOpts.RTTIData)
.Case("enumerator_attributes", true)
.Case("nullability", true)
.Case("memory_sanitizer", LangOpts.Sanitize.has(SanitizerKind::Memory))
Modified: cfe/trunk/test/Lexer/has_feature_rtti.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_rtti.cpp?rev=244922&r1=244921&r2=244922&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/has_feature_rtti.cpp (original)
+++ cfe/trunk/test/Lexer/has_feature_rtti.cpp Thu Aug 13 12:56:49 2015
@@ -1,5 +1,6 @@
// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-RTTI %s
// RUN: %clang_cc1 -E -fno-rtti %s -o - | FileCheck --check-prefix=CHECK-NO-RTTI %s
+// RUN: %clang_cc1 -E -fno-rtti-data %s -o - | FileCheck --check-prefix=CHECK-NO-RTTI %s
#if __has_feature(cxx_rtti)
int foo();
More information about the cfe-commits
mailing list