[llvm] Allow DWARF expressions to refer to variable values (PR #181028)

via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 11 13:48:26 PST 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- llvm/include/llvm-c/DebugInfo.h llvm/include/llvm/Bitcode/LLVMBitCodes.h llvm/include/llvm/IR/DIBuilder.h llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/AsmParser/LLParser.cpp llvm/lib/Bitcode/Reader/MetadataLoader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h llvm/lib/DebugInfo/DWARF/LowLevel/DWARFExpression.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/IR/DIBuilder.cpp llvm/lib/IR/DebugInfoMetadata.cpp llvm/lib/IR/LLVMContextImpl.h llvm/lib/IR/Verifier.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
index bd772c377..b3f4be56a 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -4695,7 +4695,8 @@ class DIVariableExpression : public MDNode {
                                        DINodeArray VarArray,
                                        StorageType Storage,
                                        bool ShouldCreate = true) {
-    return getImpl(Context, static_cast<Metadata *>(Expr), VarArray.get(), Storage, ShouldCreate);
+    return getImpl(Context, static_cast<Metadata *>(Expr), VarArray.get(),
+                   Storage, ShouldCreate);
   }
   static DIVariableExpression *getImpl(LLVMContext &Context, Metadata *Expr,
                                        Metadata *VarArray, StorageType Storage,
@@ -4707,8 +4708,7 @@ class DIVariableExpression : public MDNode {
 
 public:
   DEFINE_MDNODE_GET(DIVariableExpression,
-                    (DIExpression * Expr, DINodeArray Vars),
-                    (Expr, Vars))
+                    (DIExpression * Expr, DINodeArray Vars), (Expr, Vars))
   DEFINE_MDNODE_GET(DIVariableExpression, (Metadata * Expr, Metadata *Vars),
                     (Expr, Vars))
 
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 3f61f264f..dba2d5d02 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -6486,8 +6486,7 @@ bool LLParser::parseDIVariableExpression(MDNode *&Result, bool IsDistinct) {
   PARSE_MD_FIELDS();
 #undef VISIT_MD_FIELDS
 
-  Result = GET_OR_DISTINCT(DIVariableExpression,
-                           (Context, expr.Val, vars.Val));
+  Result = GET_OR_DISTINCT(DIVariableExpression, (Context, expr.Val, vars.Val));
   return false;
 }
 
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
index 2053b4241..115cb960e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
@@ -221,7 +221,8 @@ public:
 
   /// Add an expression as block data.
   void addBlock(DIE &Die, dwarf::Attribute Attribute, const DIExpression *Expr);
-  void addBlock(DIE &Die, dwarf::Attribute Attribute, const DIVariableExpression *Expr);
+  void addBlock(DIE &Die, dwarf::Attribute Attribute,
+                const DIVariableExpression *Expr);
 
   /// Add location information to specified debug information entry.
   void addSourceLine(DIE &Die, unsigned Line, unsigned Column,

``````````

</details>


https://github.com/llvm/llvm-project/pull/181028


More information about the llvm-commits mailing list