]> granicus.if.org Git - clang/commitdiff
AST: Simplify CharUnits::alignmentAtOffset
authorDavid Majnemer <david.majnemer@gmail.com>
Tue, 25 Feb 2014 01:47:33 +0000 (01:47 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Tue, 25 Feb 2014 01:47:33 +0000 (01:47 +0000)
CharUnits::alignmentAtOffset is equivalent to llvm::MinAlign but
slightly less efficient.  Use it's implementation instead.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202099 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/CharUnits.h

index 69dee4cdf67d964b883e323148698fc8768088f6..72ca9f5cd67d55b5de567466218a1dc1e9009201 100644 (file)
@@ -173,12 +173,7 @@ namespace clang {
       /// 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);
+        return CharUnits(llvm::MinAlign(Quantity, offset.Quantity));
       }