Skip to content

Commit 6633605

Browse files
[clang-format] Address fixme
Differential Revision: https://reviews.llvm.org/D113320
1 parent 7f92a1a commit 6633605

File tree

3 files changed

+11
-23
lines changed

3 files changed

+11
-23
lines changed

clang/lib/Format/TokenAnnotator.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ class AnnotatedLine {
5353
// left them in a different state.
5454
First->Previous = nullptr;
5555
FormatToken *Current = First;
56-
for (std::list<UnwrappedLineNode>::const_iterator I = ++Line.Tokens.begin(),
57-
E = Line.Tokens.end();
58-
I != E; ++I) {
56+
for (auto I = ++Line.Tokens.begin(), E = Line.Tokens.end(); I != E; ++I) {
5957
const UnwrappedLineNode &Node = *I;
6058
Current->Next = I->Tok;
6159
I->Tok->Previous = Current;

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3034,24 +3034,15 @@ LLVM_ATTRIBUTE_UNUSED static void printDebugInfo(const UnwrappedLine &Line,
30343034
llvm::dbgs() << Prefix << "Line(" << Line.Level
30353035
<< ", FSC=" << Line.FirstStartColumn << ")"
30363036
<< (Line.InPPDirective ? " MACRO" : "") << ": ";
3037-
for (std::list<UnwrappedLineNode>::const_iterator I = Line.Tokens.begin(),
3038-
E = Line.Tokens.end();
3039-
I != E; ++I) {
3040-
llvm::dbgs() << I->Tok->Tok.getName() << "["
3041-
<< "T=" << (unsigned)I->Tok->getType()
3042-
<< ", OC=" << I->Tok->OriginalColumn << "] ";
3043-
}
3044-
for (std::list<UnwrappedLineNode>::const_iterator I = Line.Tokens.begin(),
3045-
E = Line.Tokens.end();
3046-
I != E; ++I) {
3047-
const UnwrappedLineNode &Node = *I;
3048-
for (SmallVectorImpl<UnwrappedLine>::const_iterator
3049-
I = Node.Children.begin(),
3050-
E = Node.Children.end();
3051-
I != E; ++I) {
3052-
printDebugInfo(*I, "\nChild: ");
3053-
}
3037+
for (const auto &Node : Line.Tokens) {
3038+
llvm::dbgs() << Node.Tok->Tok.getName() << "["
3039+
<< "T=" << static_cast<unsigned>(Node.Tok->getType())
3040+
<< ", OC=" << Node.Tok->OriginalColumn << "] ";
30543041
}
3042+
for (const auto &Node : Line.Tokens)
3043+
for (const auto &ChildNode : Node.Children)
3044+
printDebugInfo(ChildNode, "\nChild: ");
3045+
30553046
llvm::dbgs() << "\n";
30563047
}
30573048

clang/lib/Format/UnwrappedLineParser.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include "clang/Basic/IdentifierTable.h"
2020
#include "clang/Format/Format.h"
2121
#include "llvm/Support/Regex.h"
22-
#include <list>
2322
#include <stack>
23+
#include <vector>
2424

2525
namespace clang {
2626
namespace format {
@@ -36,9 +36,8 @@ struct UnwrappedLineNode;
3636
struct UnwrappedLine {
3737
UnwrappedLine();
3838

39-
// FIXME: Don't use std::list here.
4039
/// The \c Tokens comprising this \c UnwrappedLine.
41-
std::list<UnwrappedLineNode> Tokens;
40+
std::vector<UnwrappedLineNode> Tokens;
4241

4342
/// The indent level of the \c UnwrappedLine.
4443
unsigned Level;

0 commit comments

Comments
 (0)