[cfe-commits] r163646 - in /cfe/trunk: include/clang/AST/CommentLexer.h include/clang/AST/CommentSema.h lib/AST/CommentCommandTraits.cpp lib/AST/CommentParser.cpp lib/AST/CommentSema.cpp test/Sema/warn-documentation.cpp
Dmitri Gribenko
gribozavr at gmail.com
Tue Sep 11 12:22:03 PDT 2012
Author: gribozavr
Date: Tue Sep 11 14:22:03 2012
New Revision: 163646
URL: http://llvm.org/viewvc/llvm-project?rev=163646&view=rev
Log:
Comment parsing: handle non-builtin commands correctly. After semantic
analysis registers a command, it becomes a "known" command for the lexer, since
it has an ID. Having this freedom of choice to register a command is a good
thing since BriefParser does not need this.
But the parser should still invoke the correct semantic analysis method
(actOnUnknownCommand) in this case.
Modified:
cfe/trunk/include/clang/AST/CommentLexer.h
cfe/trunk/include/clang/AST/CommentSema.h
cfe/trunk/lib/AST/CommentCommandTraits.cpp
cfe/trunk/lib/AST/CommentParser.cpp
cfe/trunk/lib/AST/CommentSema.cpp
cfe/trunk/test/Sema/warn-documentation.cpp
Modified: cfe/trunk/include/clang/AST/CommentLexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentLexer.h?rev=163646&r1=163645&r2=163646&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/CommentLexer.h (original)
+++ cfe/trunk/include/clang/AST/CommentLexer.h Tue Sep 11 14:22:03 2012
@@ -34,8 +34,8 @@
eof,
newline,
text,
- unknown_command,
- command,
+ unknown_command, // Command that does not have an ID.
+ command, // Command with an ID.
verbatim_block_begin,
verbatim_block_line,
verbatim_block_end,
Modified: cfe/trunk/include/clang/AST/CommentSema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentSema.h?rev=163646&r1=163645&r2=163646&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/CommentSema.h (original)
+++ cfe/trunk/include/clang/AST/CommentSema.h Tue Sep 11 14:22:03 2012
@@ -139,7 +139,11 @@
InlineContentComment *actOnUnknownCommand(SourceLocation LocBegin,
SourceLocation LocEnd,
- StringRef Name);
+ StringRef CommandName);
+
+ InlineContentComment *actOnUnknownCommand(SourceLocation LocBegin,
+ SourceLocation LocEnd,
+ unsigned CommandID);
TextComment *actOnText(SourceLocation LocBegin,
SourceLocation LocEnd,
Modified: cfe/trunk/lib/AST/CommentCommandTraits.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentCommandTraits.cpp?rev=163646&r1=163645&r2=163646&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentCommandTraits.cpp (original)
+++ cfe/trunk/lib/AST/CommentCommandTraits.cpp Tue Sep 11 14:22:03 2012
@@ -40,6 +40,7 @@
CommandInfo *Info = new (Allocator) CommandInfo();
Info->Name = Name;
Info->ID = NextID++;
+ Info->IsUnknownCommand = true;
RegisteredCommands.push_back(Info);
Modified: cfe/trunk/lib/AST/CommentParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentParser.cpp?rev=163646&r1=163645&r2=163646&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentParser.cpp (original)
+++ cfe/trunk/lib/AST/CommentParser.cpp Tue Sep 11 14:22:03 2012
@@ -554,6 +554,13 @@
return parseBlockCommand();
break; // Block command ahead, finish this parapgaph.
}
+ if (Info->IsUnknownCommand) {
+ Content.push_back(S.actOnUnknownCommand(Tok.getLocation(),
+ Tok.getEndLocation(),
+ Info->getID()));
+ consumeToken();
+ continue;
+ }
assert(Info->IsInlineCommand);
Content.push_back(parseInlineCommand());
continue;
Modified: cfe/trunk/lib/AST/CommentSema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=163646&r1=163645&r2=163646&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentSema.cpp (original)
+++ cfe/trunk/lib/AST/CommentSema.cpp Tue Sep 11 14:22:03 2012
@@ -272,9 +272,15 @@
InlineContentComment *Sema::actOnUnknownCommand(SourceLocation LocBegin,
SourceLocation LocEnd,
- StringRef Name) {
+ StringRef CommandName) {
+ unsigned CommandID = Traits.registerUnknownCommand(CommandName)->getID();
+ return actOnUnknownCommand(LocBegin, LocEnd, CommandID);
+}
+
+InlineContentComment *Sema::actOnUnknownCommand(SourceLocation LocBegin,
+ SourceLocation LocEnd,
+ unsigned CommandID) {
ArrayRef<InlineCommandComment::Argument> Args;
- unsigned CommandID = Traits.registerUnknownCommand(Name)->getID();
return new (Allocator) InlineCommandComment(
LocBegin, LocEnd, CommandID,
InlineCommandComment::RenderNormal,
Modified: cfe/trunk/test/Sema/warn-documentation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.cpp?rev=163646&r1=163645&r2=163646&view=diff
==============================================================================
--- cfe/trunk/test/Sema/warn-documentation.cpp (original)
+++ cfe/trunk/test/Sema/warn-documentation.cpp Tue Sep 11 14:22:03 2012
@@ -761,3 +761,8 @@
*/
typedef const struct test_nocrash7 * test_nocrash8;
+// We used to crash on this.
+
+/// aaa \unknown aaa \unknown aaa
+int test_nocrash9;
+
More information about the cfe-commits
mailing list