31#ifndef LLVM_CLANG_SERIALIZATION_SOURCELOCATIONENCODING_H
32#define LLVM_CLANG_SERIALIZATION_SOURCELOCATIONENCODING_H
35#include "llvm/Support/MathExtras.h"
46 constexpr static unsigned UIntBits =
CHAR_BIT *
sizeof(UIntTy);
48 static UIntTy encodeRaw(UIntTy Raw) {
49 return (Raw << 1) | (Raw >> (UIntBits - 1));
51 static UIntTy decodeRaw(UIntTy Raw) {
52 return (Raw >> 1) | (Raw << (UIntBits - 1));
59 unsigned BaseModuleFileIndex);
65 unsigned BaseModuleFileIndex) {
69 return encodeRaw(
Loc.getRawEncoding());
76 assert(
Loc.getOffset() >= BaseOffset);
77 Loc =
Loc.getLocWithOffset(-BaseOffset);
81 assert(BaseModuleFileIndex < (1 << 16));
85inline std::pair<SourceLocation, unsigned>
87 unsigned ModuleFileIndex = Encoded >> 32;
93 Encoded &= llvm::maskTrailingOnes<RawLocEncoding>(32);
96 return {
Loc, ModuleFileIndex};
Defines the clang::SourceLocation class and associated facilities.
Serialized encoding of SourceLocations without context.
static RawLocEncoding encode(SourceLocation Loc, UIntTy BaseOffset, unsigned BaseModuleFileIndex)
static std::pair< SourceLocation, unsigned > decode(RawLocEncoding)
Encodes a location in the source.
static SourceLocation getFromRawEncoding(UIntTy Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
The JSON file list parser is used to communicate input to InstallAPI.