summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-18 22:27:02 +0000
committerChris Lattner <sabre@nondot.org>2009-04-18 22:27:02 +0000
commit38b2cde4c4c877664ef25dd513d033b4dd5866c3 (patch)
treeaf6847a1ea9f4373fa6fcfbce26c71ac00ef0c46 /clang/lib/Lex
parentfbce7aa1f46a7df304070acd7860344d26315cd4 (diff)
downloadbcm5719-llvm-38b2cde4c4c877664ef25dd513d033b4dd5866c3.tar.gz
bcm5719-llvm-38b2cde4c4c877664ef25dd513d033b4dd5866c3.zip
add a new Lexer::SkipEscapedNewLines method.
llvm-svn: 69483
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r--clang/lib/Lex/Lexer.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index b9aa0178c64..4d6450b9149 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -422,6 +422,29 @@ unsigned Lexer::getEscapedNewLineSize(const char *Ptr) {
return 0;
}
+/// SkipEscapedNewLines - If P points to an escaped newline (or a series of
+/// them), skip over them and return the first non-escaped-newline found,
+/// otherwise return P.
+const char *Lexer::SkipEscapedNewLines(const char *P) {
+ while (1) {
+ const char *AfterEscape;
+ if (*P == '\\') {
+ AfterEscape = P+1;
+ } else if (*P == '?') {
+ // If not a trigraph for escape, bail out.
+ if (P[1] != '?' || P[2] != '/')
+ return P;
+ AfterEscape = P+3;
+ } else {
+ return P;
+ }
+
+ unsigned NewLineSize = Lexer::getEscapedNewLineSize(AfterEscape);
+ if (NewLineSize == 0) return P;
+ P = AfterEscape+NewLineSize;
+ }
+}
+
/// getCharAndSizeSlow - Peek a single 'character' from the specified buffer,
/// get its size, and return it. This is tricky in several cases:
OpenPOWER on IntegriCloud