Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Clang][NFC] Adding note on details that are not immediately obvious #138349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shafik
Copy link
Collaborator

@shafik shafik commented May 2, 2025

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.

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.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels May 2, 2025
@llvmbot
Copy link
Member

llvmbot commented May 2, 2025

@llvm/pr-subscribers-clang

Author: Shafik Yaghmour (shafik)

Changes

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.


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

1 Files Affected:

  • (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (+3)
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 0e81804f8c1e7..ca5db61afbd2e 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()) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants