[cfe-commits] r162297 - in /cfe/trunk: include/clang/AST/ExprCXX.h include/clang/Basic/OnDiskHashTable.h lib/AST/ExprCXX.cpp

Richard Smith richard-llvm at metafoo.co.uk
Tue Aug 21 11:18:06 PDT 2012


Author: rsmith
Date: Tue Aug 21 13:18:06 2012
New Revision: 162297

URL: http://llvm.org/viewvc/llvm-project?rev=162297&view=rev
Log:
Switch some realignment calculations over to llvm::RoundUpToAlignment.

Modified:
    cfe/trunk/include/clang/AST/ExprCXX.h
    cfe/trunk/include/clang/Basic/OnDiskHashTable.h
    cfe/trunk/lib/AST/ExprCXX.cpp

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=162297&r1=162296&r2=162297&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Tue Aug 21 13:18:06 2012
@@ -1281,9 +1281,9 @@
   
   /// \brief Retrieve the complete set of array-index variables.
   VarDecl **getArrayIndexVars() const {
-    unsigned ArrayIndexSize = sizeof(unsigned) * (NumCaptures + 1);
-    unsigned Align = llvm::alignOf<VarDecl*>();
-    ArrayIndexSize = (ArrayIndexSize + Align - 1) & ~(Align - 1);
+    unsigned ArrayIndexSize =
+        llvm::RoundUpToAlignment(sizeof(unsigned) * (NumCaptures + 1),
+                                 llvm::alignOf<VarDecl*>());
     return reinterpret_cast<VarDecl **>(
         reinterpret_cast<char*>(getArrayIndexStarts()) + ArrayIndexSize);
   }

Modified: cfe/trunk/include/clang/Basic/OnDiskHashTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OnDiskHashTable.h?rev=162297&r1=162296&r2=162297&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/OnDiskHashTable.h (original)
+++ cfe/trunk/include/clang/Basic/OnDiskHashTable.h Tue Aug 21 13:18:06 2012
@@ -65,8 +65,7 @@
 
 inline void Pad(raw_ostream& Out, unsigned A) {
   Offset off = (Offset) Out.tell();
-  uint32_t n = ((uintptr_t)(off+A-1) & ~(uintptr_t)(A-1)) - off;
-  for (; n ; --n)
+  for (uint32_t n = llvm::OffsetToAlignment(off, A); n; --n)
     Emit8(Out, 0);
 }
 

Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=162297&r1=162296&r2=162297&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Tue Aug 21 13:18:06 2012
@@ -880,8 +880,7 @@
   if (!ArrayIndexVars.empty()) {
     Size += sizeof(unsigned) * (Captures.size() + 1);
     // Realign for following VarDecl array.
-    unsigned Align = llvm::alignOf<VarDecl*>();
-    Size = (Size + Align - 1) & ~(Align - 1);
+    Size = llvm::RoundUpToAlignment(Size, llvm::alignOf<VarDecl*>());
     Size += sizeof(VarDecl *) * ArrayIndexVars.size();
   }
   void *Mem = Context.Allocate(Size);





More information about the cfe-commits mailing list