llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tidy

Author: Zeyi Xu (zeyi2)

<details>
<summary>Changes</summary>

Closes #<!-- -->224219

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


1 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/misc/StaticInitializationCycleCheck.cpp (+4-3) 


``````````diff
diff --git 
a/clang-tools-extra/clang-tidy/misc/StaticInitializationCycleCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/StaticInitializationCycleCheck.cpp
index 7b1e86b7804fa..aabb7bb71ac4c 100644
--- a/clang-tools-extra/clang-tidy/misc/StaticInitializationCycleCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/StaticInitializationCycleCheck.cpp
@@ -199,8 +199,8 @@ class VarUseCollector : public DynamicRecursiveASTVisitor {
 
   bool VisitDeclRefExpr(DeclRefExpr *DRE) override {
     if (const auto *VarD = dyn_cast<VarDecl>(DRE->getDecl());
-        VarD && (!shouldIgnoreRef(DRE, Node->getDecl()) &&
-                 (VarD->hasGlobalStorage() || VarD->isStaticLocal())))
+        VarD && VarD->hasGlobalStorage() &&
+        !shouldIgnoreRef(DRE, Node->getDecl()))
       Node->Uses.emplace_back(DRE, G.addNode(VarD->getCanonicalDecl()));
     return true;
   }
@@ -240,7 +240,8 @@ class VarUseGraphBuilder : public 
DynamicRecursiveASTVisitor {
   }
 
   bool VisitFunctionDecl(FunctionDecl *FD) override {
-    if (FD->isGlobal() || FD->isStatic()) {
+    if ((FD->isGlobal() || FD->isStatic()) &&
+        FD->doesThisDeclarationHaveABody()) {
       if (Stmt *Body = FD->getBody()) {
         VarUseNode *N = G.addNode(FD);
         VarUseCollector Collector(N, G);

``````````

</details>


https://github.com/llvm/llvm-project/pull/224243
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to