================ @@ -43,17 +46,24 @@ namespace clang { // Macro locations have the top bit set, we rotate by one so it is the low bit. class SourceLocationEncoding { using UIntTy = SourceLocation::UIntTy; - constexpr static unsigned UIntBits = CHAR_BIT * sizeof(UIntTy); static UIntTy encodeRaw(UIntTy Raw) { - return (Raw << 1) | (Raw >> (UIntBits - 1)); + return ((Raw & llvm::maskTrailingOnes<uint64_t>(SourceLocation::Bits - 1)) + << 1) | + (Raw >> (SourceLocation::Bits - 1)); } static UIntTy decodeRaw(UIntTy Raw) { - return (Raw >> 1) | (Raw << (UIntBits - 1)); + return (Raw >> 1) | ((Raw & 1) << (SourceLocation::Bits - 1)); } public: using RawLocEncoding = uint64_t; + // 16 bits should be sufficient to store the module file index. + constexpr static unsigned ModuleFileIndexBits = 16; ---------------- ChuanqiXu9 wrote:
SGTM https://github.com/llvm/llvm-project/pull/147292 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits