[PATCH] D82706: [ASTMatchers] Enhanced support for matchers taking Regex arguments
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 1 04:17:20 PDT 2020
aaron.ballman added inline comments.
================
Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.cpp:124
+llvm::Optional<llvm::Regex::RegexFlags> getRegexFlag(llvm::StringRef Flag) {
+ for (auto &StringFlag : RegexMap) {
+ if (Flag == StringFlag.first)
----------------
`const auto &` (same below)
================
Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.cpp:158
+ }
+ if (!Any)
+ return None; // Without this an empty string would return "NoFlags",
----------------
I would probably simplify this (untested):
```
SmallVector<StringRef, 4> Split;
llvm::Optional<llvm::Regex::RegexFlags> Flag;
Flags.split(Split, '|', -1, false);
for (StringRef OrFlag : Split) {
if (llvm::Optional<llvm::Regex::RegexFlags> NextFlag =
getRegexFlag(OrFlag.trim())) {
Flag = Flag.getValueOr(llvm::Regex::NoFlags) | *NextFlag;
}
}
return Flag;
```
Similar below.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82706/new/
https://reviews.llvm.org/D82706
More information about the cfe-commits
mailing list