[PATCH] D146089: [Sema] Fix null pointer dereference handleAlwaysInlineAttr.
Craig Topper via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 14 13:34:14 PDT 2023
craig.topper created this revision.
craig.topper added reviewers: aaron.ballman, erichkeane.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a project: clang.
It's possible for `getCalleeDecl()` to return a null pointer.
This was encountered by a user of our downstream compiler.
The case involved a DependentScopeDeclRefExpr.
Since this seems to only be for a warning diagnostic, I skipped
the diagnostic check if it returned null. But mabye there's a
different way to fix this.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D146089
Files:
clang/lib/Sema/SemaStmtAttr.cpp
Index: clang/lib/Sema/SemaStmtAttr.cpp
===================================================================
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -259,7 +259,7 @@
for (const auto *CallExpr : CEF.getCallExprs()) {
const Decl *Decl = CallExpr->getCalleeDecl();
- if (Decl->hasAttr<NoInlineAttr>() || Decl->hasAttr<FlattenAttr>())
+ if (Decl && (Decl->hasAttr<NoInlineAttr>() || Decl->hasAttr<FlattenAttr>()))
S.Diag(St->getBeginLoc(), diag::warn_function_stmt_attribute_precedence)
<< A << (Decl->hasAttr<NoInlineAttr>() ? 2 : 1);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146089.505245.patch
Type: text/x-patch
Size: 604 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230314/88ba972b/attachment.bin>
More information about the cfe-commits
mailing list