From 52d0fd8961ef4d03e042ac9eb1b30610518e3016 Mon Sep 17 00:00:00 2001 From: Manuel Klimek Date: Sat, 5 Jan 2013 22:56:06 +0000 Subject: Fixes parsing of hash tokens in the middle of a line. To parse # correctly, we need to know whether it is the first token in a line - we can deduct this either from the whitespace or seeing that the token is the first in the file - we already calculate this information. This patch moves the identification of the first token into the getNextToken method and stores it inside the FormatToken, so the UnwrappedLineParser can stay independent of the SourceManager. llvm-svn: 171640 --- clang/lib/Format/UnwrappedLineParser.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'clang/lib/Format/UnwrappedLineParser.cpp') diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 2f3a6034bcf..72b47503ee8 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -470,7 +470,9 @@ void UnwrappedLineParser::nextToken() { void UnwrappedLineParser::readToken() { FormatTok = Tokens->getNextToken(); - while (!Line.InPPDirective && FormatTok.Tok.is(tok::hash)) { + while (!Line.InPPDirective && FormatTok.Tok.is(tok::hash) && + ((FormatTok.NewlinesBefore > 0 && FormatTok.HasUnescapedNewline) || + FormatTok.IsFirst)) { // FIXME: This is incorrect - the correct way is to create a // data structure that will construct the parts around the preprocessor // directive as a structured \c UnwrappedLine. -- cgit v1.2.3