[PATCH] D91908: [clang-tidy] Use compiled regex for AllowedRegexp in macro usage check
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 23 12:47:58 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG269ef315d1be: [clang-tidy] Use compiled regex for AllowedRegexp in macro usage check (authored by smhc, committed by njames93).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91908/new/
https://reviews.llvm.org/D91908
Files:
clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
@@ -32,8 +32,8 @@
class MacroUsageCallbacks : public PPCallbacks {
public:
MacroUsageCallbacks(MacroUsageCheck *Check, const SourceManager &SM,
- StringRef RegExp, bool CapsOnly, bool IgnoreCommandLine)
- : Check(Check), SM(SM), RegExp(RegExp), CheckCapsOnly(CapsOnly),
+ StringRef RegExpStr, bool CapsOnly, bool IgnoreCommandLine)
+ : Check(Check), SM(SM), RegExp(RegExpStr), CheckCapsOnly(CapsOnly),
IgnoreCommandLineMacros(IgnoreCommandLine) {}
void MacroDefined(const Token &MacroNameTok,
const MacroDirective *MD) override {
@@ -47,7 +47,7 @@
return;
StringRef MacroName = MacroNameTok.getIdentifierInfo()->getName();
- if (!CheckCapsOnly && !llvm::Regex(RegExp).match(MacroName))
+ if (!CheckCapsOnly && !RegExp.match(MacroName))
Check->warnMacro(MD, MacroName);
if (CheckCapsOnly && !isCapsOnly(MacroName))
@@ -57,7 +57,7 @@
private:
MacroUsageCheck *Check;
const SourceManager &SM;
- StringRef RegExp;
+ const llvm::Regex RegExp;
bool CheckCapsOnly;
bool IgnoreCommandLineMacros;
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91908.307175.patch
Type: text/x-patch
Size: 1415 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201123/426a659f/attachment.bin>
More information about the cfe-commits
mailing list