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 | af973b4f36b4a7f171a92d89d4a9c6156276a600 (patch) | |
tree | e05d900e5a00aa45185f9595e4bf44b7a11ac180 /llvm/utils/TableGen/ClangDiagnosticsEmitter.cpp | |
parent | 256d39d47d27a2752cdfba97e2ecf03ec44bb5b3 (diff) | |
download | bcm5719-llvm-af973b4f36b4a7f171a92d89d4a9c6156276a600.tar.gz bcm5719-llvm-af973b4f36b4a7f171a92d89d4a9c6156276a600.zip |
[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.
llvm-svn: 134907
Diffstat (limited to 'llvm/utils/TableGen/ClangDiagnosticsEmitter.cpp')
-rw-r--r-- | llvm/utils/TableGen/ClangDiagnosticsEmitter.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/utils/TableGen/ClangDiagnosticsEmitter.cpp b/llvm/utils/TableGen/ClangDiagnosticsEmitter.cpp index 0a48e75681f..debed97d673 100644 --- a/llvm/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/llvm/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -74,7 +74,8 @@ getCategoryFromDiagGroup(const Record *Group, static std::string getDiagnosticCategory(const Record *R, DiagGroupParentMap &DiagGroupParents) { // If the diagnostic is in a group, and that group has a category, use it. - if (DefInit *Group = dynamic_cast<DefInit*>(R->getValueInit("Group"))) { + if (const DefInit *Group = + dynamic_cast<const DefInit*>(R->getValueInit("Group"))) { // Check the diagnostic's diag group for a category. std::string CatName = getCategoryFromDiagGroup(Group->getDef(), DiagGroupParents); @@ -159,7 +160,8 @@ void ClangDiagsDefsEmitter::run(raw_ostream &OS) { OS.write_escaped(R.getValueAsString("Text")) << '"'; // Warning associated with the diagnostic. - if (DefInit *DI = dynamic_cast<DefInit*>(R.getValueInit("Group"))) { + if (const DefInit *DI = + dynamic_cast<const DefInit*>(R.getValueInit("Group"))) { OS << ", \""; OS.write_escaped(DI->getDef()->getValueAsString("GroupName")) << '"'; } else { @@ -225,7 +227,7 @@ void ClangDiagGroupsEmitter::run(raw_ostream &OS) { Records.getAllDerivedDefinitions("Diagnostic"); for (unsigned i = 0, e = Diags.size(); i != e; ++i) { const Record *R = Diags[i]; - DefInit *DI = dynamic_cast<DefInit*>(R->getValueInit("Group")); + const DefInit *DI = dynamic_cast<const DefInit*>(R->getValueInit("Group")); if (DI == 0) continue; std::string GroupName = DI->getDef()->getValueAsString("GroupName"); DiagsInGroup[GroupName].DiagsInGroup.push_back(R); |