aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/CommentSema.cpp
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2012-07-13 00:44:24 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2012-07-13 00:44:24 +0000
commit3f38bf2d441fac379c427f86153fbb0cb41256c6 (patch)
tree85044422828656cba608b746c8e3e6937697aeb9 /lib/AST/CommentSema.cpp
parent3d986980bd02594b1a5aa7b9f9f68d201621ced7 (diff)
Comment parsing: repaint the bikesched: rename 'HTML open tags' to 'HTML start tags' and 'HTML close tags' to 'HTML end tags' according to HTML spec.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160153 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/CommentSema.cpp')
-rw-r--r--lib/AST/CommentSema.cpp74
1 files changed, 36 insertions, 38 deletions
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)