[Lldb-commits] [PATCH] D132635: [lldb][Test] Prevent generating DW_AT_location for unused argument

Michael Buch via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 25 00:47:38 PDT 2022


Michael137 created this revision.
Michael137 added a reviewer: aprantl.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This test simply checks whether we can print an optimized
function argument. With recent changes to Clang the assumption
that we don't generate a `DW_AT_location` attribute for the
unused funciton parameter breaks.

This patch tries harder to get Clang to drop the location
from DWARF by making it generate an `undef` for `unused1`.
Drop the check for `unused2` since it adds no benefit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132635

Files:
  lldb/test/API/functionalities/unused-inlined-parameters/TestUnusedInlinedParameters.py
  lldb/test/API/functionalities/unused-inlined-parameters/main.c


Index: lldb/test/API/functionalities/unused-inlined-parameters/main.c
===================================================================
--- lldb/test/API/functionalities/unused-inlined-parameters/main.c
+++ lldb/test/API/functionalities/unused-inlined-parameters/main.c
@@ -2,11 +2,12 @@
 
 __attribute__((optnone)) __attribute__((nodebug)) void use(int used) {}
 
-__attribute__((always_inline)) void f(void *unused1, int used, int unused2) {
+__attribute__((always_inline)) void f(void *unused1, int used) {
   use(used); // break here
 }
 
 int main(int argc, char **argv) {
-  f(argv, 42, 1);
+  char* undefined;
+  f(undefined, 42);
   return 0;
-}
\ No newline at end of file
+}
Index: lldb/test/API/functionalities/unused-inlined-parameters/TestUnusedInlinedParameters.py
===================================================================
--- lldb/test/API/functionalities/unused-inlined-parameters/TestUnusedInlinedParameters.py
+++ lldb/test/API/functionalities/unused-inlined-parameters/TestUnusedInlinedParameters.py
@@ -17,5 +17,3 @@
         self.assertIn("(void *) unused1 = <no location, value may have been optimized out>",
                       lldbutil.get_description(self.frame().FindVariable("unused1")))
         self.assertEqual(42, self.frame().FindVariable("used").GetValueAsUnsigned())
-        self.assertIn("(int) unused2 = <no location, value may have been optimized out>",
-                      lldbutil.get_description(self.frame().FindVariable("unused2")))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132635.455490.patch
Type: text/x-patch
Size: 1494 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220825/e33dfff9/attachment.bin>


More information about the lldb-commits mailing list