зеркало из https://github.com/microsoft/clang-1.git
Fixes a compile warning and crash in the tests.
The necessity of this fix points to a problem with the design of the addToken during the optimiation phase, which we need to address in a much more principled way. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169151 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
91ecfa6af5
Коммит
0be4b36830
|
@ -167,13 +167,14 @@ private:
|
|||
State.Column = State.Column - Previous.Tok.getLength();
|
||||
else if (Previous.Tok.is(tok::equal) && ParenLevel != 0)
|
||||
State.Column = State.Indent[ParenLevel] + 4;
|
||||
else
|
||||
else if (ParenLevel < State.Indent.size())
|
||||
State.Column = State.Indent[ParenLevel];
|
||||
if (!DryRun)
|
||||
replaceWhitespace(Current, 1, State.Column);
|
||||
|
||||
State.Column += Current.Tok.getLength();
|
||||
State.LastSpace[ParenLevel] = State.Indent[ParenLevel];
|
||||
if (ParenLevel < State.LastSpace.size())
|
||||
State.LastSpace[ParenLevel] = State.Indent[ParenLevel];
|
||||
if (Current.Tok.is(tok::colon) &&
|
||||
Annotations[Index].Type != TokenAnnotation::TT_ConditionalExpr) {
|
||||
State.Indent[ParenLevel] += 2;
|
||||
|
@ -189,20 +190,23 @@ private:
|
|||
if (Previous.Tok.is(tok::l_paren))
|
||||
State.Indent[ParenLevel] = State.Column;
|
||||
if (Previous.Tok.is(tok::less) &&
|
||||
Annotations[Index - 1].Type == TokenAnnotation::TT_TemplateOpener)
|
||||
Annotations[Index - 1].Type == TokenAnnotation::TT_TemplateOpener &&
|
||||
ParenLevel < State.Indent.size())
|
||||
State.Indent[ParenLevel] = State.Column;
|
||||
if (Current.Tok.is(tok::colon)) {
|
||||
State.Indent[ParenLevel] = State.Column + 3;
|
||||
State.InCtorInitializer = true;
|
||||
}
|
||||
// Top-level spaces are exempt as that mostly leads to better results.
|
||||
if (Spaces > 0 && ParenLevel != 0)
|
||||
if (Spaces > 0 && ParenLevel != 0 &&
|
||||
ParenLevel < State.LastSpace.size())
|
||||
State.LastSpace[ParenLevel] = State.Column + Spaces;
|
||||
State.Column += Current.Tok.getLength() + Spaces;
|
||||
}
|
||||
|
||||
if (Current.Tok.is(tok::r_paren) || Current.Tok.is(tok::r_square) ||
|
||||
Annotations[Index].Type == TokenAnnotation::TT_TemplateOpener) {
|
||||
if (!DryRun &&
|
||||
(Current.Tok.is(tok::r_paren) || Current.Tok.is(tok::r_square) ||
|
||||
Annotations[Index].Type == TokenAnnotation::TT_TemplateOpener)) {
|
||||
State.Indent.pop_back();
|
||||
State.LastSpace.pop_back();
|
||||
}
|
||||
|
@ -341,11 +345,9 @@ public:
|
|||
/// into template parameter lists.
|
||||
class AnnotatingParser {
|
||||
public:
|
||||
AnnotatingParser(const SourceManager &SourceMgr,
|
||||
const SmallVector<FormatToken, 16> &Tokens,
|
||||
AnnotatingParser(const SmallVector<FormatToken, 16> &Tokens,
|
||||
std::vector<TokenAnnotation> &Annotations)
|
||||
: SourceMgr(SourceMgr),
|
||||
Tokens(Tokens),
|
||||
: Tokens(Tokens),
|
||||
Annotations(Annotations),
|
||||
Index(0) {
|
||||
}
|
||||
|
@ -457,7 +459,6 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
const SourceManager &SourceMgr;
|
||||
const SmallVector<FormatToken, 16> &Tokens;
|
||||
std::vector<TokenAnnotation> &Annotations;
|
||||
unsigned Index;
|
||||
|
@ -469,7 +470,7 @@ public:
|
|||
Annotations.push_back(TokenAnnotation());
|
||||
}
|
||||
|
||||
AnnotatingParser Parser(SourceMgr, Line.Tokens, Annotations);
|
||||
AnnotatingParser Parser(Line.Tokens, Annotations);
|
||||
Parser.parseLine();
|
||||
|
||||
determineTokenTypes();
|
||||
|
|
Загрузка…
Ссылка в новой задаче