diff options
| author | Daniel Jasper <djasper@google.com> | 2014-01-31 12:49:42 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-01-31 12:49:42 +0000 |
| commit | 86fee2fa3da2718967b7af8ecf4be3de02f22cc8 (patch) | |
| tree | e4eca69bf8f473f6e3fb944d4624443ff00dc27a /clang/lib | |
| parent | e2dbedda76a77c4a8aef0c93884e9a01b0ec7d53 (diff) | |
| download | bcm5719-llvm-86fee2fa3da2718967b7af8ecf4be3de02f22cc8.tar.gz bcm5719-llvm-86fee2fa3da2718967b7af8ecf4be3de02f22cc8.zip | |
clang-format: (JavaScript) Don't crash on empty string literals.
Before, this would lead to a crash:
f('', true);
llvm-svn: 200540
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Format/Format.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 1eca6cf79cf..eb74fc8f1d7 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1358,10 +1358,14 @@ private: Tok.Tok.getLength()); // For formatting, treat unterminated string literals like normal string // literals. - if (Tok.is(tok::unknown) && !Tok.TokenText.empty() && - Tok.TokenText[0] == '"') { - Tok.Tok.setKind(tok::string_literal); - Tok.IsUnterminatedLiteral = true; + if (Tok.is(tok::unknown)) { + if (!Tok.TokenText.empty() && Tok.TokenText[0] == '"') { + Tok.Tok.setKind(tok::string_literal); + Tok.IsUnterminatedLiteral = true; + } else if (Style.Language == FormatStyle::LK_JavaScript && + Tok.TokenText == "''") { + Tok.Tok.setKind(tok::char_constant); + } } } }; |

