diff --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp --- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp @@ -453,9 +453,12 @@ Decl = Overridden; } Decl = cast(Decl->getCanonicalDecl()); - return addUsage(RenamerClangTidyCheck::NamingCheckId(Decl->getLocation(), - Decl->getName()), - Range, SourceMgr); + // Don't keep track for non-identifier names. + if (auto *II = Decl->getIdentifier()) { + return addUsage(RenamerClangTidyCheck::NamingCheckId(Decl->getLocation(), + II->getName()), + Range, SourceMgr); + } } void RenamerClangTidyCheck::checkNamedDecl(const NamedDecl *Decl, diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-nocrash.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-nocrash.cpp new file mode 100644 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-nocrash.cpp @@ -0,0 +1,11 @@ +// RUN: %check_clang_tidy %s readability-identifier-naming %t + +struct Foo { + operator bool(); +}; + +void foo() { + // Make sure we don't crash on non-identifier names (e.g. conversion + // operators). + if (Foo()) {} +}