[clang] Enclose code in nondebug in #ifndef NDEBUG/#endif (PR #142189)
via cfe-commits
cfe-commits at lists.llvm.org
Fri May 30 10:44:48 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (DeanSturtevant1)
<details>
<summary>Changes</summary>
A previous change to InterpBuiltin.cpp fixed an unused variable warning by using [[maybe unused]] and (void).
The code actually serves no useful purpose in non-debug builds, so let's not include it there.
---
Full diff: https://github.com/llvm/llvm-project/pull/142189.diff
1 Files Affected:
- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+3-2)
``````````diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index bfad4e763692f..55e0061702874 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -763,12 +763,13 @@ static bool interp__builtin_ffs(InterpState &S, CodePtr OpPC,
static bool interp__builtin_addressof(InterpState &S, CodePtr OpPC,
const InterpFrame *Frame,
const CallExpr *Call) {
+#ifndef NDEBUG
assert(Call->getArg(0)->isLValue());
- [[maybe_unused]] PrimType PtrT =
+ PrimType PtrT =
S.getContext().classify(Call->getArg(0)).value_or(PT_Ptr);
assert(PtrT == PT_Ptr &&
"Unsupported pointer type passed to __builtin_addressof()");
- (void)PtrT;
+#endif
return true;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/142189
More information about the cfe-commits
mailing list