[llvm-branch-commits] [clang] c435567 - [Sema] Fix an assertion failure in -Wcompletion-handler
Erik Pilkington via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jan 25 10:07:59 PST 2021
Author: Erik Pilkington
Date: 2021-01-25T13:02:02-05:00
New Revision: c4355670b4bb12bc7181a99345bf8d09af1c5762
URL: https://github.com/llvm/llvm-project/commit/c4355670b4bb12bc7181a99345bf8d09af1c5762
DIFF: https://github.com/llvm/llvm-project/commit/c4355670b4bb12bc7181a99345bf8d09af1c5762.diff
LOG: [Sema] Fix an assertion failure in -Wcompletion-handler
NamedDecl::getName() was being called on a constructor.
Added:
clang/test/SemaObjCXX/warn-called-once.mm
Modified:
clang/lib/Analysis/CalledOnceCheck.cpp
Removed:
################################################################################
diff --git a/clang/lib/Analysis/CalledOnceCheck.cpp b/clang/lib/Analysis/CalledOnceCheck.cpp
index 6b7d3790e3e5..883629a300dc 100644
--- a/clang/lib/Analysis/CalledOnceCheck.cpp
+++ b/clang/lib/Analysis/CalledOnceCheck.cpp
@@ -936,8 +936,9 @@ class CalledOnceChecker : public ConstStmtVisitor<CalledOnceChecker> {
/// Return true if the only parameter of the function is conventional.
static bool isOnlyParameterConventional(const FunctionDecl *Function) {
- return Function->getNumParams() == 1 &&
- hasConventionalSuffix(Function->getName());
+ IdentifierInfo *II = Function->getIdentifier();
+ return Function->getNumParams() == 1 && II &&
+ hasConventionalSuffix(II->getName());
}
/// Return true/false if 'swift_async' attribute states that the given
diff --git a/clang/test/SemaObjCXX/warn-called-once.mm b/clang/test/SemaObjCXX/warn-called-once.mm
new file mode 100644
index 000000000000..312da27d9ae3
--- /dev/null
+++ b/clang/test/SemaObjCXX/warn-called-once.mm
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wcompletion-handler %s
+
+// expected-no-diagnostics
+
+class HasCtor {
+ HasCtor(void *) {}
+};
More information about the llvm-branch-commits
mailing list