From: Reid Kleckner Date: Thu, 13 Aug 2015 17:56:49 +0000 (+0000) Subject: Turn off __has_feature(cxx_rtti) when -fno-rtti-data is present X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1e1a99ea87f52cf6a14f5fa08a44451a45ddd2ac;p=clang 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244922 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index 42b1d048c4..594365b45e 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -1076,7 +1076,7 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) { .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)) diff --git a/test/Lexer/has_feature_rtti.cpp b/test/Lexer/has_feature_rtti.cpp index 4bfeead329..26eaa2ead6 100644 --- a/test/Lexer/has_feature_rtti.cpp +++ b/test/Lexer/has_feature_rtti.cpp @@ -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();