Skip to content

Commit 561c7eb

Browse files
committed
clang-format
1 parent b0ce196 commit 561c7eb

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

llvm/lib/Support/Mustache.cpp

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ Token::Type Token::getTokenType(char Identifier) {
9191

9292
// Function to check if there's no meaningful text behind
9393
bool noTextBehind(size_t Idx, const SmallVector<Token, 0> &Tokens) {
94-
if(Idx == 0)
94+
if (Idx == 0)
9595
return false;
96-
96+
9797
int PrevIdx = Idx - 1;
9898
if (Tokens[PrevIdx].getType() != Token::Type::Text)
9999
return false;
100-
100+
101101
const Token &PrevToken = Tokens[Idx - 1];
102102
StringRef TokenBody = PrevToken.getRawBody().rtrim(" \t\v\t");
103103
// We make an exception for when previous token is empty
@@ -113,11 +113,11 @@ bool noTextBehind(size_t Idx, const SmallVector<Token, 0> &Tokens) {
113113
bool noTextAhead(size_t Idx, const SmallVector<Token, 0> &Tokens) {
114114
if (Idx >= Tokens.size() - 1)
115115
return false;
116-
116+
117117
int PrevIdx = Idx + 1;
118118
if (Tokens[Idx + 1].getType() != Token::Type::Text)
119119
return false;
120-
120+
121121
const Token &NextToken = Tokens[Idx + 1];
122122
StringRef TokenBody = NextToken.getRawBody().ltrim(" ");
123123
return TokenBody.starts_with("\r\n") || TokenBody.starts_with("\n");
@@ -136,7 +136,7 @@ bool requiresCleanUp(Token::Type T) {
136136
// "{{! Comment }} \nLine 2"
137137
// would be considered as no text ahead and should be render as
138138
// " Line 2"
139-
void stripTokenAhead(SmallVector<Token, 0>& Tokens, size_t Idx) {
139+
void stripTokenAhead(SmallVector<Token, 0> &Tokens, size_t Idx) {
140140
Token &NextToken = Tokens[Idx + 1];
141141
StringRef NextTokenBody = NextToken.getTokenBody();
142142
// cut off the leading newline which could be \n or \r\n
@@ -154,10 +154,8 @@ void stripTokenAhead(SmallVector<Token, 0>& Tokens, size_t Idx) {
154154
// "A"
155155
// The exception for this is partial tag which requires us to
156156
// keep track of the indentation once it's rendered
157-
void stripTokenBefore(SmallVector<Token, 0>& Tokens,
158-
size_t Idx,
159-
Token& CurrentToken,
160-
Token::Type CurrentType) {
157+
void stripTokenBefore(SmallVector<Token, 0> &Tokens, size_t Idx,
158+
Token &CurrentToken, Token::Type CurrentType) {
161159
Token &PrevToken = Tokens[Idx - 1];
162160
StringRef PrevTokenBody = PrevToken.getTokenBody();
163161
StringRef Unindented = PrevTokenBody.rtrim(" \t\v");
@@ -228,20 +226,20 @@ SmallVector<Token, 0> tokenize(StringRef Template) {
228226
if (!RequiresCleanUp)
229227
continue;
230228

231-
// We adjust the token body if there's no text behind or ahead.
229+
// We adjust the token body if there's no text behind or ahead.
232230
// A token is considered to have no text ahead if the right of the previous
233231
// token is a newline followed by spaces.
234-
// A token is considered to have no text behind if the left of the next
232+
// A token is considered to have no text behind if the left of the next
235233
// token is spaces followed by a newline.
236234
// eg.
237235
// "Line 1\n {{#section}} \n Line 2 \n {{/section}} \n Line 3"
238236
bool NoTextBehind = noTextBehind(Idx, Tokens);
239237
bool NoTextAhead = noTextAhead(Idx, Tokens);
240-
238+
241239
if ((NoTextBehind && NoTextAhead) || (NoTextAhead && Idx == 0)) {
242240
stripTokenAhead(Tokens, Idx);
243241
}
244-
242+
245243
if (((NoTextBehind && NoTextAhead) || (NoTextBehind && Idx == LastIdx))) {
246244
stripTokenBefore(Tokens, Idx, CurrentToken, CurrentType);
247245
}
@@ -346,7 +344,7 @@ StringRef Template::render(Value &Data) {
346344
void Template::registerPartial(StringRef Name, StringRef Partial) {
347345
Parser P = Parser(Partial, Allocator);
348346
ASTNode *PartialTree = P.parse();
349-
PartialTree->setUpNode(LocalAllocator, Partials, Lambdas, SectionLambdas,
347+
PartialTree->setUpNode(LocalAllocator, Partials, Lambdas, SectionLambdas,
350348
Escapes);
351349
Partials.insert(std::make_pair(Name, PartialTree));
352350
}
@@ -369,8 +367,7 @@ Template::Template(StringRef TemplateStr) {
369367
{'"', "&quot;"},
370368
{'\'', "&#39;"}};
371369
registerEscape(HtmlEntities);
372-
Tree->setUpNode(LocalAllocator,
373-
Partials, Lambdas, SectionLambdas, Escapes);
370+
Tree->setUpNode(LocalAllocator, Partials, Lambdas, SectionLambdas, Escapes);
374371
}
375372

376373
void toJsonString(const Value &Data, SmallString<0> &Output) {
@@ -531,7 +528,7 @@ void ASTNode::renderLambdas(const Value &Contexts, SmallString<0> &Output,
531528
toJsonString(LambdaResult, LambdaStr);
532529
Parser P = Parser(LambdaStr, *Allocator);
533530
ASTNode *LambdaNode = P.parse();
534-
LambdaNode->setUpNode(*Allocator, *Partials, *Lambdas, *SectionLambdas,
531+
LambdaNode->setUpNode(*Allocator, *Partials, *Lambdas, *SectionLambdas,
535532
*Escapes);
536533
LambdaNode->render(Contexts, Output);
537534
if (T == Variable)
@@ -548,7 +545,7 @@ void ASTNode::renderSectionLambdas(const Value &Contexts,
548545
toJsonString(Return, LambdaStr);
549546
Parser P = Parser(LambdaStr, *Allocator);
550547
ASTNode *LambdaNode = P.parse();
551-
LambdaNode->setUpNode(*Allocator, *Partials, *Lambdas, *SectionLambdas,
548+
LambdaNode->setUpNode(*Allocator, *Partials, *Lambdas, *SectionLambdas,
552549
*Escapes);
553550
LambdaNode->render(Contexts, Output);
554551
return;
@@ -568,4 +565,3 @@ void ASTNode::setUpNode(llvm::BumpPtrAllocator &Alloc,
568565
for (ASTNode *Child : Children)
569566
Child->setUpNode(Alloc, Par, L, SC, E);
570567
}
571-

0 commit comments

Comments
 (0)