summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/FormatTokenLexer.cpp
diff options
context:
space:
mode:
authorPaul Hoad <mydeveloperday@gmail.com>2019-09-18 18:57:09 +0000
committerPaul Hoad <mydeveloperday@gmail.com>2019-09-18 18:57:09 +0000
commit79983be5a027c0ff8a7ef7a8f67481ce61efc523 (patch)
tree3e5eeaedc9cdc0363ed935223dcf74da669aedad /clang/lib/Format/FormatTokenLexer.cpp
parentba4cad9039660d322937f7f44bcb30b4849c3d58 (diff)
downloadbcm5719-llvm-79983be5a027c0ff8a7ef7a8f67481ce61efc523.tar.gz
bcm5719-llvm-79983be5a027c0ff8a7ef7a8f67481ce61efc523.zip
[clang-format][PR41964] Fix crash with SIGFPE when TabWidth is set to 0 and line starts with tab
Summary: clang-format 8.0 crashes with SIGFPE (floating point exception) when formatting following file: app.cpp: void a() { //line starts with '\t' } $ clang-format -style='{TabWidth: 0}' app.cpp Reviewers: owenpan, klimek, russellmcc, timwoj Reviewed By: klimek Subscribers: cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D67670 llvm-svn: 372246
Diffstat (limited to 'clang/lib/Format/FormatTokenLexer.cpp')
-rw-r--r--clang/lib/Format/FormatTokenLexer.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Format/FormatTokenLexer.cpp b/clang/lib/Format/FormatTokenLexer.cpp
index 009b8849753..e59a059fd6b 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -657,7 +657,8 @@ FormatToken *FormatTokenLexer::getNextToken() {
++Column;
break;
case '\t':
- Column += Style.TabWidth - Column % Style.TabWidth;
+ Column +=
+ Style.TabWidth - (Style.TabWidth ? Column % Style.TabWidth : 0);
break;
case '\\':
if (i + 1 == e || (Text[i + 1] != '\r' && Text[i + 1] != '\n'))
OpenPOWER on IntegriCloud