[PATCH] D112916: Confusable identifiers detection

Nico Weber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 3 06:26:44 PDT 2022


thakis added a comment.

This also makes clang-tidy crash for fairly normal inputs, see below.



================
Comment at: clang-tools-extra/clang-tidy/misc/Homoglyph.cpp:84
+  if (const auto *ND = Result.Nodes.getNodeAs<NamedDecl>("nameddecl")) {
+    StringRef NDName = ND->getName();
+    auto &Mapped = Mapper[skeleton(NDName)];
----------------
This call is not correct, it's only valid for simple identifiers:

```
% cat t.cc
namespace ns { struct Foo {}; }
auto f = ns::Foo();
% ../llvm-build-2/bin/clang-tidy t.cc  -fix '--checks=-*,misc-homoglyph'  -config={} --
argh Foo
Assertion failed: (Name.isIdentifier() && "Name is not a simple identifier"), function getName, file Decl.h, line 278.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
```

This crash breaks check-clangd in some build configs (t.cc is reduced form `clang-tools-extra/clangd/test/check.test`).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112916/new/

https://reviews.llvm.org/D112916



More information about the cfe-commits mailing list