Bug Summary

File:clang/lib/Format/QualifierAlignmentFixer.cpp
Warning:line 263, column 9
Value stored to 'Next' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name QualifierAlignmentFixer.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mframe-pointer=none -relaxed-aliasing -fmath-errno -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -ffunction-sections -fdata-sections -fcoverage-compilation-dir=/build/llvm-toolchain-snapshot-14~++20211016100712+8e1d532707fd/build-llvm -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -D CLANG_ROUND_TRIP_CC1_ARGS=ON -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I tools/clang/lib/Format -I /build/llvm-toolchain-snapshot-14~++20211016100712+8e1d532707fd/clang/lib/Format -I /build/llvm-toolchain-snapshot-14~++20211016100712+8e1d532707fd/clang/include -I tools/clang/include -I include -I /build/llvm-toolchain-snapshot-14~++20211016100712+8e1d532707fd/llvm/include -D NDEBUG -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wno-comment -std=c++14 -fdeprecated-macro -fdebug-compilation-dir=/build/llvm-toolchain-snapshot-14~++20211016100712+8e1d532707fd/build-llvm -ferror-limit 19 -fvisibility-inlines-hidden -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2021-10-17-004846-21170-1 -x c++ /build/llvm-toolchain-snapshot-14~++20211016100712+8e1d532707fd/clang/lib/Format/QualifierAlignmentFixer.cpp
1//===--- LeftRightQualifierAlignmentFixer.cpp -------------------*- C++--*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file implements LeftRightQualifierAlignmentFixer, a TokenAnalyzer that
11/// enforces either left or right const depending on the style.
12///
13//===----------------------------------------------------------------------===//
14
15#include "QualifierAlignmentFixer.h"
16#include "FormatToken.h"
17#include "llvm/Support/Debug.h"
18#include "llvm/Support/Regex.h"
19
20#include <algorithm>
21
22#define DEBUG_TYPE"format-qualifier-alignment-fixer" "format-qualifier-alignment-fixer"
23
24namespace clang {
25namespace format {
26
27QualifierAlignmentFixer::QualifierAlignmentFixer(
28 const Environment &Env, const FormatStyle &Style, StringRef &Code,
29 ArrayRef<tooling::Range> Ranges, unsigned FirstStartColumn,
30 unsigned NextStartColumn, unsigned LastStartColumn, StringRef FileName)
31 : TokenAnalyzer(Env, Style), Code(Code), Ranges(Ranges),
32 FirstStartColumn(FirstStartColumn), NextStartColumn(NextStartColumn),
33 LastStartColumn(LastStartColumn), FileName(FileName) {
34 std::vector<std::string> LeftOrder;
35 std::vector<std::string> RightOrder;
36 std::vector<tok::TokenKind> ConfiguredQualifierTokens;
37 PrepareLeftRightOrdering(Style.QualifierOrder, LeftOrder, RightOrder,
38 ConfiguredQualifierTokens);
39
40 // Handle the left and right Alignment Seperately
41 for (const auto &Qualifier : LeftOrder) {
42 Passes.emplace_back(
43 [&, Qualifier, ConfiguredQualifierTokens](const Environment &Env) {
44 return LeftRightQualifierAlignmentFixer(Env, Style, Qualifier,
45 ConfiguredQualifierTokens,
46 /*RightAlign=*/false)
47 .process();
48 });
49 }
50 for (const auto &Qualifier : RightOrder) {
51 Passes.emplace_back(
52 [&, Qualifier, ConfiguredQualifierTokens](const Environment &Env) {
53 return LeftRightQualifierAlignmentFixer(Env, Style, Qualifier,
54 ConfiguredQualifierTokens,
55 /*RightAlign=*/true)
56 .process();
57 });
58 }
59}
60
61std::pair<tooling::Replacements, unsigned> QualifierAlignmentFixer::analyze(
62 TokenAnnotator &Annotator, SmallVectorImpl<AnnotatedLine *> &AnnotatedLines,
63 FormatTokenLexer &Tokens) {
64
65 auto Env =
66 std::make_unique<Environment>(Code, FileName, Ranges, FirstStartColumn,
67 NextStartColumn, LastStartColumn);
68 llvm::Optional<std::string> CurrentCode = None;
69 tooling::Replacements Fixes;
70 for (size_t I = 0, E = Passes.size(); I < E; ++I) {
71 std::pair<tooling::Replacements, unsigned> PassFixes = Passes[I](*Env);
72 auto NewCode = applyAllReplacements(
73 CurrentCode ? StringRef(*CurrentCode) : Code, PassFixes.first);
74 if (NewCode) {
75 Fixes = Fixes.merge(PassFixes.first);
76 if (I + 1 < E) {
77 CurrentCode = std::move(*NewCode);
78 Env = std::make_unique<Environment>(
79 *CurrentCode, FileName,
80 tooling::calculateRangesAfterReplacements(Fixes, Ranges),
81 FirstStartColumn, NextStartColumn, LastStartColumn);
82 }
83 }
84 }
85
86 // Don't make replacements that replace nothing.
87 tooling::Replacements NonNoOpFixes;
88
89 for (auto I = Fixes.begin(), E = Fixes.end(); I != E; ++I) {
90 StringRef OriginalCode = Code.substr(I->getOffset(), I->getLength());
91
92 if (!OriginalCode.equals(I->getReplacementText())) {
93 auto Err = NonNoOpFixes.add(*I);
94 if (Err)
95 llvm::errs() << "Error adding replacements : "
96 << llvm::toString(std::move(Err)) << "\n";
97 }
98 }
99 return {NonNoOpFixes, 0};
100}
101
102static void replaceToken(const SourceManager &SourceMgr,
103 tooling::Replacements &Fixes,
104 const CharSourceRange &Range, std::string NewText) {
105 auto Replacement = tooling::Replacement(SourceMgr, Range, NewText);
106 auto Err = Fixes.add(Replacement);
107
108 if (Err)
109 llvm::errs() << "Error while rearranging Qualifier : "
110 << llvm::toString(std::move(Err)) << "\n";
111}
112
113static void removeToken(const SourceManager &SourceMgr,
114 tooling::Replacements &Fixes,
115 const FormatToken *First) {
116 auto Range = CharSourceRange::getCharRange(First->getStartOfNonWhitespace(),
117 First->Tok.getEndLoc());
118 replaceToken(SourceMgr, Fixes, Range, "");
119}
120
121static void insertQualifierAfter(const SourceManager &SourceMgr,
122 tooling::Replacements &Fixes,
123 const FormatToken *First,
124 const std::string &Qualifier) {
125 FormatToken *Next = First->Next;
126 if (!Next)
127 return;
128 auto Range = CharSourceRange::getCharRange(Next->getStartOfNonWhitespace(),
129 Next->Tok.getEndLoc());
130
131 std::string NewText = " " + Qualifier + " ";
132 NewText += Next->TokenText;
133 replaceToken(SourceMgr, Fixes, Range, NewText);
134}
135
136static void insertQualifierBefore(const SourceManager &SourceMgr,
137 tooling::Replacements &Fixes,
138 const FormatToken *First,
139 const std::string &Qualifier) {
140 auto Range = CharSourceRange::getCharRange(First->getStartOfNonWhitespace(),
141 First->Tok.getEndLoc());
142
143 std::string NewText = " " + Qualifier + " ";
144 NewText += First->TokenText;
145
146 replaceToken(SourceMgr, Fixes, Range, NewText);
147}
148
149static bool endsWithSpace(const std::string &s) {
150 if (s.empty()) {
151 return false;
152 }
153 return isspace(s.back());
154}
155
156static bool startsWithSpace(const std::string &s) {
157 if (s.empty()) {
158 return false;
159 }
160 return isspace(s.front());
161}
162
163static void rotateTokens(const SourceManager &SourceMgr,
164 tooling::Replacements &Fixes, const FormatToken *First,
165 const FormatToken *Last, bool Left) {
166 auto *End = Last;
167 auto *Begin = First;
168 if (!Left) {
169 End = Last->Next;
170 Begin = First->Next;
171 }
172
173 std::string NewText;
174 // If we are rotating to the left we move the Last token to the front.
175 if (Left) {
176 NewText += Last->TokenText;
177 NewText += " ";
178 }
179
180 // Then move through the other tokens.
181 auto *Tok = Begin;
182 while (Tok != End) {
183 if (!NewText.empty() && !endsWithSpace(NewText)) {
184 NewText += " ";
185 }
186
187 NewText += Tok->TokenText;
188 Tok = Tok->Next;
189 }
190
191 // If we are rotating to the right we move the first token to the back.
192 if (!Left) {
193 if (!NewText.empty() && !startsWithSpace(NewText)) {
194 NewText += " ";
195 }
196 NewText += First->TokenText;
197 }
198
199 auto Range = CharSourceRange::getCharRange(First->getStartOfNonWhitespace(),
200 Last->Tok.getEndLoc());
201
202 replaceToken(SourceMgr, Fixes, Range, NewText);
203}
204
205FormatToken *LeftRightQualifierAlignmentFixer::analyzeRight(
206 const SourceManager &SourceMgr, const AdditionalKeywords &Keywords,
207 tooling::Replacements &Fixes, FormatToken *Tok,
208 const std::string &Qualifier, tok::TokenKind QualifierType) {
209 // We only need to think about streams that begin with a qualifier.
210 if (!Tok->is(QualifierType))
211 return Tok;
212 // Don't concern yourself if nothing follows the qualifier.
213 if (!Tok->Next)
214 return Tok;
215 if (LeftRightQualifierAlignmentFixer::isPossibleMacro(Tok->Next))
216 return Tok;
217
218 FormatToken *Qual = Tok->Next;
219 FormatToken *LastQual = Qual;
220 while (Qual && isQualifierOrType(Qual, ConfiguredQualifierTokens)) {
221 LastQual = Qual;
222 Qual = Qual->Next;
223 }
224 if (LastQual && Qual != LastQual) {
225 rotateTokens(SourceMgr, Fixes, Tok, LastQual, /*Left=*/false);
226 Tok = LastQual;
227 } else if (Tok->startsSequence(QualifierType, tok::identifier,
228 TT_TemplateOpener)) {
229 // Read from the TemplateOpener to
230 // TemplateCloser as in const ArrayRef<int> a; const ArrayRef<int> &a;
231 FormatToken *EndTemplate = Tok->Next->Next->MatchingParen;
232 if (EndTemplate) {
233 // Move to the end of any template class members e.g.
234 // `Foo<int>::iterator`.
235 if (EndTemplate->startsSequence(TT_TemplateCloser, tok::coloncolon,
236 tok::identifier))
237 EndTemplate = EndTemplate->Next->Next;
238 }
239 if (EndTemplate && EndTemplate->Next &&
240 !EndTemplate->Next->isOneOf(tok::equal, tok::l_paren)) {
241 insertQualifierAfter(SourceMgr, Fixes, EndTemplate, Qualifier);
242 // Remove the qualifier.
243 removeToken(SourceMgr, Fixes, Tok);
244 return Tok;
245 }
246 } else if (Tok->startsSequence(QualifierType, tok::identifier)) {
247 FormatToken *Next = Tok->Next;
248 // The case `const Foo` -> `Foo const`
249 // The case `const Foo *` -> `Foo const *`
250 // The case `const Foo &` -> `Foo const &`
251 // The case `const Foo &&` -> `Foo const &&`
252 // The case `const std::Foo &&` -> `std::Foo const &&`
253 // The case `const std::Foo<T> &&` -> `std::Foo<T> const &&`
254 while (Next && Next->isOneOf(tok::identifier, tok::coloncolon)) {
255 Next = Next->Next;
256 }
257 if (Next && Next->is(TT_TemplateOpener)) {
258 Next = Next->MatchingParen;
259 // Move to the end of any template class members e.g.
260 // `Foo<int>::iterator`.
261 if (Next && Next->startsSequence(TT_TemplateCloser, tok::coloncolon,
262 tok::identifier)) {
263 Next = Next->Next->Next;
Value stored to 'Next' is never read
264 return Tok;
265 }
266 assert(Next && "Missing template opener")(static_cast <bool> (Next && "Missing template opener"
) ? void (0) : __assert_fail ("Next && \"Missing template opener\""
, "/build/llvm-toolchain-snapshot-14~++20211016100712+8e1d532707fd/clang/lib/Format/QualifierAlignmentFixer.cpp"
, 266, __extension__ __PRETTY_FUNCTION__))
;
267 Next = Next->Next;
268 }
269 if (Next && Next->isOneOf(tok::star, tok::amp, tok::ampamp) &&
270 !Tok->Next->isOneOf(Keywords.kw_override, Keywords.kw_final)) {
271 if (Next->Previous && !Next->Previous->is(QualifierType)) {
272 insertQualifierAfter(SourceMgr, Fixes, Next->Previous, Qualifier);
273 removeToken(SourceMgr, Fixes, Tok);
274 }
275 return Next;
276 }
277 }
278
279 return Tok;
280}
281
282FormatToken *LeftRightQualifierAlignmentFixer::analyzeLeft(
283 const SourceManager &SourceMgr, const AdditionalKeywords &Keywords,
284 tooling::Replacements &Fixes, FormatToken *Tok,
285 const std::string &Qualifier, tok::TokenKind QualifierType) {
286 // if Tok is an identifier and possibly a macro then don't convert.
287 if (LeftRightQualifierAlignmentFixer::isPossibleMacro(Tok))
288 return Tok;
289
290 FormatToken *Qual = Tok;
291 FormatToken *LastQual = Qual;
292 while (Qual && isQualifierOrType(Qual, ConfiguredQualifierTokens)) {
293 LastQual = Qual;
294 Qual = Qual->Next;
295 if (Qual && Qual->is(QualifierType))
296 break;
297 }
298
299 if (!Qual) {
300 return Tok;
301 }
302
303 if (LastQual && Qual != LastQual && Qual->is(QualifierType)) {
304 rotateTokens(SourceMgr, Fixes, Tok, Qual, /*Left=*/true);
305 Tok = Qual->Next;
306 } else if (Tok->startsSequence(tok::identifier, QualifierType)) {
307 if (Tok->Next->Next && Tok->Next->Next->isOneOf(tok::identifier, tok::star,
308 tok::amp, tok::ampamp)) {
309 // Don't swap `::iterator const` to `::const iterator`.
310 if (!Tok->Previous ||
311 (Tok->Previous && !Tok->Previous->is(tok::coloncolon))) {
312 rotateTokens(SourceMgr, Fixes, Tok, Tok->Next, /*Left=*/true);
313 Tok = Tok->Next;
314 }
315 }
316 }
317 if (Tok->is(TT_TemplateOpener) && Tok->Next &&
318 (Tok->Next->is(tok::identifier) || Tok->Next->isSimpleTypeSpecifier()) &&
319 Tok->Next->Next && Tok->Next->Next->is(QualifierType)) {
320 rotateTokens(SourceMgr, Fixes, Tok->Next, Tok->Next->Next, /*Left=*/true);
321 }
322 if (Tok->startsSequence(tok::identifier) && Tok->Next) {
323 if (Tok->Previous &&
324 Tok->Previous->isOneOf(tok::star, tok::ampamp, tok::amp)) {
325 return Tok;
326 }
327 FormatToken *Next = Tok->Next;
328 // The case `std::Foo<T> const` -> `const std::Foo<T> &&`
329 while (Next && Next->isOneOf(tok::identifier, tok::coloncolon))
330 Next = Next->Next;
331 if (Next && Next->Previous &&
332 Next->Previous->startsSequence(tok::identifier, TT_TemplateOpener)) {
333 // Read from to the end of the TemplateOpener to
334 // TemplateCloser const ArrayRef<int> a; const ArrayRef<int> &a;
335 assert(Next->MatchingParen && "Missing template closer")(static_cast <bool> (Next->MatchingParen && "Missing template closer"
) ? void (0) : __assert_fail ("Next->MatchingParen && \"Missing template closer\""
, "/build/llvm-toolchain-snapshot-14~++20211016100712+8e1d532707fd/clang/lib/Format/QualifierAlignmentFixer.cpp"
, 335, __extension__ __PRETTY_FUNCTION__))
;
336 Next = Next->MatchingParen->Next;
337
338 // Move to the end of any template class members e.g.
339 // `Foo<int>::iterator`.
340 if (Next && Next->startsSequence(tok::coloncolon, tok::identifier))
341 Next = Next->Next->Next;
342 if (Next && Next->is(QualifierType)) {
343 // Remove the const.
344 insertQualifierBefore(SourceMgr, Fixes, Tok, Qualifier);
345 removeToken(SourceMgr, Fixes, Next);
346 return Next;
347 }
348 }
349 if (Next && Next->Next &&
350 Next->Next->isOneOf(tok::amp, tok::ampamp, tok::star)) {
351 if (Next->is(QualifierType)) {
352 // Remove the qualifier.
353 insertQualifierBefore(SourceMgr, Fixes, Tok, Qualifier);
354 removeToken(SourceMgr, Fixes, Next);
355 return Next;
356 }
357 }
358 }
359 return Tok;
360}
361
362tok::TokenKind LeftRightQualifierAlignmentFixer::getTokenFromQualifier(
363 const std::string &Qualifier) {
364 // Don't let 'type' be an identifier, but steal typeof token.
365 return llvm::StringSwitch<tok::TokenKind>(Qualifier)
366 .Case("type", tok::kw_typeof)
367 .Case("const", tok::kw_const)
368 .Case("volatile", tok::kw_volatile)
369 .Case("static", tok::kw_static)
370 .Case("inline", tok::kw_inline)
371 .Case("constexpr", tok::kw_constexpr)
372 .Case("restrict", tok::kw_restrict)
373 .Default(tok::identifier);
374}
375
376LeftRightQualifierAlignmentFixer::LeftRightQualifierAlignmentFixer(
377 const Environment &Env, const FormatStyle &Style,
378 const std::string &Qualifier,
379 const std::vector<tok::TokenKind> &QualifierTokens, bool RightAlign)
380 : TokenAnalyzer(Env, Style), Qualifier(Qualifier), RightAlign(RightAlign),
381 ConfiguredQualifierTokens(QualifierTokens) {}
382
383std::pair<tooling::Replacements, unsigned>
384LeftRightQualifierAlignmentFixer::analyze(
385 TokenAnnotator &Annotator, SmallVectorImpl<AnnotatedLine *> &AnnotatedLines,
386 FormatTokenLexer &Tokens) {
387 tooling::Replacements Fixes;
388 const AdditionalKeywords &Keywords = Tokens.getKeywords();
389 const SourceManager &SourceMgr = Env.getSourceManager();
390 AffectedRangeMgr.computeAffectedLines(AnnotatedLines);
391
392 tok::TokenKind QualifierToken = getTokenFromQualifier(Qualifier);
393 assert(QualifierToken != tok::identifier && "Unrecognised Qualifier")(static_cast <bool> (QualifierToken != tok::identifier &&
"Unrecognised Qualifier") ? void (0) : __assert_fail ("QualifierToken != tok::identifier && \"Unrecognised Qualifier\""
, "/build/llvm-toolchain-snapshot-14~++20211016100712+8e1d532707fd/clang/lib/Format/QualifierAlignmentFixer.cpp"
, 393, __extension__ __PRETTY_FUNCTION__))
;
394
395 for (size_t I = 0, E = AnnotatedLines.size(); I != E; ++I) {
396 FormatToken *First = AnnotatedLines[I]->First;
397 const auto *Last = AnnotatedLines[I]->Last;
398
399 for (auto *Tok = First; Tok && Tok != Last && Tok->Next; Tok = Tok->Next) {
400 if (Tok->is(tok::comment))
401 continue;
402 if (RightAlign)
403 Tok = analyzeRight(SourceMgr, Keywords, Fixes, Tok, Qualifier,
404 QualifierToken);
405 else
406 Tok = analyzeLeft(SourceMgr, Keywords, Fixes, Tok, Qualifier,
407 QualifierToken);
408 }
409 }
410 return {Fixes, 0};
411}
412
413void QualifierAlignmentFixer::PrepareLeftRightOrdering(
414 const std::vector<std::string> &Order, std::vector<std::string> &LeftOrder,
415 std::vector<std::string> &RightOrder,
416 std::vector<tok::TokenKind> &Qualifiers) {
417
418 // Depending on the position of type in the order you need
419 // To iterate forward or backward through the order list as qualifier
420 // can push through each other.
421 // The Order list must define the position of "type" to signify
422 assert(llvm::is_contained(Order, "type") &&(static_cast <bool> (llvm::is_contained(Order, "type") &&
"QualifierOrder must contain type") ? void (0) : __assert_fail
("llvm::is_contained(Order, \"type\") && \"QualifierOrder must contain type\""
, "/build/llvm-toolchain-snapshot-14~++20211016100712+8e1d532707fd/clang/lib/Format/QualifierAlignmentFixer.cpp"
, 423, __extension__ __PRETTY_FUNCTION__))
423 "QualifierOrder must contain type")(static_cast <bool> (llvm::is_contained(Order, "type") &&
"QualifierOrder must contain type") ? void (0) : __assert_fail
("llvm::is_contained(Order, \"type\") && \"QualifierOrder must contain type\""
, "/build/llvm-toolchain-snapshot-14~++20211016100712+8e1d532707fd/clang/lib/Format/QualifierAlignmentFixer.cpp"
, 423, __extension__ __PRETTY_FUNCTION__))
;
424 // Split the Order list by type and reverse the left side.
425
426 bool left = true;
427 for (const auto &s : Order) {
428 if (s == "type") {
429 left = false;
430 continue;
431 }
432
433 tok::TokenKind QualifierToken =
434 LeftRightQualifierAlignmentFixer::getTokenFromQualifier(s);
435 if (QualifierToken != tok::kw_typeof && QualifierToken != tok::identifier) {
436 Qualifiers.push_back(QualifierToken);
437 }
438
439 if (left)
440 // Reverse the order for left aligned items.
441 LeftOrder.insert(LeftOrder.begin(), s);
442 else
443 RightOrder.push_back(s);
444 }
445}
446
447bool LeftRightQualifierAlignmentFixer::isQualifierOrType(
448 const FormatToken *Tok, const std::vector<tok::TokenKind> &specifiedTypes) {
449 return Tok && (Tok->isSimpleTypeSpecifier() || Tok->is(tok::kw_auto) ||
450 llvm::is_contained(specifiedTypes, Tok->Tok.getKind()));
451}
452
453// If a token is an identifier and it's upper case, it could
454// be a macro and hence we need to be able to ignore it.
455bool LeftRightQualifierAlignmentFixer::isPossibleMacro(const FormatToken *Tok) {
456 if (!Tok)
457 return false;
458 if (!Tok->is(tok::identifier))
459 return false;
460 if (Tok->TokenText.upper() == Tok->TokenText.str())
461 return true;
462 return false;
463}
464
465} // namespace format
466} // namespace clang