Skip to content

Commit 064da42

Browse files
committed
[clang-format][NFC] Remove unneeded ST_ChildBlock in annotator
Also, remove redundant llvm:: in the annotator and return early for globstar in matchFilePath().
1 parent 93011fe commit 064da42

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

clang/lib/Format/MatchFilePath.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ bool matchFilePath(StringRef Pattern, StringRef FilePath) {
6363
if (I == EOP) // `Pattern` ends with a star.
6464
return Globstar || NoMoreSeparatorsInFilePath;
6565
if (Pattern[I] != Separator) {
66-
Globstar = false;
6766
// `Pattern` ends with a lone backslash.
6867
if (Pattern[I] == '\\' && ++I == EOP)
6968
return false;
69+
Globstar = false;
7070
}
7171
// The star is followed by a (possibly escaped) `Separator`.
7272
if (Pattern[I] == Separator) {

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ class AnnotatingParser {
137137
private:
138138
ScopeType getScopeType(const FormatToken &Token) const {
139139
switch (Token.getType()) {
140-
case TT_LambdaLBrace:
141-
return ST_ChildBlock;
142140
case TT_ClassLBrace:
143141
case TT_StructLBrace:
144142
case TT_UnionLBrace:
@@ -3395,13 +3393,13 @@ class ExpressionParser {
33953393
/// Parse unary operator expressions and surround them with fake
33963394
/// parentheses if appropriate.
33973395
void parseUnaryOperator() {
3398-
llvm::SmallVector<FormatToken *, 2> Tokens;
3396+
SmallVector<FormatToken *, 2> Tokens;
33993397
while (Current && Current->is(TT_UnaryOperator)) {
34003398
Tokens.push_back(Current);
34013399
next();
34023400
}
34033401
parse(PrecedenceArrowAndPeriod);
3404-
for (FormatToken *Token : llvm::reverse(Tokens)) {
3402+
for (FormatToken *Token : reverse(Tokens)) {
34053403
// The actual precedence doesn't matter.
34063404
addFakeParenthesis(Token, prec::Unknown);
34073405
}
@@ -3579,7 +3577,7 @@ class ExpressionParser {
35793577
void TokenAnnotator::setCommentLineLevels(
35803578
SmallVectorImpl<AnnotatedLine *> &Lines) const {
35813579
const AnnotatedLine *NextNonCommentLine = nullptr;
3582-
for (AnnotatedLine *Line : llvm::reverse(Lines)) {
3580+
for (AnnotatedLine *Line : reverse(Lines)) {
35833581
assert(Line->First);
35843582

35853583
// If the comment is currently aligned with the line immediately following
@@ -3700,7 +3698,7 @@ void TokenAnnotator::annotate(AnnotatedLine &Line) {
37003698
Line.Type = Parser.parseLine();
37013699

37023700
if (!Line.Children.empty()) {
3703-
ScopeStack.push_back(ST_ChildBlock);
3701+
ScopeStack.push_back(ST_Other);
37043702
const bool InRequiresExpression = Line.Type == LT_RequiresExpression;
37053703
for (auto &Child : Line.Children) {
37063704
if (InRequiresExpression &&

clang/lib/Format/TokenAnnotator.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ enum LineType {
3838
};
3939

4040
enum ScopeType {
41-
// Contained in child block.
42-
ST_ChildBlock,
4341
// Contained in class declaration/definition.
4442
ST_Class,
4543
// Contained in compound requirement.
4644
ST_CompoundRequirement,
47-
// Contained within other scope block (function, loop, if/else, etc).
45+
// Contained in other blocks (function, lambda, loop, if/else, child, etc).
4846
ST_Other,
4947
};
5048

0 commit comments

Comments
 (0)