summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/CommentLexer.cpp
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2013-03-04 23:06:15 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2013-03-04 23:06:15 +0000
commitbcf7f4d3bbd920d29a8e1ebca998ea9e21fe716d (patch)
tree1d2975f918c89343f48b071ac16b85cb930a08cf /clang/lib/AST/CommentLexer.cpp
parent208b5beb60862ab7fd3dde5de77950ceb29290c4 (diff)
downloadbcm5719-llvm-bcf7f4d3bbd920d29a8e1ebca998ea9e21fe716d.tar.gz
bcm5719-llvm-bcf7f4d3bbd920d29a8e1ebca998ea9e21fe716d.zip
Comment parsing: refactor handling of command markers in AST
* Use the term 'command marker', because the semantics of 'backslash' and 'at' commands are the same. (Talking about 'at commands' makes them look like a special entity.) * Sink the flag down into bitfields, reducing the size of AST nodes. * Change the flag into an enum for clarity. Boolean function parameters are not very clear. * Add unittests for new tok::at_command tokens. llvm-svn: 176461
Diffstat (limited to 'clang/lib/AST/CommentLexer.cpp')
-rw-r--r--clang/lib/AST/CommentLexer.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/AST/CommentLexer.cpp b/clang/lib/AST/CommentLexer.cpp
index 20180994177..1194520bf36 100644
--- a/clang/lib/AST/CommentLexer.cpp
+++ b/clang/lib/AST/CommentLexer.cpp
@@ -298,7 +298,11 @@ void Lexer::lexCommentText(Token &T) {
switch(*TokenPtr) {
case '\\':
case '@': {
- bool AtCommand = (*TokenPtr == '@');
+ // Commands that start with a backslash and commands that start with
+ // 'at' have equivalent semantics. But we keep information about the
+ // exact syntax in AST for comments.
+ tok::TokenKind CommandKind =
+ (*TokenPtr == '@') ? tok::at_command : tok::backslash_command;
TokenPtr++;
if (TokenPtr == CommentEnd) {
formTextToken(T, TokenPtr);
@@ -359,9 +363,7 @@ void Lexer::lexCommentText(Token &T) {
setupAndLexVerbatimLine(T, TokenPtr, Info);
return;
}
- formTokenWithChars(T, TokenPtr,
- (AtCommand ? tok::at_command
- : tok::backslash_command));
+ formTokenWithChars(T, TokenPtr, CommandKind);
T.setCommandID(Info->getID());
return;
}
OpenPOWER on IntegriCloud