[Lldb-commits] [PATCH] D80308: [lldb] Enable C++14 when evaluating expressions in a C++14 frame

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri May 22 03:01:15 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG5f88f39ab815: [lldb] Enable C++14 when evaluating expressions in a C++14 frame (authored by teemperor).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80308/new/

https://reviews.llvm.org/D80308

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/test/API/lang/cpp/standards/cpp11/Makefile
  lldb/test/API/lang/cpp/standards/cpp11/TestCPP11Standard.py
  lldb/test/API/lang/cpp/standards/cpp11/main.cpp
  lldb/test/API/lang/cpp/standards/cpp14/Makefile
  lldb/test/API/lang/cpp/standards/cpp14/TestCPP14Standard.py
  lldb/test/API/lang/cpp/standards/cpp14/main.cpp


Index: lldb/test/API/lang/cpp/standards/cpp14/main.cpp
===================================================================
--- /dev/null
+++ lldb/test/API/lang/cpp/standards/cpp14/main.cpp
@@ -0,0 +1,3 @@
+int main() {
+  return 0; // break here
+}
Index: lldb/test/API/lang/cpp/standards/cpp14/TestCPP14Standard.py
===================================================================
--- /dev/null
+++ lldb/test/API/lang/cpp/standards/cpp14/TestCPP14Standard.py
@@ -0,0 +1,19 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    def test(self):
+        self.build()
+        lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp"))
+
+        # Run an expression that is valid in C++11 (as it uses nullptr).
+        self.expect_expr("nullptr == nullptr", result_type="bool", result_value="true")
+
+        # Run a expression that is only valid in C++14 that (as it uses
+        # polymorphic lambdas).
+        self.expect_expr("[](auto x) { return x; }(1)", result_type="int", result_value="1")
Index: lldb/test/API/lang/cpp/standards/cpp14/Makefile
===================================================================
--- /dev/null
+++ lldb/test/API/lang/cpp/standards/cpp14/Makefile
@@ -0,0 +1,4 @@
+CXX_SOURCES := main.cpp
+CXXFLAGS_EXTRAS := -std=c++14
+
+include Makefile.rules
Index: lldb/test/API/lang/cpp/standards/cpp11/main.cpp
===================================================================
--- /dev/null
+++ lldb/test/API/lang/cpp/standards/cpp11/main.cpp
@@ -0,0 +1,3 @@
+int main() {
+  return 0; // break here
+}
Index: lldb/test/API/lang/cpp/standards/cpp11/TestCPP11Standard.py
===================================================================
--- /dev/null
+++ lldb/test/API/lang/cpp/standards/cpp11/TestCPP11Standard.py
@@ -0,0 +1,19 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    def test(self):
+        self.build()
+        lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp"))
+
+        # Run an expression that is valid in C++11 (as it uses nullptr).
+        self.expect_expr("nullptr == nullptr", result_type="bool", result_value="true")
+
+        # Run a expression that is not valid in C++11 (as it uses polymorphic
+        # lambdas from C++14).
+        self.expect("expr [](auto x) { return x; }(1)", error=True, substrs=["'auto' not allowed in lambda parameter"])
Index: lldb/test/API/lang/cpp/standards/cpp11/Makefile
===================================================================
--- /dev/null
+++ lldb/test/API/lang/cpp/standards/cpp11/Makefile
@@ -0,0 +1,4 @@
+CXX_SOURCES := main.cpp
+CXXFLAGS_EXTRAS := -std=c++11
+
+include Makefile.rules
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===================================================================
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -491,9 +491,11 @@
     // be re-evaluated in the future.
     lang_opts.CPlusPlus11 = true;
     break;
+  case lldb::eLanguageTypeC_plus_plus_14:
+    lang_opts.CPlusPlus14 = true;
+    LLVM_FALLTHROUGH;
   case lldb::eLanguageTypeC_plus_plus:
   case lldb::eLanguageTypeC_plus_plus_11:
-  case lldb::eLanguageTypeC_plus_plus_14:
     lang_opts.CPlusPlus11 = true;
     m_compiler->getHeaderSearchOpts().UseLibcxx = true;
     LLVM_FALLTHROUGH;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80308.265690.patch
Type: text/x-patch
Size: 3731 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200522/417af582/attachment-0001.bin>


More information about the lldb-commits mailing list