Skip to content

Commit c435567

Browse files
committed
[Sema] Fix an assertion failure in -Wcompletion-handler
NamedDecl::getName() was being called on a constructor.
1 parent 3fbd3ea commit c435567

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

clang/lib/Analysis/CalledOnceCheck.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,9 @@ class CalledOnceChecker : public ConstStmtVisitor<CalledOnceChecker> {
936936

937937
/// Return true if the only parameter of the function is conventional.
938938
static bool isOnlyParameterConventional(const FunctionDecl *Function) {
939-
return Function->getNumParams() == 1 &&
940-
hasConventionalSuffix(Function->getName());
939+
IdentifierInfo *II = Function->getIdentifier();
940+
return Function->getNumParams() == 1 && II &&
941+
hasConventionalSuffix(II->getName());
941942
}
942943

943944
/// Return true/false if 'swift_async' attribute states that the given
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %clang_cc1 -verify -fsyntax-only -Wcompletion-handler %s
2+
3+
// expected-no-diagnostics
4+
5+
class HasCtor {
6+
HasCtor(void *) {}
7+
};

0 commit comments

Comments
 (0)