[cfe-commits] r104799 - /cfe/trunk/lib/Sema/SemaAttr.cpp

Daniel Dunbar daniel at zuster.org
Wed May 26 19:25:27 PDT 2010


Author: ddunbar
Date: Wed May 26 21:25:27 2010
New Revision: 104799

URL: http://llvm.org/viewvc/llvm-project?rev=104799&view=rev
Log:
Sema: Factor out struct for alignment stack entries.

Modified:
    cfe/trunk/lib/Sema/SemaAttr.cpp

Modified: cfe/trunk/lib/Sema/SemaAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAttr.cpp?rev=104799&r1=104798&r2=104799&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaAttr.cpp Wed May 26 21:25:27 2010
@@ -24,10 +24,15 @@
 //===----------------------------------------------------------------------===//
 
 namespace {
+  struct PackStackEntry {
+    unsigned Alignment;
+    IdentifierInfo *Name;
+  };
+
   /// PragmaPackStack - Simple class to wrap the stack used by #pragma
   /// pack.
   class PragmaPackStack {
-    typedef std::vector< std::pair<unsigned, IdentifierInfo*> > stack_ty;
+    typedef std::vector<PackStackEntry> stack_ty;
 
     /// Alignment - The current user specified alignment.
     unsigned Alignment;
@@ -45,7 +50,8 @@
     /// push - Push the current alignment onto the stack, optionally
     /// using the given \arg Name for the record, if non-zero.
     void push(IdentifierInfo *Name) {
-      Stack.push_back(std::make_pair(Alignment, Name));
+      PackStackEntry PSE = { Alignment, Name };
+      Stack.push_back(PSE);
     }
 
     /// pop - Pop a record from the stack and restore the current
@@ -62,7 +68,7 @@
 
   // If name is empty just pop top.
   if (!Name) {
-    Alignment = Stack.back().first;
+    Alignment = Stack.back().Alignment;
     Stack.pop_back();
     return true;
   }
@@ -70,9 +76,9 @@
   // Otherwise, find the named record.
   for (unsigned i = Stack.size(); i != 0; ) {
     --i;
-    if (Stack[i].second == Name) {
+    if (Stack[i].Name == Name) {
       // Found it, pop up to and including this record.
-      Alignment = Stack[i].first;
+      Alignment = Stack[i].Alignment;
       Stack.erase(Stack.begin() + i, Stack.end());
       return true;
     }





More information about the cfe-commits mailing list