[cfe-commits] r159001 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/Sema.cpp test/Analysis/retain-release.m test/Sema/doxygen-comments.c
Dmitri Gribenko
gribozavr at gmail.com
Fri Jun 22 09:02:55 PDT 2012
Author: gribozavr
Date: Fri Jun 22 11:02:55 2012
New Revision: 159001
URL: http://llvm.org/viewvc/llvm-project?rev=159001&view=rev
Log:
Add a warning about almost-Doxygen trailing comments: //< and /*< ... */
Added:
cfe/trunk/test/Sema/doxygen-comments.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/test/Analysis/retain-release.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=159001&r1=159000&r2=159001&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Jun 22 11:02:55 2012
@@ -57,6 +57,7 @@
def : DiagGroup<"disabled-optimization">;
def : DiagGroup<"discard-qual">;
def : DiagGroup<"div-by-zero">;
+def Doxygen : DiagGroup<"doxygen">;
def EmptyBody : DiagGroup<"empty-body">;
def ExtraTokens : DiagGroup<"extra-tokens">;
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=159001&r1=159000&r2=159001&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jun 22 11:02:55 2012
@@ -5665,5 +5665,10 @@
"definition of %0 must be imported before it is required">;
}
+let CategoryName = "Documentation Issue" in {
+def warn_not_a_doxygen_trailing_member_comment : Warning<
+ "not a Doxygen trailing comment">, InGroup<Doxygen>;
+} // end of documentation issue category
+
} // end of sema component.
Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=159001&r1=159000&r2=159001&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Fri Jun 22 11:02:55 2012
@@ -1016,6 +1016,24 @@
void Sema::ActOnComment(SourceRange Comment) {
RawComment RC(SourceMgr, Comment);
+ if (RC.isAlmostTrailingComment()) {
+ SourceRange MagicMarkerRange(Comment.getBegin(),
+ Comment.getBegin().getLocWithOffset(3));
+ StringRef MagicMarkerText;
+ switch (RC.getKind()) {
+ case RawComment::CK_OrdinaryBCPL:
+ MagicMarkerText = "///<";
+ break;
+ case RawComment::CK_OrdinaryC:
+ MagicMarkerText = "/**<";
+ break;
+ default:
+ llvm_unreachable("if this is an almost Doxygen comment, "
+ "it should be ordinary");
+ }
+ Diag(Comment.getBegin(), diag::warn_not_a_doxygen_trailing_member_comment) <<
+ FixItHint::CreateReplacement(MagicMarkerRange, MagicMarkerText);
+ }
Context.addComment(RC);
}
Modified: cfe/trunk/test/Analysis/retain-release.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.m?rev=159001&r1=159000&r2=159001&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/retain-release.m (original)
+++ cfe/trunk/test/Analysis/retain-release.m Fri Jun 22 11:02:55 2012
@@ -753,7 +753,7 @@
@end
//===----------------------------------------------------------------------===//
-//<rdar://problem/6320065> false positive - init method returns an object
+// <rdar://problem/6320065> false positive - init method returns an object
// owned by caller
//===----------------------------------------------------------------------===//
Added: cfe/trunk/test/Sema/doxygen-comments.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/doxygen-comments.c?rev=159001&view=auto
==============================================================================
--- cfe/trunk/test/Sema/doxygen-comments.c (added)
+++ cfe/trunk/test/Sema/doxygen-comments.c Fri Jun 22 11:02:55 2012
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: cp %s %t
+// RUN: %clang_cc1 -fsyntax-only -fixit %t
+// RUN: %clang_cc1 -fsyntax-only -Werror %t
+
+struct a {
+ int x; //< comment // expected-warning {{not a Doxygen trailing comment}}
+ int y; /*< comment */ // expected-warning {{not a Doxygen trailing comment}}
+};
+
+// CHECK: fix-it:"{{.*}}":{8:10-8:13}:"///<"
+// CHECK: fix-it:"{{.*}}":{9:10-9:13}:"/**<"
+
More information about the cfe-commits
mailing list