summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2013-10-10 13:36:20 +0000
committerAlexander Kornienko <alexfh@google.com>2013-10-10 13:36:20 +0000
commit60d1b046dd3f24bacd6f4dc2acd1c033d668de86 (patch)
tree49e6e6e5b9548e24d13911117b0d1276b42023ec /clang/lib/Format
parent20a6a436ae4742a44747ef534be32f97ebf5ff50 (diff)
downloadbcm5719-llvm-60d1b046dd3f24bacd6f4dc2acd1c033d668de86.tar.gz
bcm5719-llvm-60d1b046dd3f24bacd6f4dc2acd1c033d668de86.zip
Correctly detect colon in bit fields. Fixes PR17333.
Summary: Colon was incorrectly detected as a start of inheritance list. Fixed. Reviewers: djasper Reviewed By: djasper CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D1884 llvm-svn: 192349
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/FormatToken.h1
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp9
2 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index c02ac6357a9..2541c782aca 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -26,6 +26,7 @@ namespace format {
enum TokenType {
TT_BinaryOperator,
+ TT_BitFieldColon,
TT_BlockComment,
TT_CastRParen,
TT_ConditionalExpr,
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 823235e602c..87549895b1c 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -328,13 +328,15 @@ private:
Tok->Previous->Type = TT_ObjCSelectorName;
if (Tok->Previous->ColumnWidth >
Contexts.back().LongestObjCSelectorName) {
- Contexts.back().LongestObjCSelectorName =
- Tok->Previous->ColumnWidth;
+ Contexts.back().LongestObjCSelectorName = Tok->Previous->ColumnWidth;
}
if (Contexts.back().FirstObjCSelectorName == NULL)
Contexts.back().FirstObjCSelectorName = Tok->Previous;
} else if (Contexts.back().ColonIsForRangeExpr) {
Tok->Type = TT_RangeBasedForLoopColon;
+ } else if (CurrentToken != NULL &&
+ CurrentToken->is(tok::numeric_constant)) {
+ Tok->Type = TT_BitFieldColon;
} else if (Contexts.size() == 1 && Line.First->isNot(tok::kw_enum)) {
Tok->Type = TT_InheritanceColon;
} else if (Contexts.back().ContextKind == tok::l_paren) {
@@ -1370,8 +1372,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
!Style.ConstructorInitializerAllOnOneLineOrOnePerLine) {
return true;
} else if (Right.Previous->BlockKind == BK_Block &&
- Right.Previous->isNot(tok::r_brace) &&
- Right.isNot(tok::r_brace)) {
+ Right.Previous->isNot(tok::r_brace) && Right.isNot(tok::r_brace)) {
return true;
} else if (Right.is(tok::l_brace) && (Right.BlockKind == BK_Block)) {
return Style.BreakBeforeBraces == FormatStyle::BS_Allman;
OpenPOWER on IntegriCloud