[PATCH] D18238: [clang-tidy] Fix clang-tidy crashes when using -fdelayed-template-parsing.
Etienne Bergeron via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 17 08:46:44 PDT 2016
etienneb updated this revision to Diff 50940.
etienneb marked 3 inline comments as done.
etienneb added a comment.
fixed. thanks.
http://reviews.llvm.org/D18238
Files:
cppcoreguidelines/ProTypeMemberInitCheck.cpp
modernize/RedundantVoidArgCheck.cpp
Index: cppcoreguidelines/ProTypeMemberInitCheck.cpp
===================================================================
--- cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -179,6 +179,11 @@
const auto *Ctor = Result.Nodes.getNodeAs<CXXConstructorDecl>("ctor");
const auto &MemberFields = Ctor->getParent()->fields();
+ // Skip delayed template instantiation declarations.
+ const Stmt *Body = Ctor->getBody();
+ if (!Body)
+ return;
+
SmallPtrSet<const FieldDecl *, 16> FieldsToInit;
fieldsRequiringInit(MemberFields, FieldsToInit);
if (FieldsToInit.empty())
@@ -193,8 +198,8 @@
continue;
FieldsToInit.erase(Init->getMember());
}
- removeFieldsInitializedInBody(*Ctor->getBody(), *Result.Context,
- FieldsToInit);
+ removeFieldsInitializedInBody(*Body, *Result.Context, FieldsToInit);
+
if (FieldsToInit.empty())
return;
Index: modernize/RedundantVoidArgCheck.cpp
===================================================================
--- modernize/RedundantVoidArgCheck.cpp
+++ modernize/RedundantVoidArgCheck.cpp
@@ -104,13 +104,10 @@
const MatchFinder::MatchResult &Result, const FunctionDecl *Function) {
SourceLocation Start = Function->getLocStart();
if (Function->isThisDeclarationADefinition()) {
- SourceLocation End;
- if (Function->hasBody())
- End = Function->getBody()->getLocStart().getLocWithOffset(-1);
- else
- End = Function->getLocEnd();
- removeVoidArgumentTokens(Result, SourceRange(Start, End),
- "function definition");
+ const Stmt *Body = Function->getBody();
+ SourceRange range(Start, Body ? Body->getLocStart().getLocWithOffset(-1) :
+ Function->getLocEnd());
+ removeVoidArgumentTokens(Result, range, "function definition");
} else {
removeVoidArgumentTokens(Result, Function->getSourceRange(),
"function declaration");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18238.50940.patch
Type: text/x-patch
Size: 2019 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160317/7e31e801/attachment.bin>
More information about the cfe-commits
mailing list