summaryrefslogtreecommitdiffstats
path: root/clang/tools/clang-format/ClangFormat.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-09-09 14:37:39 +0000
committerDaniel Jasper <djasper@google.com>2014-09-09 14:37:39 +0000
commit23376259c087f8629345230087ac9ed6df6d6134 (patch)
treea4850374f4835915588fcd3d38bfcbca486d50fb /clang/tools/clang-format/ClangFormat.cpp
parent7fc29546f93e1c4ca579be76c69245e7521cce4b (diff)
downloadbcm5719-llvm-23376259c087f8629345230087ac9ed6df6d6134.tar.gz
bcm5719-llvm-23376259c087f8629345230087ac9ed6df6d6134.zip
clang-format: [JS] Support regex literals with trailing escaped slash.
Before: var regex = / a\//; int i; After: var regex = /a\//; int i; This required pushing the Lexer into its wrapper class and generating a new one in this specific case. Otherwise, the sequence get lexed as a //-comment. This is hacky, but I don't know a better way (short of supporting regex literals in the Lexer). Pushing the Lexer down seems to make all the call sites simpler. llvm-svn: 217444
Diffstat (limited to 'clang/tools/clang-format/ClangFormat.cpp')
-rw-r--r--clang/tools/clang-format/ClangFormat.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp
index 7dda9c6e138..614d9cd4bdd 100644
--- a/clang/tools/clang-format/ClangFormat.cpp
+++ b/clang/tools/clang-format/ClangFormat.cpp
@@ -19,7 +19,6 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/Version.h"
#include "clang/Format/Format.h"
-#include "clang/Lex/Lexer.h"
#include "clang/Rewrite/Core/Rewriter.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/Debug.h"
@@ -225,9 +224,7 @@ static bool format(StringRef FileName) {
FormatStyle FormatStyle = getStyle(
Style, (FileName == "-") ? AssumeFilename : FileName, FallbackStyle);
- Lexer Lex(ID, Sources.getBuffer(ID), Sources,
- getFormattingLangOpts(FormatStyle));
- tooling::Replacements Replaces = reformat(FormatStyle, Lex, Sources, Ranges);
+ tooling::Replacements Replaces = reformat(FormatStyle, Sources, ID, Ranges);
if (OutputXML) {
llvm::outs()
<< "<?xml version='1.0'?>\n<replacements xml:space='preserve'>\n";
OpenPOWER on IntegriCloud