[PATCH] D152764: [clang-tidy] Reserved-identifier: Improved AllowedIdentifiers option to support regular expressions

Piotr Zegar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 13 00:46:20 PDT 2023


PiotrZSL added a comment.

Except pointed out issues, looks fine.



================
Comment at: clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp:49-50
+  for (const auto &Identifier : AllowedIdentifiers) {
+    if (!llvm::Regex(Identifier).isValid())
+      configurationDiag("Invalid allowed identifier regex '%0'") << Identifier;
+    AllowedIdentifiersRegex.emplace_back(Identifier.str());
----------------
avoid double compilation of regexp.
Simply:
```
AllowedIdentifiersRegex.emplace_back(Identifier.str());
if (!AllowedIdentifiersRegex.back().isValid()) {
       AllowedIdentifiersRegex.pop_back();
    configurationDiag("Invalid allowed identifier regex '%0'") << Identifier;
}
```


================
Comment at: clang-tools-extra/docs/ReleaseNotes.rst:414-416
+- Improved option `AllowedIdentifiers` from :doc:`bugprone-reserved-identifier
+  <clang-tidy/checks/bugprone/reserved-identifier>` to support regular
+  expressions.
----------------
Sort this entry by full check name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152764



More information about the cfe-commits mailing list