[clang-format][NFC] Remove unneeded ST_ChildBlock in annotator

Also, remove redundant llvm:: in the annotator and return early for globstar
in matchFilePath().
This commit is contained in:
Owen Pan
2025-01-07 00:41:04 -08:00
parent 93011fe2a5
commit 064da423c3
3 changed files with 6 additions and 10 deletions

View File

@@ -63,10 +63,10 @@ bool matchFilePath(StringRef Pattern, StringRef FilePath) {
if (I == EOP) // `Pattern` ends with a star.
return Globstar || NoMoreSeparatorsInFilePath;
if (Pattern[I] != Separator) {
Globstar = false;
// `Pattern` ends with a lone backslash.
if (Pattern[I] == '\\' && ++I == EOP)
return false;
Globstar = false;
}
// The star is followed by a (possibly escaped) `Separator`.
if (Pattern[I] == Separator) {

View File

@@ -137,8 +137,6 @@ public:
private:
ScopeType getScopeType(const FormatToken &Token) const {
switch (Token.getType()) {
case TT_LambdaLBrace:
return ST_ChildBlock;
case TT_ClassLBrace:
case TT_StructLBrace:
case TT_UnionLBrace:
@@ -3395,13 +3393,13 @@ private:
/// Parse unary operator expressions and surround them with fake
/// parentheses if appropriate.
void parseUnaryOperator() {
llvm::SmallVector<FormatToken *, 2> Tokens;
SmallVector<FormatToken *, 2> Tokens;
while (Current && Current->is(TT_UnaryOperator)) {
Tokens.push_back(Current);
next();
}
parse(PrecedenceArrowAndPeriod);
for (FormatToken *Token : llvm::reverse(Tokens)) {
for (FormatToken *Token : reverse(Tokens)) {
// The actual precedence doesn't matter.
addFakeParenthesis(Token, prec::Unknown);
}
@@ -3579,7 +3577,7 @@ private:
void TokenAnnotator::setCommentLineLevels(
SmallVectorImpl<AnnotatedLine *> &Lines) const {
const AnnotatedLine *NextNonCommentLine = nullptr;
for (AnnotatedLine *Line : llvm::reverse(Lines)) {
for (AnnotatedLine *Line : reverse(Lines)) {
assert(Line->First);
// If the comment is currently aligned with the line immediately following
@@ -3700,7 +3698,7 @@ void TokenAnnotator::annotate(AnnotatedLine &Line) {
Line.Type = Parser.parseLine();
if (!Line.Children.empty()) {
ScopeStack.push_back(ST_ChildBlock);
ScopeStack.push_back(ST_Other);
const bool InRequiresExpression = Line.Type == LT_RequiresExpression;
for (auto &Child : Line.Children) {
if (InRequiresExpression &&

View File

@@ -38,13 +38,11 @@ enum LineType {
};
enum ScopeType {
// Contained in child block.
ST_ChildBlock,
// Contained in class declaration/definition.
ST_Class,
// Contained in compound requirement.
ST_CompoundRequirement,
// Contained within other scope block (function, loop, if/else, etc).
// Contained in other blocks (function, lambda, loop, if/else, child, etc).
ST_Other,
};