[PATCH] D145769: [clang] Extract ParsedAttrInfo::hasSpelling method (NFC)
Anders Waldenborg via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 13 08:48:50 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG446f78092ffa: [clang] Extract ParsedAttrInfo::hasSpelling method (NFC) (authored by wanders).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145769/new/
https://reviews.llvm.org/D145769
Files:
clang/include/clang/Basic/ParsedAttrInfo.h
clang/lib/Sema/ParsedAttr.cpp
Index: clang/lib/Sema/ParsedAttr.cpp
===================================================================
--- clang/lib/Sema/ParsedAttr.cpp
+++ clang/lib/Sema/ParsedAttr.cpp
@@ -126,9 +126,8 @@
SyntaxUsed = AttributeCommonInfo::AS_Keyword;
for (auto &Ptr : getAttributePluginInstances())
- for (auto &S : Ptr->Spellings)
- if (S.Syntax == SyntaxUsed && S.NormalizedFullName == FullName)
- return *Ptr;
+ if (Ptr->hasSpelling(SyntaxUsed, FullName))
+ return *Ptr;
// If we failed to find a match then return a default ParsedAttrInfo.
static const ParsedAttrInfo DefaultParsedAttrInfo(
Index: clang/include/clang/Basic/ParsedAttrInfo.h
===================================================================
--- clang/include/clang/Basic/ParsedAttrInfo.h
+++ clang/include/clang/Basic/ParsedAttrInfo.h
@@ -88,6 +88,13 @@
public:
virtual ~ParsedAttrInfo() = default;
+ /// Check if this attribute has specified spelling.
+ bool hasSpelling(AttributeCommonInfo::Syntax Syntax, StringRef Name) const {
+ return llvm::any_of(Spellings, [&](const Spelling &S) {
+ return (S.Syntax == Syntax && S.NormalizedFullName == Name);
+ });
+ }
+
/// Check if this attribute appertains to D, and issue a diagnostic if not.
virtual bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr,
const Decl *D) const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145769.504684.patch
Type: text/x-patch
Size: 1395 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230313/a659b7f0/attachment.bin>
More information about the cfe-commits
mailing list