Skip to content

Commit 4ff4b5b

Browse files
committed
More cleanup
1 parent 3a58c88 commit 4ff4b5b

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

clang/include/clang/AST/Stmt.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ class alignas(void *) Stmt {
809809
LLVM_PREFERRED_TYPE(bool)
810810
uint64_t Value : 1;
811811

812-
/// The location of the boolean ligeral
812+
/// The location of the boolean ligeral.
813813
LLVM_PREFERRED_TYPE(SourceLocation)
814814
uint64_t Loc : SourceLocation::Bits;
815815
};
@@ -840,7 +840,7 @@ class alignas(void *) Stmt {
840840
LLVM_PREFERRED_TYPE(bool)
841841
uint64_t CapturedByCopyInLambdaWithExplicitObjectParameter : 1;
842842

843-
/// The location of the "this"
843+
/// The location of the "this".
844844
LLVM_PREFERRED_TYPE(SourceLocation)
845845
uint64_t Loc : SourceLocation::Bits;
846846
};
@@ -856,7 +856,7 @@ class alignas(void *) Stmt {
856856
LLVM_PREFERRED_TYPE(bool)
857857
uint64_t IsThrownVariableInScope : 1;
858858

859-
/// The location of the "throw"
859+
/// The location of the "throw".
860860
LLVM_PREFERRED_TYPE(SourceLocation)
861861
uint64_t ThrowLoc : SourceLocation::Bits;
862862
};
@@ -901,7 +901,6 @@ class alignas(void *) Stmt {
901901
LLVM_PREFERRED_TYPE(ExprBitfields)
902902
uint64_t : NumExprBits;
903903

904-
/// The location where the default initializer expression was used.
905904
LLVM_PREFERRED_TYPE(SourceLocation)
906905
uint64_t RParenLoc : SourceLocation::Bits;
907906
};
@@ -978,7 +977,7 @@ class alignas(void *) Stmt {
978977
LLVM_PREFERRED_TYPE(bool)
979978
uint64_t UsualArrayDeleteWantsSize : 1;
980979

981-
/// Location of the expression
980+
/// Location of the expression.
982981
LLVM_PREFERRED_TYPE(SourceLocation)
983982
uint64_t Loc : SourceLocation::Bits;
984983
};
@@ -1308,7 +1307,6 @@ class alignas(void *) Stmt {
13081307
LLVM_PREFERRED_TYPE(bool)
13091308
uint64_t IsUnique : 1;
13101309

1311-
/// The location of the non-type template parameter reference.
13121310
LLVM_PREFERRED_TYPE(SourceLocation)
13131311
uint64_t Loc : SourceLocation::Bits;
13141312
};
@@ -2182,7 +2180,7 @@ class ValueStmt : public Stmt {
21822180
class LabelStmt : public ValueStmt {
21832181
LabelDecl *TheDecl;
21842182
Stmt *SubStmt;
2185-
bool SideEntry = false; // FIXME: could improve
2183+
bool SideEntry = false;
21862184

21872185
public:
21882186
/// Build a label statement.
@@ -2545,8 +2543,12 @@ class IfStmt final
25452543
class SwitchStmt final : public Stmt,
25462544
private llvm::TrailingObjects<SwitchStmt, Stmt *> {
25472545
friend TrailingObjects;
2546+
25482547
/// Points to a linked list of case and default statements.
25492548
SwitchCase *FirstCase = nullptr;
2549+
2550+
SourceLocation LParenLoc;
2551+
SourceLocation RParenLoc;
25502552

25512553
// SwitchStmt is followed by several trailing objects,
25522554
// some of which optional. Note that it would be more convenient to
@@ -2567,8 +2569,6 @@ class SwitchStmt final : public Stmt,
25672569
// Always present.
25682570
enum { InitOffset = 0, BodyOffsetFromCond = 1 };
25692571
enum { NumMandatoryStmtPtr = 2 };
2570-
SourceLocation LParenLoc;
2571-
SourceLocation RParenLoc;
25722572

25732573
unsigned numTrailingStatements() const {
25742574
return NumMandatoryStmtPtr + hasInitStorage() + hasVarStorage();
@@ -2754,6 +2754,7 @@ class WhileStmt final : public Stmt,
27542754
//
27552755
enum { VarOffset = 0, BodyOffsetFromCond = 1 };
27562756
enum { NumMandatoryStmtPtr = 2 };
2757+
27572758
SourceLocation LParenLoc, RParenLoc;
27582759

27592760
unsigned varOffset() const { return VarOffset; }
@@ -2877,6 +2878,7 @@ class DoStmt : public Stmt {
28772878
Stmt *SubExprs[END_EXPR];
28782879
SourceLocation WhileLoc;
28792880
SourceLocation RParenLoc; // Location of final ')' in do stmt condition.
2881+
28802882
public:
28812883
DoStmt(Stmt *Body, Expr *Cond, SourceLocation DL, SourceLocation WL,
28822884
SourceLocation RP)
@@ -3187,6 +3189,7 @@ class ReturnStmt final
31873189
: public Stmt,
31883190
private llvm::TrailingObjects<ReturnStmt, const VarDecl *> {
31893191
friend TrailingObjects;
3192+
31903193
/// The return expression.
31913194
Stmt *RetExpr;
31923195

clang/include/clang/Basic/SourceLocation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ class FileID {
7171
int getOpaqueValue() const { return ID; }
7272
};
7373

74+
using FileIDAndOffset = std::pair<FileID, unsigned>;
75+
7476
/// Encodes a location in the source. The SourceManager can decode this
7577
/// to get at the full include stack, line and column information.
7678
///
@@ -224,7 +226,6 @@ inline bool operator<=(const SourceLocation &LHS, const SourceLocation &RHS) {
224226
inline bool operator>=(const SourceLocation &LHS, const SourceLocation &RHS) {
225227
return LHS.getRawEncoding() >= RHS.getRawEncoding();
226228
}
227-
using FileIDAndOffset = std::pair<FileID, unsigned>;
228229

229230
/// A trivial tuple used to represent a source range.
230231
class SourceRange {

clang/include/clang/Serialization/ASTBitCodes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ const unsigned int NUM_PREDEF_MACRO_IDS = 1;
165165

166166
/// An ID number that refers to an ObjC selector in an AST file.
167167
using SelectorID = uint64_t;
168+
static_assert(sizeof(SelectorID) >= sizeof(SourceLocation::UIntTy),
169+
"SelectorID is too small to hold the SourceLocation");
168170

169171
/// The number of predefined selector IDs.
170172
const unsigned int NUM_PREDEF_SELECTOR_IDS = 1;

clang/include/clang/Serialization/SourceLocationEncoding.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@
1515
// To achieve this, we need to encode the index of the module file into the
1616
// encoding of the source location. The encoding of the source location may be:
1717
//
18-
// |-----------------------|-----------------------|
19-
// | A | B | C |
18+
// |---------------|---------------------------|
19+
// | A | B | C |
2020
//
21-
// * A: 32 bit. The index of the module file in the module manager + 1. The +1
21+
// * A: 24 bit. The index of the module file in the module manager + 1. The +1
2222
// here is necessary since we wish 0 stands for the current module file.
23-
// * B: 31 bit. The offset of the source location to the module file containing
23+
// * B: 39 bit. The offset of the source location to the module file containing
2424
// it.
2525
// * C: The macro bit. We rotate it to the lowest bit so that we can save some
2626
// space in case the index of the module file is 0.
2727
//
28+
// Together, B and C form SourceLocation::Bits (40 bits total).
2829
//
30+
// Currently, only the lower 16 bits of A are used to store the module file
31+
// index, leaving the upper 8 bits of A unused (reserved for future use).
2932
//===----------------------------------------------------------------------===//
3033

3134
#ifndef LLVM_CLANG_SERIALIZATION_SOURCELOCATIONENCODING_H
@@ -96,7 +99,7 @@ SourceLocationEncoding::decode(RawLocEncoding Encoded) {
9699
return {SourceLocation::getFromRawEncoding(decodeRaw(Encoded)),
97100
ModuleFileIndex};
98101

99-
Encoded &= llvm::maskTrailingOnes<RawLocEncoding>((SourceLocation::Bits));
102+
Encoded &= llvm::maskTrailingOnes<RawLocEncoding>(SourceLocation::Bits);
100103
SourceLocation Loc = SourceLocation::getFromRawEncoding(decodeRaw(Encoded));
101104

102105
return {Loc, ModuleFileIndex};

0 commit comments

Comments
 (0)