diff options
| author | Douglas Gregor <dgregor@apple.com> | 2012-05-11 23:37:49 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2012-05-11 23:37:49 +0000 |
| commit | 87a170c1e60f0b0c109f4c94a96e4ba43ac160cb (patch) | |
| tree | c6869305a0f2c122435cd44b7c6b0209cd6f7972 /clang/utils | |
| parent | a39c9bceeb75376fb574b5a279cf31390fa04986 (diff) | |
| download | bcm5719-llvm-87a170c1e60f0b0c109f4c94a96e4ba43ac160cb.tar.gz bcm5719-llvm-87a170c1e60f0b0c109f4c94a96e4ba43ac160cb.zip | |
Teach the parser to deal with multiple spellings for the same
attribute, rather than requiring multiple cases in consumers of this
information.
llvm-svn: 156666
Diffstat (limited to 'clang/utils')
| -rw-r--r-- | clang/utils/TableGen/ClangAttrEmitter.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp index 4177660e26b..772fc2f526f 100644 --- a/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -1062,7 +1062,8 @@ void ClangAttrParsedAttrListEmitter::run(raw_ostream &OS) { Record &Attr = **I; bool SemaHandler = Attr.getValueAsBit("SemaHandler"); - + bool DistinctSpellings = Attr.getValueAsBit("DistinctSpellings"); + if (SemaHandler) { std::vector<StringRef> Spellings = getValueAsListOfStrings(Attr, "Spellings"); @@ -1079,6 +1080,9 @@ void ClangAttrParsedAttrListEmitter::run(raw_ostream &OS) { ProcessedAttrs.insert(AttrName); OS << "PARSED_ATTR(" << AttrName << ")\n"; + + if (!DistinctSpellings) + break; } } } @@ -1097,23 +1101,23 @@ void ClangAttrParsedAttrKindsEmitter::run(raw_ostream &OS) { bool SemaHandler = Attr.getValueAsBit("SemaHandler"); bool Ignored = Attr.getValueAsBit("Ignored"); - + bool DistinctSpellings = Attr.getValueAsBit("DistinctSpellings"); if (SemaHandler || Ignored) { std::vector<StringRef> Spellings = getValueAsListOfStrings(Attr, "Spellings"); for (std::vector<StringRef>::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) { - StringRef AttrName = *I, Spelling = *I; - - AttrName = NormalizeAttrName(AttrName); - Spelling = NormalizeAttrSpelling(Spelling); + StringRef AttrName = NormalizeAttrName(DistinctSpellings + ? *I + : Spellings.front()); + StringRef Spelling = NormalizeAttrSpelling(*I); if (SemaHandler) Matches.push_back( - StringMatcher::StringPair(Spelling, - std::string("return AttributeList::AT_") + - AttrName.str() + ";")); + StringMatcher::StringPair( + Spelling, + std::string("return AttributeList::AT_")+AttrName.str() + ";")); else Matches.push_back( StringMatcher::StringPair( |

