diff options
author | David Greene <greened@obbligato.org> | 2011-07-11 18:25:51 +0000 |
---|---|---|
committer | David Greene <greened@obbligato.org> | 2011-07-11 18:25:51 +0000 |
commit | d4a9066c93da9a5aab47ca228d82e796fdec70c0 (patch) | |
tree | f4533e3a9fe75aa310bd4682b254a053af0bfd73 /utils/TableGen/ClangAttrEmitter.cpp | |
parent | 7ae0df41422193e65231a0f9526bfe66067c6532 (diff) |
[AVX] Make Inits Foldable
Manage Inits in a FoldingSet. This provides several benefits:
- Memory for Inits is properly managed
- Duplicate Inits are folded into Flyweights, saving memory
- It enforces const-correctness, protecting against certain classes
of bugs
The above benefits allow Inits to be used in more contexts, which in
turn provides more dynamism to TableGen. This enhanced capability
will be used by the AVX code generator to a fold common patterns
together.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134907 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/ClangAttrEmitter.cpp')
-rw-r--r-- | utils/TableGen/ClangAttrEmitter.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/utils/TableGen/ClangAttrEmitter.cpp b/utils/TableGen/ClangAttrEmitter.cpp index 26bd8786a4..bca4bb61c2 100644 --- a/utils/TableGen/ClangAttrEmitter.cpp +++ b/utils/TableGen/ClangAttrEmitter.cpp @@ -21,17 +21,19 @@ using namespace llvm; static const std::vector<StringRef> getValueAsListOfStrings(Record &R, StringRef FieldName) { - ListInit *List = R.getValueAsListInit(FieldName); + const ListInit *List = R.getValueAsListInit(FieldName); assert (List && "Got a null ListInit"); std::vector<StringRef> Strings; Strings.reserve(List->getSize()); - for (ListInit::iterator i = List->begin(), e = List->end(); i != e; ++i) { + for (ListInit::const_iterator i = List->begin(), e = List->end(); + i != e; + ++i) { assert(*i && "Got a null element in a ListInit"); - if (StringInit *S = dynamic_cast<StringInit *>(*i)) + if (const StringInit *S = dynamic_cast<const StringInit *>(*i)) Strings.push_back(S->getValue()); - else if (CodeInit *C = dynamic_cast<CodeInit *>(*i)) + else if (const CodeInit *C = dynamic_cast<const CodeInit *>(*i)) Strings.push_back(C->getValue()); else assert(false && "Got a non-string, non-code element in a ListInit"); |