[PATCH] D152246: [clang][ThreadSafety] Analyze known function pointer values
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 10 00:35:21 PDT 2023
tbaeder updated this revision to Diff 530177.
tbaeder marked an inline comment as done.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152246/new/
https://reviews.llvm.org/D152246
Files:
clang/lib/Analysis/ThreadSafety.cpp
Index: clang/lib/Analysis/ThreadSafety.cpp
===================================================================
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -2063,10 +2063,22 @@
examineArguments(Exp->getDirectCallee(), Exp->arg_begin(), Exp->arg_end());
}
- auto *D = dyn_cast_or_null<NamedDecl>(Exp->getCalleeDecl());
- if(!D || !D->hasAttrs())
+ const auto *ND = dyn_cast_if_present<NamedDecl>(Exp->getCalleeDecl());
+ if (!ND)
return;
- handleCall(Exp, D);
+
+ // For function pointers, try to get the currently known
+ // value of the pointer.
+ if (const auto *VD = dyn_cast<VarDecl>(ND)) {
+ if (const Expr *E = Analyzer->LocalVarMap.lookupExpr(ND, LVarCtx)) {
+ if (const auto *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts()))
+ ND = DRE->getDecl();
+ }
+ }
+
+ if (!ND->hasAttrs())
+ return;
+ handleCall(Exp, ND);
}
void BuildLockset::VisitCXXConstructExpr(const CXXConstructExpr *Exp) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152246.530177.patch
Type: text/x-patch
Size: 991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230610/63d4510c/attachment-0001.bin>
More information about the cfe-commits
mailing list