[clang] Add option to generate additional debug info for expression dereferencing pointer to pointers. (PR #81545)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 12 14:39:32 PST 2024
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 9261ab708e37c2d6499ac063045f816d25a5919c f2c82758e1cba7773e41d941d2812c829c339675 -- clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h clang/lib/CodeGen/CGDecl.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CodeGenFunction.h clang/lib/Driver/ToolChains/Clang.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index b979c0830c..7e38a6946a 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2074,15 +2074,20 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address Addr, bool Volatile,
// Since there is no variable correspond to an intermediate expression, we
// create a pseudo variable for it and emit its debug info, as if the
// expression were written in SSA form.
- if (CGM.getCodeGenOpts().getDebugInfo() > llvm::codegenoptions::DebugLineTablesOnly &&
+ if (CGM.getCodeGenOpts().getDebugInfo() >
+ llvm::codegenoptions::DebugLineTablesOnly &&
CGM.getCodeGenOpts().DebugInfoForPointerType) {
if (CGDebugInfo *DI = getDebugInfo())
// We only generate this debug info if loading from GEP, not from other
// cases such as loading a function argument.
if (isa<llvm::GetElementPtrInst>(Load->getOperand(0))) {
const llvm::DebugLoc &DebugLoc = Load->getDebugLoc();
- llvm::AllocaInst *PseudoVar = Builder.CreateAlloca(
- Load->getType(), nullptr, Twine("pseudo_").concat(Twine(DebugLoc.getLine())).concat("_").concat(Twine(DebugLoc.getCol())));
+ llvm::AllocaInst *PseudoVar =
+ Builder.CreateAlloca(Load->getType(), nullptr,
+ Twine("pseudo_")
+ .concat(Twine(DebugLoc.getLine()))
+ .concat("_")
+ .concat(Twine(DebugLoc.getCol())));
DI->EmitPseudoVariable(PseudoVar, Ty, Loc);
Address PseudoVarAddr(PseudoVar, Load->getType(), Addr.getAlignment());
Builder.CreateStore(Load, PseudoVarAddr);
@@ -5644,7 +5649,8 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) {
}
RValue RV = EmitAnyExpr(E->getRHS());
- if (CGM.getCodeGenOpts().getDebugInfo() > llvm::codegenoptions::DebugLineTablesOnly &&
+ if (CGM.getCodeGenOpts().getDebugInfo() >
+ llvm::codegenoptions::DebugLineTablesOnly &&
CGM.getCodeGenOpts().DebugInfoForPointerType)
if (isa<DeclRefExpr>(E->getLHS()) && RV.isScalar())
RV = RValue::get(UnemitPseudoVariable(RV.getScalarVal()));
``````````
</details>
https://github.com/llvm/llvm-project/pull/81545
More information about the cfe-commits
mailing list