]> granicus.if.org Git - clang/commitdiff
Stop abusing StringRef. Fixes the Windows build.
authorSean Hunt <scshunt@csclub.uwaterloo.ca>
Tue, 19 Jun 2012 13:36:02 +0000 (13:36 +0000)
committerSean Hunt <scshunt@csclub.uwaterloo.ca>
Tue, 19 Jun 2012 13:36:02 +0000 (13:36 +0000)
I've also removed the duplicate check for PARSED_ATTR since it seems
unnecessary, and would have made the code more complicated.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158716 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/ClangAttrEmitter.cpp

index 61f07e2db79c50804da5e9afc5e98ca551233d81..0df566f7123f061e0ad3b92d22abecc603edef6e 100644 (file)
@@ -966,7 +966,8 @@ void EmitClangAttrSpellingList(RecordKeeper &Records, raw_ostream &OS) {
     std::vector<Record*> Spellings = Attr.getValueAsListOfDefs("Spellings");
 
     for (std::vector<Record*>::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) {
-      StringRef Spelling = (*I)->getValueAsString("Name");
+      SmallString<64> Spelling;
+      Spelling += (*I)->getValueAsString("Name");
       OS << ".Case(\"" << Spelling << "\", true)\n";
     }
   }
@@ -1074,6 +1075,9 @@ void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS) {
      << "} // end namespace clang\n";
 }
 
+}
+#include <cstdio>
+namespace clang {
 // Emits the list of parsed attributes.
 void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) {
   OS << "// This file is generated by TableGen. Do not edit.\n\n";
@@ -1083,7 +1087,6 @@ void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) {
   OS << "#endif\n\n";
   
   std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr");
-  std::set<StringRef> ProcessedAttrs;
 
   for (std::vector<Record*>::iterator I = Attrs.begin(), E = Attrs.end();
        I != E; ++I) {
@@ -1098,16 +1101,12 @@ void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) {
         
         for (std::vector<Record*>::const_iterator I = Spellings.begin(),
              E = Spellings.end(); I != E; ++I) {
-          StringRef AttrName = (*I)->getValueAsString("Name");
+          SmallString<64> AttrName;
+          AttrName += (*I)->getValueAsString("Name");
 
-          AttrName = NormalizeAttrName(AttrName);
-          // skip if a normalized version has been processed.
-          if (ProcessedAttrs.find(AttrName) != ProcessedAttrs.end())
-            continue;
-          else
-            ProcessedAttrs.insert(AttrName);
+          StringRef Spelling = NormalizeAttrName(AttrName);
 
-          OS << "PARSED_ATTR(" << AttrName << ")\n";
+          OS << "PARSED_ATTR(" << Spelling << ")\n";
         }
       } else {
         StringRef AttrName = Attr.getName();
@@ -1138,9 +1137,10 @@ void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) {
 
       for (std::vector<Record*>::const_iterator I = Spellings.begin(),
            E = Spellings.end(); I != E; ++I) {
-        StringRef RawSpelling = (*I)->getValueAsString("Name");
+        SmallString<64> RawSpelling;
+        RawSpelling += (*I)->getValueAsString("Name");
         StringRef AttrName = NormalizeAttrName(DistinctSpellings
-                                                 ? RawSpelling
+                                                 ? StringRef(RawSpelling)
                                                  : StringRef(Attr.getName()));
 
         SmallString<64> Spelling;