aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Serialization/ASTBitCodes.h
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-08-20 16:03:59 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-08-20 16:03:59 +0000
commitc8e5d51f51e46c6f7717761537c6609ef9daf57c (patch)
tree504cce81c4f40422e0fe67e6f437a7cf5ad86909 /include/clang/Serialization/ASTBitCodes.h
parent0eca89e9890db4d8336ce762a5b359a1d58ca02b (diff)
serialization::TypeID is used with or without qualifiers, both as index and as index + qualifiers.
Disambiguate and provide some type safety by using a new class TypeIdx for the "TypeID as index" semantics. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111630 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Serialization/ASTBitCodes.h')
-rw-r--r--include/clang/Serialization/ASTBitCodes.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h
index 55c11e29f0..3156a36040 100644
--- a/include/clang/Serialization/ASTBitCodes.h
+++ b/include/clang/Serialization/ASTBitCodes.h
@@ -17,6 +17,7 @@
#ifndef LLVM_CLANG_FRONTEND_PCHBITCODES_H
#define LLVM_CLANG_FRONTEND_PCHBITCODES_H
+#include "clang/AST/Type.h"
#include "llvm/Bitcode/BitCodes.h"
#include "llvm/System/DataTypes.h"
@@ -64,6 +65,22 @@ namespace clang {
/// other types that have serialized representations.
typedef uint32_t TypeID;
+ /// \brief A type index; the type ID with the qualifier bits removed.
+ class TypeIdx {
+ uint32_t Idx;
+ public:
+ TypeIdx() : Idx(0) { }
+ explicit TypeIdx(uint32_t index) : Idx(index) { }
+
+ uint32_t getIndex() const { return Idx; }
+ TypeID asTypeID(unsigned FastQuals) const {
+ return (Idx << Qualifiers::FastWidth) | FastQuals;
+ }
+ static TypeIdx fromTypeID(TypeID ID) {
+ return TypeIdx(ID >> Qualifiers::FastWidth);
+ }
+ };
+
/// \brief An ID number that refers to an identifier in an AST
/// file.
typedef uint32_t IdentID;