[clang] 3b417b7 - Fix "pointer is null" static analyzer warning. NFCI.
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 7 05:42:19 PST 2020
Author: Simon Pilgrim
Date: 2020-01-07T13:41:52Z
New Revision: 3b417b7cf73b6b5a2953ad4c8178b4394ea4f20e
URL: https://github.com/llvm/llvm-project/commit/3b417b7cf73b6b5a2953ad4c8178b4394ea4f20e
DIFF: https://github.com/llvm/llvm-project/commit/3b417b7cf73b6b5a2953ad4c8178b4394ea4f20e.diff
LOG: Fix "pointer is null" static analyzer warning. NFCI.
Added:
Modified:
clang/lib/AST/Comment.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp
index 23dc7ba93591..a02cc9d119fe 100644
--- a/clang/lib/AST/Comment.cpp
+++ b/clang/lib/AST/Comment.cpp
@@ -379,11 +379,11 @@ StringRef TParamCommandComment::getParamName(const FullComment *FC) const {
assert(isPositionValid());
const TemplateParameterList *TPL = FC->getDeclInfo()->TemplateParameters;
for (unsigned i = 0, e = getDepth(); i != e; ++i) {
- if (i == e-1)
+ assert(TPL && "Unknown TemplateParameterList");
+ if (i == e - 1)
return TPL->getParam(getIndex(i))->getName();
const NamedDecl *Param = TPL->getParam(getIndex(i));
- if (const TemplateTemplateParmDecl *TTP =
- dyn_cast<TemplateTemplateParmDecl>(Param))
+ if (auto *TTP = dyn_cast<TemplateTemplateParmDecl>(Param))
TPL = TTP->getTemplateParameters();
}
return "";
More information about the cfe-commits
mailing list