forked from OSchip/llvm-project
[Basic] Use a bitfield in SLocEntry for clarity. NFC.
llvm-svn: 253177
This commit is contained in:
parent
1d4058322d
commit
a52fa8efe6
|
@ -388,15 +388,16 @@ namespace SrcMgr {
|
|||
/// SourceManager keeps an array of these objects, and they are uniquely
|
||||
/// identified by the FileID datatype.
|
||||
class SLocEntry {
|
||||
unsigned Offset; // low bit is set for expansion info.
|
||||
unsigned Offset : 31;
|
||||
unsigned IsExpansion : 1;
|
||||
union {
|
||||
FileInfo File;
|
||||
ExpansionInfo Expansion;
|
||||
};
|
||||
public:
|
||||
unsigned getOffset() const { return Offset >> 1; }
|
||||
unsigned getOffset() const { return Offset; }
|
||||
|
||||
bool isExpansion() const { return Offset & 1; }
|
||||
bool isExpansion() const { return IsExpansion; }
|
||||
bool isFile() const { return !isExpansion(); }
|
||||
|
||||
const FileInfo &getFile() const {
|
||||
|
@ -410,15 +411,19 @@ namespace SrcMgr {
|
|||
}
|
||||
|
||||
static SLocEntry get(unsigned Offset, const FileInfo &FI) {
|
||||
assert(!(Offset & (1 << 31)) && "Offset is too large");
|
||||
SLocEntry E;
|
||||
E.Offset = Offset << 1;
|
||||
E.Offset = Offset;
|
||||
E.IsExpansion = false;
|
||||
E.File = FI;
|
||||
return E;
|
||||
}
|
||||
|
||||
static SLocEntry get(unsigned Offset, const ExpansionInfo &Expansion) {
|
||||
assert(!(Offset & (1 << 31)) && "Offset is too large");
|
||||
SLocEntry E;
|
||||
E.Offset = (Offset << 1) | 1;
|
||||
E.Offset = Offset;
|
||||
E.IsExpansion = true;
|
||||
E.Expansion = Expansion;
|
||||
return E;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue