aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/AST/ExprCXX.h6
-rw-r--r--include/clang/Basic/OnDiskHashTable.h3
-rw-r--r--lib/AST/ExprCXX.cpp3
3 files changed, 5 insertions, 7 deletions
diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h
index 598543757d..a2355cadbe 100644
--- a/include/clang/AST/ExprCXX.h
+++ b/include/clang/AST/ExprCXX.h
@@ -1281,9 +1281,9 @@ private:
/// \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);
}
diff --git a/include/clang/Basic/OnDiskHashTable.h b/include/clang/Basic/OnDiskHashTable.h
index 79273fcc79..66109e7b3c 100644
--- a/include/clang/Basic/OnDiskHashTable.h
+++ b/include/clang/Basic/OnDiskHashTable.h
@@ -65,8 +65,7 @@ inline void Emit64(raw_ostream& Out, uint64_t V) {
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);
}
diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp
index 97814afa18..40d218bee8 100644
--- a/lib/AST/ExprCXX.cpp
+++ b/lib/AST/ExprCXX.cpp
@@ -880,8 +880,7 @@ LambdaExpr *LambdaExpr::Create(ASTContext &Context,
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);