]> granicus.if.org Git - clang/commitdiff
Fixed a VC++ issue related to bitmasks. As it turns out the compiler fills the unused...
authorHartmut Kaiser <hartmut.kaiser@gmail.com>
Mon, 17 Sep 2007 21:11:08 +0000 (21:11 +0000)
committerHartmut Kaiser <hartmut.kaiser@gmail.com>
Mon, 17 Sep 2007 21:11:08 +0000 (21:11 +0000)
Please review.

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

include/clang/AST/Type.h

index 9c853e321b293b94c472c9d1b93ea69064b79b74..d99babb4c1301560606de9112b9f5fce81ed9bde 100644 (file)
@@ -222,7 +222,10 @@ protected:
   virtual ~Type();
   friend class ASTContext;
 public:
-  TypeClass getTypeClass() const { return TC; }
+  // Masking the 4 bits from the bitfield above is necessary, since at least
+  // VC++ fills the unused bits of the word the bitfield is stored in with
+  // '1' resulting in invalid values returned from this function otherwise.
+  TypeClass getTypeClass() const { return static_cast<TypeClass>(TC & 0xf); }
   
   bool isCanonical() const { return CanonicalType.getTypePtr() == this; }