Skip to content

Conversation

@usx95
Copy link
Contributor

@usx95 usx95 commented Dec 17, 2025

Wrap debug-only function in #ifndef NDEBUG to avoid unused function warnings in release builds.

Copy link
Contributor Author

usx95 commented Dec 17, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@usx95 usx95 changed the title fix-opt-build [LifetimeSafety] Guard debug-only function with NDEBUG Dec 17, 2025
@usx95 usx95 marked this pull request as ready for review December 17, 2025 17:38
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:analysis clang:temporal-safety Issue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr) labels Dec 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Dec 17, 2025

@llvm/pr-subscribers-clang
@llvm/pr-subscribers-clang-analysis

@llvm/pr-subscribers-clang-temporal-safety

Author: Utkarsh Saxena (usx95)

Changes

Wrap debug-only function in #ifndef NDEBUG to avoid unused function warnings in release builds.


Full diff: https://github.com/llvm/llvm-project/pull/172696.diff

1 Files Affected:

  • (modified) clang/lib/Analysis/LifetimeSafety/LifetimeSafety.cpp (+2)
diff --git a/clang/lib/Analysis/LifetimeSafety/LifetimeSafety.cpp b/clang/lib/Analysis/LifetimeSafety/LifetimeSafety.cpp
index 50111f8ef1fba..c0fa640a8ba66 100644
--- a/clang/lib/Analysis/LifetimeSafety/LifetimeSafety.cpp
+++ b/clang/lib/Analysis/LifetimeSafety/LifetimeSafety.cpp
@@ -31,6 +31,7 @@
 namespace clang::lifetimes {
 namespace internal {
 
+#ifndef NDEBUG
 static void DebugOnlyFunction(AnalysisDeclContext &AC, const CFG &Cfg,
                               FactManager &FactMgr) {
   std::string Name;
@@ -43,6 +44,7 @@ static void DebugOnlyFunction(AnalysisDeclContext &AC, const CFG &Cfg,
                                          /*ShowColors=*/true));
   DEBUG_WITH_TYPE(Name.c_str(), FactMgr.dump(Cfg, AC));
 }
+#endif
 
 LifetimeSafetyAnalysis::LifetimeSafetyAnalysis(AnalysisDeclContext &AC,
                                                LifetimeSafetyReporter *Reporter)

@usx95 usx95 merged commit 68e4a75 into main Dec 17, 2025
15 of 16 checks passed
@usx95 usx95 deleted the users/usx95/12-17-fix-opt-build branch December 17, 2025 17:45
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Dec 19, 2025
Wrap debug-only function in `#ifndef NDEBUG` to avoid unused function
warnings in release builds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:analysis clang:temporal-safety Issue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr) clang Clang issues not falling into any other category

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants