[cfe-commits] r158716 - /cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Michael Han Michael.Han at autodesk.com
Tue Jun 19 10:06:21 PDT 2012


Before DistinctSpellings is introduced to Attr, the check for PARSED_ATTR was to distinguish same attribute that has more than one spelling (e.g. __const, const) so they are treated as a single attribute instead of two. With DistinctSpellings this check is duplicated and thanks for removing it..

Michael
-----Original Message-----
From: cfe-commits-bounces at cs.uiuc.edu [mailto:cfe-commits-bounces at cs.uiuc.edu] On Behalf Of Sean Hunt
Sent: Tuesday, June 19, 2012 6:36 AM
To: cfe-commits at cs.uiuc.edu
Subject: [cfe-commits] r158716 - /cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Author: coppro
Date: Tue Jun 19 08:36:02 2012
New Revision: 158716

URL: http://llvm.org/viewvc/llvm-project?rev=158716&view=rev
Log:
Stop abusing StringRef. Fixes the Windows build.

I've also removed the duplicate check for PARSED_ATTR since it seems unnecessary, and would have made the code more complicated.

Modified:
    cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=158716&r1=158715&r2=158716&view=diff
==============================================================================
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Tue Jun 19 08:36:02 
+++ 2012
@@ -966,7 +966,8 @@
     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 @@
      << "} // 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 @@
   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 @@
         
         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 @@
 
       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;


_______________________________________________
cfe-commits mailing list
cfe-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list