[PATCH] D62230: [CGDebugInfo] return early on failed dyn_cast
Nick Desaulniers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 21 20:05:05 PDT 2019
nickdesaulniers created this revision.
nickdesaulniers added a reviewer: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
nickdesaulniers added a comment.
Also of note is that no existing test covers this case.
This was flagged in https://www.viva64.com/en/b/0629/ under "Snippet No.
39".
I looked at making CGDebugInfo::getFunctionFwdDeclOrStub take a
FunctionDecl as its first argument, but this quickly became untenable.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D62230
Files:
clang/lib/CodeGen/CGDebugInfo.cpp
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3280,6 +3280,10 @@
llvm::DISubprogram *CGDebugInfo::getFunctionFwdDeclOrStub(GlobalDecl GD,
bool Stub) {
+ auto *FD = dyn_cast<FunctionDecl>(GD.getDecl());
+ if (!FD)
+ return nullptr;
+
llvm::DINodeArray TParamsArray;
StringRef Name, LinkageName;
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
@@ -3290,13 +3294,10 @@
unsigned Line = getLineNumber(Loc);
collectFunctionDeclProps(GD, Unit, Name, LinkageName, DContext, TParamsArray,
Flags);
- auto *FD = dyn_cast<FunctionDecl>(GD.getDecl());
-
// Build function type.
SmallVector<QualType, 16> ArgTypes;
- if (FD)
- for (const ParmVarDecl *Parm : FD->parameters())
- ArgTypes.push_back(Parm->getType());
+ for (const ParmVarDecl *Parm : FD->parameters())
+ ArgTypes.push_back(Parm->getType());
CallingConv CC = FD->getType()->castAs<FunctionType>()->getCallConv();
QualType FnType = CGM.getContext().getFunctionType(
FD->getReturnType(), ArgTypes, FunctionProtoType::ExtProtoInfo(CC));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62230.200631.patch
Type: text/x-patch
Size: 1275 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190522/51178aa4/attachment.bin>
More information about the cfe-commits
mailing list