[cfe-commits] r160675 - in /cfe/trunk: include/clang/AST/CommentParser.h lib/AST/CommentParser.cpp unittests/AST/CommentParser.cpp
Dmitri Gribenko
gribozavr at gmail.com
Tue Jul 24 09:10:48 PDT 2012
Author: gribozavr
Date: Tue Jul 24 11:10:47 2012
New Revision: 160675
URL: http://llvm.org/viewvc/llvm-project?rev=160675&view=rev
Log:
Comment parsing: retokenized text tokens are now pushed back in correct (not
reverse) order
Modified:
cfe/trunk/include/clang/AST/CommentParser.h
cfe/trunk/lib/AST/CommentParser.cpp
cfe/trunk/unittests/AST/CommentParser.cpp
Modified: cfe/trunk/include/clang/AST/CommentParser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentParser.h?rev=160675&r1=160674&r2=160675&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/CommentParser.h (original)
+++ cfe/trunk/include/clang/AST/CommentParser.h Tue Jul 24 11:10:47 2012
@@ -83,7 +83,7 @@
MoreLATokens.push_back(Tok);
for (const Token *I = &Toks.back(),
- *B = &Toks.front() + 1;
+ *B = &Toks.front();
I != B; --I) {
MoreLATokens.push_back(*I);
}
Modified: cfe/trunk/lib/AST/CommentParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentParser.cpp?rev=160675&r1=160674&r2=160675&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentParser.cpp (original)
+++ cfe/trunk/lib/AST/CommentParser.cpp Tue Jul 24 11:10:47 2012
@@ -105,9 +105,12 @@
BC = parseBlockCommandArgs(BC, Retokenizer, NumArgs);
// Put back tokens we didn't use.
+ SmallVector<Token, 16> TextToks;
Token Text;
- while (Retokenizer.lexText(Text))
- putBack(Text);
+ while (Retokenizer.lexText(Text)) {
+ TextToks.push_back(Text);
+ }
+ putBack(TextToks);
}
BlockContentComment *Block = parseParagraphOrBlockCommand();
Modified: cfe/trunk/unittests/AST/CommentParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/CommentParser.cpp?rev=160675&r1=160674&r2=160675&view=diff
==============================================================================
--- cfe/trunk/unittests/AST/CommentParser.cpp (original)
+++ cfe/trunk/unittests/AST/CommentParser.cpp Tue Jul 24 11:10:47 2012
@@ -755,6 +755,31 @@
}
}
+TEST_F(CommentParserTest, ParamCommand5) {
+ const char *Source =
+ "// \\param aaa \\% Bbb \\$ ccc\n";
+
+ FullComment *FC = parseString(Source);
+ ASSERT_TRUE(HasChildCount(FC, 2));
+
+ ASSERT_TRUE(HasParagraphCommentAt(FC, 0, " "));
+ {
+ ParamCommandComment *PCC;
+ ParagraphComment *PC;
+ ASSERT_TRUE(HasParamCommandAt(FC, 1, PCC, "param",
+ ParamCommandComment::In,
+ /* IsDirectionExplicit = */ false,
+ "aaa", PC));
+ ASSERT_TRUE(HasChildCount(PCC, 1));
+
+ ASSERT_TRUE(HasChildCount(PC, 5));
+ ASSERT_TRUE(HasTextAt(PC, 0, " "));
+ ASSERT_TRUE(HasTextAt(PC, 1, "%"));
+ ASSERT_TRUE(HasTextAt(PC, 2, " Bbb "));
+ ASSERT_TRUE(HasTextAt(PC, 3, "$"));
+ ASSERT_TRUE(HasTextAt(PC, 4, " ccc"));
+ }
+}
TEST_F(CommentParserTest, InlineCommand1) {
const char *Source = "// \\c";
More information about the cfe-commits
mailing list