aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/CommentDumper.cpp10
-rw-r--r--lib/AST/CommentLexer.cpp34
-rw-r--r--lib/AST/CommentParser.cpp100
-rw-r--r--lib/AST/CommentSema.cpp74
4 files changed, 108 insertions, 110 deletions
diff --git a/lib/AST/CommentDumper.cpp b/lib/AST/CommentDumper.cpp
index 267657b76b..7ff61e0a27 100644
--- a/lib/AST/CommentDumper.cpp
+++ b/lib/AST/CommentDumper.cpp
@@ -43,8 +43,8 @@ public:
// Inline content.
void visitTextComment(const TextComment *C);
void visitInlineCommandComment(const InlineCommandComment *C);
- void visitHTMLOpenTagComment(const HTMLOpenTagComment *C);
- void visitHTMLCloseTagComment(const HTMLCloseTagComment *C);
+ void visitHTMLStartTagComment(const HTMLStartTagComment *C);
+ void visitHTMLEndTagComment(const HTMLEndTagComment *C);
// Block content.
void visitParagraphComment(const ParagraphComment *C);
@@ -110,14 +110,14 @@ void CommentDumper::visitInlineCommandComment(const InlineCommandComment *C) {
OS << " Arg[" << i << "]=\"" << C->getArgText(i) << "\"";
}
-void CommentDumper::visitHTMLOpenTagComment(const HTMLOpenTagComment *C) {
+void CommentDumper::visitHTMLStartTagComment(const HTMLStartTagComment *C) {
dumpComment(C);
OS << " Name=\"" << C->getTagName() << "\"";
if (C->getAttrCount() != 0) {
OS << " Attrs: ";
for (unsigned i = 0, e = C->getAttrCount(); i != e; ++i) {
- const HTMLOpenTagComment::Attribute &Attr = C->getAttr(i);
+ const HTMLStartTagComment::Attribute &Attr = C->getAttr(i);
OS << " \"" << Attr.Name << "=\"" << Attr.Value << "\"";
}
}
@@ -125,7 +125,7 @@ void CommentDumper::visitHTMLOpenTagComment(const HTMLOpenTagComment *C) {
OS << " SelfClosing";
}
-void CommentDumper::visitHTMLCloseTagComment(const HTMLCloseTagComment *C) {
+void CommentDumper::visitHTMLEndTagComment(const HTMLEndTagComment *C) {
dumpComment(C);
OS << " Name=\"" << C->getTagName() << "\"";
diff --git a/lib/AST/CommentLexer.cpp b/lib/AST/CommentLexer.cpp
index 1f4955d1cf..5b411ca9cc 100644
--- a/lib/AST/CommentLexer.cpp
+++ b/lib/AST/CommentLexer.cpp
@@ -273,11 +273,11 @@ void Lexer::lexCommentText(Token &T) {
case LS_VerbatimLineText:
lexVerbatimLineText(T);
return;
- case LS_HTMLOpenTag:
- lexHTMLOpenTag(T);
+ case LS_HTMLStartTag:
+ lexHTMLStartTag(T);
return;
- case LS_HTMLCloseTag:
- lexHTMLCloseTag(T);
+ case LS_HTMLEndTag:
+ lexHTMLEndTag(T);
return;
}
@@ -363,9 +363,9 @@ void Lexer::lexCommentText(Token &T) {
}
const char C = *TokenPtr;
if (isHTMLIdentifierStartingCharacter(C))
- setupAndLexHTMLOpenTag(T);
+ setupAndLexHTMLStartTag(T);
else if (C == '/')
- setupAndLexHTMLCloseTag(T);
+ setupAndLexHTMLEndTag(T);
else {
StringRef Text(BufferPtr, TokenPtr - BufferPtr);
formTokenWithChars(T, TokenPtr, tok::text);
@@ -496,25 +496,25 @@ void Lexer::lexVerbatimLineText(Token &T) {
State = LS_Normal;
}
-void Lexer::setupAndLexHTMLOpenTag(Token &T) {
+void Lexer::setupAndLexHTMLStartTag(Token &T) {
assert(BufferPtr[0] == '<' &&
isHTMLIdentifierStartingCharacter(BufferPtr[1]));
const char *TagNameEnd = skipHTMLIdentifier(BufferPtr + 2, CommentEnd);
StringRef Name(BufferPtr + 1, TagNameEnd - (BufferPtr + 1));
- formTokenWithChars(T, TagNameEnd, tok::html_tag_open);
- T.setHTMLTagOpenName(Name);
+ formTokenWithChars(T, TagNameEnd, tok::html_start_tag);
+ T.setHTMLTagStartName(Name);
BufferPtr = skipWhitespace(BufferPtr, CommentEnd);
const char C = *BufferPtr;
if (BufferPtr != CommentEnd &&
(C == '>' || C == '/' || isHTMLIdentifierStartingCharacter(C)))
- State = LS_HTMLOpenTag;
+ State = LS_HTMLStartTag;
}
-void Lexer::lexHTMLOpenTag(Token &T) {
- assert(State == LS_HTMLOpenTag);
+void Lexer::lexHTMLStartTag(Token &T) {
+ assert(State == LS_HTMLStartTag);
const char *TokenPtr = BufferPtr;
char C = *TokenPtr;
@@ -577,7 +577,7 @@ void Lexer::lexHTMLOpenTag(Token &T) {
}
}
-void Lexer::setupAndLexHTMLCloseTag(Token &T) {
+void Lexer::setupAndLexHTMLEndTag(Token &T) {
assert(BufferPtr[0] == '<' && BufferPtr[1] == '/');
const char *TagNameBegin = skipWhitespace(BufferPtr + 2, CommentEnd);
@@ -585,14 +585,14 @@ void Lexer::setupAndLexHTMLCloseTag(Token &T) {
const char *End = skipWhitespace(TagNameEnd, CommentEnd);
- formTokenWithChars(T, End, tok::html_tag_close);
- T.setHTMLTagCloseName(StringRef(TagNameBegin, TagNameEnd - TagNameBegin));
+ formTokenWithChars(T, End, tok::html_end_tag);
+ T.setHTMLTagEndName(StringRef(TagNameBegin, TagNameEnd - TagNameBegin));
if (BufferPtr != CommentEnd && *BufferPtr == '>')
- State = LS_HTMLCloseTag;
+ State = LS_HTMLEndTag;
}
-void Lexer::lexHTMLCloseTag(Token &T) {
+void Lexer::lexHTMLEndTag(Token &T) {
assert(BufferPtr != CommentEnd && *BufferPtr == '>');
formTokenWithChars(T, BufferPtr + 1, tok::html_greater);
diff --git a/lib/AST/CommentParser.cpp b/lib/AST/CommentParser.cpp
index eabe61c979..ddcfef023f 100644
--- a/lib/AST/CommentParser.cpp
+++ b/lib/AST/CommentParser.cpp
@@ -155,38 +155,38 @@ InlineCommandComment *Parser::parseInlineCommand() {
return IC;
}
-HTMLOpenTagComment *Parser::parseHTMLOpenTag() {
- assert(Tok.is(tok::html_tag_open));
- HTMLOpenTagComment *HOT =
- S.actOnHTMLOpenTagStart(Tok.getLocation(),
- Tok.getHTMLTagOpenName());
+HTMLStartTagComment *Parser::parseHTMLStartTag() {
+ assert(Tok.is(tok::html_start_tag));
+ HTMLStartTagComment *HST =
+ S.actOnHTMLStartTagStart(Tok.getLocation(),
+ Tok.getHTMLTagStartName());
consumeToken();
- SmallVector<HTMLOpenTagComment::Attribute, 2> Attrs;
+ SmallVector<HTMLStartTagComment::Attribute, 2> Attrs;
while (true) {
switch (Tok.getKind()) {
case tok::html_ident: {
Token Ident = Tok;
consumeToken();
if (Tok.isNot(tok::html_equals)) {
- Attrs.push_back(HTMLOpenTagComment::Attribute(Ident.getLocation(),
- Ident.getHTMLIdent()));
+ Attrs.push_back(HTMLStartTagComment::Attribute(Ident.getLocation(),
+ Ident.getHTMLIdent()));
continue;
}
Token Equals = Tok;
consumeToken();
if (Tok.isNot(tok::html_quoted_string)) {
Diag(Tok.getLocation(),
- diag::warn_doc_html_open_tag_expected_quoted_string)
+ diag::warn_doc_html_start_tag_expected_quoted_string)
<< SourceRange(Equals.getLocation());
- Attrs.push_back(HTMLOpenTagComment::Attribute(Ident.getLocation(),
- Ident.getHTMLIdent()));
+ Attrs.push_back(HTMLStartTagComment::Attribute(Ident.getLocation(),
+ Ident.getHTMLIdent()));
while (Tok.is(tok::html_equals) ||
Tok.is(tok::html_quoted_string))
consumeToken();
continue;
}
- Attrs.push_back(HTMLOpenTagComment::Attribute(
+ Attrs.push_back(HTMLStartTagComment::Attribute(
Ident.getLocation(),
Ident.getHTMLIdent(),
Equals.getLocation(),
@@ -198,25 +198,25 @@ HTMLOpenTagComment *Parser::parseHTMLOpenTag() {
}
case tok::html_greater:
- HOT = S.actOnHTMLOpenTagFinish(HOT,
- copyArray(llvm::makeArrayRef(Attrs)),
- Tok.getLocation(),
- /* IsSelfClosing = */ false);
+ HST = S.actOnHTMLStartTagFinish(HST,
+ copyArray(llvm::makeArrayRef(Attrs)),
+ Tok.getLocation(),
+ /* IsSelfClosing = */ false);
consumeToken();
- return HOT;
+ return HST;
case tok::html_slash_greater:
- HOT = S.actOnHTMLOpenTagFinish(HOT,
- copyArray(llvm::makeArrayRef(Attrs)),
- Tok.getLocation(),
- /* IsSelfClosing = */ true);
+ HST = S.actOnHTMLStartTagFinish(HST,
+ copyArray(llvm::makeArrayRef(Attrs)),
+ Tok.getLocation(),
+ /* IsSelfClosing = */ true);
consumeToken();
- return HOT;
+ return HST;
case tok::html_equals:
case tok::html_quoted_string:
Diag(Tok.getLocation(),
- diag::warn_doc_html_open_tag_expected_ident_or_greater);
+ diag::warn_doc_html_start_tag_expected_ident_or_greater);
while (Tok.is(tok::html_equals) ||
Tok.is(tok::html_quoted_string))
consumeToken();
@@ -225,20 +225,20 @@ HTMLOpenTagComment *Parser::parseHTMLOpenTag() {
Tok.is(tok::html_slash_greater))
continue;
- return S.actOnHTMLOpenTagFinish(HOT,
+ return S.actOnHTMLStartTagFinish(HST,
+ copyArray(llvm::makeArrayRef(Attrs)),
+ SourceLocation(),
+ /* IsSelfClosing = */ false);
+
+ default:
+ // Not a token from an HTML start tag. Thus HTML tag prematurely ended.
+ HST = S.actOnHTMLStartTagFinish(HST,
copyArray(llvm::makeArrayRef(Attrs)),
SourceLocation(),
/* IsSelfClosing = */ false);
-
- default:
- // Not a token from an HTML open tag. Thus HTML tag prematurely ended.
- HOT = S.actOnHTMLOpenTagFinish(HOT,
- copyArray(llvm::makeArrayRef(Attrs)),
- SourceLocation(),
- /* IsSelfClosing = */ false);
bool StartLineInvalid;
const unsigned StartLine = SourceMgr.getPresumedLineNumber(
- HOT->getLocation(),
+ HST->getLocation(),
&StartLineInvalid);
bool EndLineInvalid;
const unsigned EndLine = SourceMgr.getPresumedLineNumber(
@@ -246,22 +246,22 @@ HTMLOpenTagComment *Parser::parseHTMLOpenTag() {
&EndLineInvalid);
if (StartLineInvalid || EndLineInvalid || StartLine == EndLine)
Diag(Tok.getLocation(),
- diag::warn_doc_html_open_tag_expected_ident_or_greater)
- << HOT->getSourceRange();
+ diag::warn_doc_html_start_tag_expected_ident_or_greater)
+ << HST->getSourceRange();
else {
Diag(Tok.getLocation(),
- diag::warn_doc_html_open_tag_expected_ident_or_greater);
- Diag(HOT->getLocation(), diag::note_doc_html_tag_started_here)
- << HOT->getSourceRange();
+ diag::warn_doc_html_start_tag_expected_ident_or_greater);
+ Diag(HST->getLocation(), diag::note_doc_html_tag_started_here)
+ << HST->getSourceRange();
}
- return HOT;
+ return HST;
}
}
}
-HTMLCloseTagComment *Parser::parseHTMLCloseTag() {
- assert(Tok.is(tok::html_tag_close));
- Token TokTagOpen = Tok;
+HTMLEndTagComment *Parser::parseHTMLEndTag() {
+ assert(Tok.is(tok::html_end_tag));
+ Token TokEndTag = Tok;
consumeToken();
SourceLocation Loc;
if (Tok.is(tok::html_greater)) {
@@ -269,9 +269,9 @@ HTMLCloseTagComment *Parser::parseHTMLCloseTag() {
consumeToken();
}
- return S.actOnHTMLCloseTag(TokTagOpen.getLocation(),
- Loc,
- TokTagOpen.getHTMLTagCloseName());
+ return S.actOnHTMLEndTag(TokEndTag.getLocation(),
+ Loc,
+ TokEndTag.getHTMLTagEndName());
}
BlockContentComment *Parser::parseParagraphOrBlockCommand() {
@@ -315,12 +315,12 @@ BlockContentComment *Parser::parseParagraphOrBlockCommand() {
}
// Don't deal with HTML tag soup now.
- case tok::html_tag_open:
- Content.push_back(parseHTMLOpenTag());
+ case tok::html_start_tag:
+ Content.push_back(parseHTMLStartTag());
continue;
- case tok::html_tag_close:
- Content.push_back(parseHTMLCloseTag());
+ case tok::html_end_tag:
+ Content.push_back(parseHTMLEndTag());
continue;
case tok::text:
@@ -418,8 +418,8 @@ BlockContentComment *Parser::parseBlockContent() {
switch (Tok.getKind()) {
case tok::text:
case tok::command:
- case tok::html_tag_open:
- case tok::html_tag_close:
+ case tok::html_start_tag:
+ case tok::html_end_tag:
return parseParagraphOrBlockCommand();
case tok::verbatim_block_begin:
diff --git a/lib/AST/CommentSema.cpp b/lib/AST/CommentSema.cpp
index 69cc01683c..955629c658 100644
--- a/lib/AST/CommentSema.cpp
+++ b/lib/AST/CommentSema.cpp
@@ -273,40 +273,38 @@ VerbatimLineComment *Sema::actOnVerbatimLine(SourceLocation LocBegin,
Text);
}
-HTMLOpenTagComment *Sema::actOnHTMLOpenTagStart(SourceLocation LocBegin,
- StringRef TagName) {
- HTMLOpenTagComment *HOT =
- new (Allocator) HTMLOpenTagComment(LocBegin, TagName);
- return HOT;
+HTMLStartTagComment *Sema::actOnHTMLStartTagStart(SourceLocation LocBegin,
+ StringRef TagName) {
+ return new (Allocator) HTMLStartTagComment(LocBegin, TagName);
}
-HTMLOpenTagComment *Sema::actOnHTMLOpenTagFinish(
- HTMLOpenTagComment *Tag,
- ArrayRef<HTMLOpenTagComment::Attribute> Attrs,
+HTMLStartTagComment *Sema::actOnHTMLStartTagFinish(
+ HTMLStartTagComment *Tag,
+ ArrayRef<HTMLStartTagComment::Attribute> Attrs,
SourceLocation GreaterLoc,
bool IsSelfClosing) {
Tag->setAttrs(Attrs);
Tag->setGreaterLoc(GreaterLoc);
if (IsSelfClosing)
Tag->setSelfClosing();
- else if (!isHTMLCloseTagForbidden(Tag->getTagName()))
+ else if (!isHTMLEndTagForbidden(Tag->getTagName()))
HTMLOpenTags.push_back(Tag);
return Tag;
}
-HTMLCloseTagComment *Sema::actOnHTMLCloseTag(SourceLocation LocBegin,
- SourceLocation LocEnd,
- StringRef TagName) {
- HTMLCloseTagComment *HCT =
- new (Allocator) HTMLCloseTagComment(LocBegin, LocEnd, TagName);
- if (isHTMLCloseTagForbidden(TagName)) {
- Diag(HCT->getLocation(), diag::warn_doc_html_close_forbidden)
- << TagName << HCT->getSourceRange();
- return HCT;
+HTMLEndTagComment *Sema::actOnHTMLEndTag(SourceLocation LocBegin,
+ SourceLocation LocEnd,
+ StringRef TagName) {
+ HTMLEndTagComment *HET =
+ new (Allocator) HTMLEndTagComment(LocBegin, LocEnd, TagName);
+ if (isHTMLEndTagForbidden(TagName)) {
+ Diag(HET->getLocation(), diag::warn_doc_html_end_forbidden)
+ << TagName << HET->getSourceRange();
+ return HET;
}
bool FoundOpen = false;
- for (SmallVectorImpl<HTMLOpenTagComment *>::const_reverse_iterator
+ for (SmallVectorImpl<HTMLStartTagComment *>::const_reverse_iterator
I = HTMLOpenTags.rbegin(), E = HTMLOpenTags.rend();
I != E; ++I) {
if ((*I)->getTagName() == TagName) {
@@ -315,44 +313,44 @@ HTMLCloseTagComment *Sema::actOnHTMLCloseTag(SourceLocation LocBegin,
}
}
if (!FoundOpen) {
- Diag(HCT->getLocation(), diag::warn_doc_html_close_unbalanced)
- << HCT->getSourceRange();
- return HCT;
+ Diag(HET->getLocation(), diag::warn_doc_html_end_unbalanced)
+ << HET->getSourceRange();
+ return HET;
}
while (!HTMLOpenTags.empty()) {
- const HTMLOpenTagComment *HOT = HTMLOpenTags.back();
+ const HTMLStartTagComment *HST = HTMLOpenTags.back();
HTMLOpenTags.pop_back();
- StringRef LastNotClosedTagName = HOT->getTagName();
+ StringRef LastNotClosedTagName = HST->getTagName();
if (LastNotClosedTagName == TagName)
break;
- if (isHTMLCloseTagOptional(LastNotClosedTagName))
+ if (isHTMLEndTagOptional(LastNotClosedTagName))
continue;
bool OpenLineInvalid;
const unsigned OpenLine = SourceMgr.getPresumedLineNumber(
- HOT->getLocation(),
+ HST->getLocation(),
&OpenLineInvalid);
bool CloseLineInvalid;
const unsigned CloseLine = SourceMgr.getPresumedLineNumber(
- HCT->getLocation(),
+ HET->getLocation(),
&CloseLineInvalid);
if (OpenLineInvalid || CloseLineInvalid || OpenLine == CloseLine)
- Diag(HOT->getLocation(), diag::warn_doc_html_open_close_mismatch)
- << HOT->getTagName() << HCT->getTagName()
- << HOT->getSourceRange() << HCT->getSourceRange();
+ Diag(HST->getLocation(), diag::warn_doc_html_start_end_mismatch)
+ << HST->getTagName() << HET->getTagName()
+ << HST->getSourceRange() << HET->getSourceRange();
else {
- Diag(HOT->getLocation(), diag::warn_doc_html_open_close_mismatch)
- << HOT->getTagName() << HCT->getTagName()
- << HOT->getSourceRange();
- Diag(HCT->getLocation(), diag::note_doc_html_closing_tag)
- << HCT->getSourceRange();
+ Diag(HST->getLocation(), diag::warn_doc_html_start_end_mismatch)
+ << HST->getTagName() << HET->getTagName()
+ << HST->getSourceRange();
+ Diag(HET->getLocation(), diag::note_doc_html_end_tag)
+ << HET->getSourceRange();
}
}
- return HCT;
+ return HET;
}
FullComment *Sema::actOnFullComment(
@@ -454,7 +452,7 @@ bool Sema::isInlineCommand(StringRef Name) {
.Default(false);
}
-bool Sema::isHTMLCloseTagOptional(StringRef Name) {
+bool Sema::isHTMLEndTagOptional(StringRef Name) {
return llvm::StringSwitch<bool>(Name)
.Case("p", true)
.Case("li", true)
@@ -470,7 +468,7 @@ bool Sema::isHTMLCloseTagOptional(StringRef Name) {
.Default(false);
}
-bool Sema::isHTMLCloseTagForbidden(StringRef Name) {
+bool Sema::isHTMLEndTagForbidden(StringRef Name) {
return llvm::StringSwitch<bool>(Name)
.Case("br", true)
.Case("hr", true)