[cfe-commits] r69483 - in /cfe/trunk: include/clang/Lex/Lexer.h lib/Lex/Lexer.cpp
Chris Lattner
sabre at nondot.org
Sat Apr 18 15:27:03 PDT 2009
Author: lattner
Date: Sat Apr 18 17:27:02 2009
New Revision: 69483
URL: http://llvm.org/viewvc/llvm-project?rev=69483&view=rev
Log:
add a new Lexer::SkipEscapedNewLines method.
Modified:
cfe/trunk/include/clang/Lex/Lexer.h
cfe/trunk/lib/Lex/Lexer.cpp
Modified: cfe/trunk/include/clang/Lex/Lexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Lexer.h?rev=69483&r1=69482&r2=69483&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Lexer.h (original)
+++ cfe/trunk/include/clang/Lex/Lexer.h Sat Apr 18 17:27:02 2009
@@ -342,6 +342,10 @@
/// to this function.
static unsigned getEscapedNewLineSize(const char *P);
+ /// 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.
+ static const char *SkipEscapedNewLines(const char *P);
private:
/// getCharAndSizeSlowNoWarn - Same as getCharAndSizeSlow, but never emits a
Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=69483&r1=69482&r2=69483&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Sat Apr 18 17:27:02 2009
@@ -422,6 +422,29 @@
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:
More information about the cfe-commits
mailing list