[clang] b1c7801 - [Clang][NFC] Adding note on details that are not immediately obvious (#138349)

via cfe-commits cfe-commits at lists.llvm.org
Fri May 9 14:23:49 PDT 2025


Author: Shafik Yaghmour
Date: 2025-05-09T14:23:45-07:00
New Revision: b1c7801069aac6c3dcaf47d15a2d723b0389cfde

URL: https://github.com/llvm/llvm-project/commit/b1c7801069aac6c3dcaf47d15a2d723b0389cfde
DIFF: https://github.com/llvm/llvm-project/commit/b1c7801069aac6c3dcaf47d15a2d723b0389cfde.diff

LOG: [Clang][NFC] Adding note on details that are not immediately obvious (#138349)

This code was flagged by static analysis. It was a false positive but
the reason why this code is valid is subtle and folks refactoring this
code in the future could easily miss it.

Added: 
    

Modified: 
    clang/lib/Sema/SemaTemplateInstantiate.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index fb490bcac6e91..d028eea4f8f3e 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1137,6 +1137,9 @@ void Sema::PrintInstantiationStack(InstantiationContextDiagFuncRef DiagFunc) {
       // FIXME: For synthesized functions that are not defaulted,
       // produce a note.
       auto *FD = dyn_cast<FunctionDecl>(Active->Entity);
+      // Note: if FD is nullptr currently setting DFK to DefaultedFunctionKind()
+      // will ensure that DFK.isComparison() is false. This is important because
+      // we will uncondtionally dereference FD in the else if.
       DefaultedFunctionKind DFK =
           FD ? getDefaultedFunctionKind(FD) : DefaultedFunctionKind();
       if (DFK.isSpecialMember()) {


        


More information about the cfe-commits mailing list