[Lldb-commits] [lldb] r320778 - [ExpressionParser] Fix evaluation failures due to mismatch in C++ versions.

Davide Italiano via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 14 16:50:43 PST 2017


Author: davide
Date: Thu Dec 14 16:50:43 2017
New Revision: 320778

URL: http://llvm.org/viewvc/llvm-project?rev=320778&view=rev
Log:
[ExpressionParser] Fix evaluation failures due to mismatch in C++ versions.

Clang recently switched to C++14 (with GNU extensions) as the default
dialect, but LLDB didn't catch up. This causes failures as LLDB still
evaluates ObjectiveC expressions as Objective C++ using C++98 as standard.

There are things not available in C++98, including, e.g. nullptr.
In some cases Objective-C `nil` is defined as `nullptr` so this causes
an evaluation failure. Switch the default to overcome this issue
(actually, currently lldb evaluates both C++11 and C++14 as C++11,
but that seems a larger change and definitely could be re-evaluated
in the future).

No test as this is currently failing on the LLDB bots after the clang
switch (so, de facto, there's a test already for it).

This is a recommit, with a thinko fixed (the code was previously
placed incorrectly).

<rdar://problem/36011995>

Modified:
    lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=320778&r1=320777&r2=320778&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Thu Dec 14 16:50:43 2017
@@ -389,6 +389,14 @@ ClangExpressionParser::ClangExpressionPa
     // FIXME: the following language option is a temporary workaround,
     // to "ask for ObjC, get ObjC++" (see comment above).
     m_compiler->getLangOpts().CPlusPlus = true;
+
+    // Clang now sets as default C++14 as the default standard (with
+    // GNU extensions), so we do the same here to avoid mismatches that
+    // cause compiler error when evaluating expressions (e.g. nullptr
+    // not found as it's a C++11 feature). Currently lldb evaluates
+    // C++14 as C++11 (see two lines below) so we decide to be consistent
+    // with that, but this could be re-evaluated in the future.
+    m_compiler->getLangOpts().CPlusPlus11 = true;
     break;
   case lldb::eLanguageTypeC_plus_plus:
   case lldb::eLanguageTypeC_plus_plus_11:




More information about the lldb-commits mailing list