diff options
author | John McCall <rjmccall@apple.com> | 2013-03-07 21:37:02 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2013-03-07 21:37:02 +0000 |
commit | b1b5d0b1e817219d40617cd3b9e63b17139c2c68 (patch) | |
tree | 439c8d508e41b6f4e4ebab0a54ce78835282f97d | |
parent | bea4c3d8c4fb333bd7f5c3c174c56a733e77edb1 (diff) | |
download | bcm5719-llvm-b1b5d0b1e817219d40617cd3b9e63b17139c2c68.tar.gz bcm5719-llvm-b1b5d0b1e817219d40617cd3b9e63b17139c2c68.zip |
Add CharUnits::alignmentAtOffset.
llvm-svn: 176655
-rw-r--r-- | clang/include/clang/AST/CharUnits.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/include/clang/AST/CharUnits.h b/clang/include/clang/AST/CharUnits.h index 12e74b32be8..082c672c219 100644 --- a/clang/include/clang/AST/CharUnits.h +++ b/clang/include/clang/AST/CharUnits.h @@ -171,6 +171,17 @@ namespace clang { Align.Quantity)); } + /// Given that this is a non-zero alignment value, what is the + /// alignment at the given offset? + CharUnits alignmentAtOffset(CharUnits offset) { + // alignment: 0010000 + // offset: 1011100 + // lowBits: 0001011 + // result: 0000100 + QuantityType lowBits = (Quantity-1) & (offset.Quantity-1); + return CharUnits((lowBits + 1) & ~lowBits); + } + }; // class CharUnit } // namespace clang |