diff --git a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp --- a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp +++ b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp @@ -118,7 +118,7 @@ if (!FD) return {}; - llvm::StringRef FName = FD->getName(); + llvm::StringRef FName = symbolName(S); llvm::SmallVector Headers; if (FName == "move") { if (FD->getNumParams() == 1) diff --git a/clang-tools-extra/include-cleaner/test/nocrash.cpp b/clang-tools-extra/include-cleaner/test/nocrash.cpp new file mode 100644 --- /dev/null +++ b/clang-tools-extra/include-cleaner/test/nocrash.cpp @@ -0,0 +1,8 @@ +// RUN: clang-include-cleaner %s -- + +namespace std { +class Foo {}; +bool operator==(Foo, int) { return false; } +} +// no crash on a reference to a non-identifier symbol (operator ==). +bool s = std::operator==(std::Foo(), 1);