[cfe-commits] r160156 - in /cfe/trunk: lib/AST/ASTContext.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclObjC.cpp lib/Sema/SemaObjCProperty.cpp test/Sema/warn-documentation.m
Dmitri Gribenko
gribozavr at gmail.com
Thu Jul 12 18:06:46 PDT 2012
Author: gribozavr
Date: Thu Jul 12 20:06:46 2012
New Revision: 160156
URL: http://llvm.org/viewvc/llvm-project?rev=160156&view=rev
Log:
Attaching comments to declarations during parsing: handle more Objective-C declarations.
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/Sema/warn-documentation.m
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=160156&r1=160155&r2=160156&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Jul 12 20:06:46 2012
@@ -78,9 +78,21 @@
if (RawComments.empty())
return NULL;
+ // Find declaration location.
+ // For Objective-C declarations we generally don't expect to have multiple
+ // declarators, thus use declaration starting location as the "declaration
+ // location".
+ // For all other declarations multiple declarators are used quite frequently,
+ // so we use the location of the identifier as the "declaration location".
+ SourceLocation DeclLoc;
+ if (isa<ObjCMethodDecl>(D) || isa<ObjCContainerDecl>(D) ||
+ isa<ObjCPropertyDecl>(D))
+ DeclLoc = D->getLocStart();
+ else
+ DeclLoc = D->getLocation();
+
// If the declaration doesn't map directly to a location in a file, we
// can't find the comment.
- SourceLocation DeclLoc = D->getLocation();
if (DeclLoc.isInvalid() || !DeclLoc.isFileID())
return NULL;
@@ -144,7 +156,7 @@
// There should be no other declarations or preprocessor directives between
// comment and declaration.
- if (Text.find_first_of(",;{}#") != StringRef::npos)
+ if (Text.find_first_of(",;{}#@") != StringRef::npos)
return NULL;
return *Comment;
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=160156&r1=160155&r2=160156&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jul 12 20:06:46 2012
@@ -8932,7 +8932,6 @@
assert(getContainingDC(OCD) == CurContext &&
"The next DeclContext should be lexically contained in the current one.");
CurContext = OCD;
- ActOnDocumentableDecl(IDecl);
return IDecl;
}
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=160156&r1=160155&r2=160156&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Jul 12 20:06:46 2012
@@ -2429,6 +2429,7 @@
Consumer.HandleTopLevelDeclInObjCContainer(DG);
}
+ ActOnDocumentableDecl(ClassDecl);
return ClassDecl;
}
Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=160156&r1=160155&r2=160156&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Thu Jul 12 20:06:46 2012
@@ -149,6 +149,7 @@
if (getLangOpts().ObjCAutoRefCount)
checkARCPropertyDecl(*this, cast<ObjCPropertyDecl>(Res));
}
+ ActOnDocumentableDecl(Res);
return Res;
}
@@ -169,6 +170,7 @@
if (getLangOpts().ObjCAutoRefCount)
checkARCPropertyDecl(*this, Res);
+ ActOnDocumentableDecl(Res);
return Res;
}
Modified: cfe/trunk/test/Sema/warn-documentation.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.m?rev=160156&r1=160155&r2=160156&view=diff
==============================================================================
--- cfe/trunk/test/Sema/warn-documentation.m (original)
+++ cfe/trunk/test/Sema/warn-documentation.m Thu Jul 12 20:06:46 2012
@@ -2,11 +2,9 @@
@class NSString;
-// expected-warning at +2 {{empty paragraph passed to '\brief' command}}
-/**
- * \brief\brief Aaa
- */
- at interface A
+// expected-warning at +1 {{empty paragraph passed to '\brief' command}}
+/// \brief\brief Aaa
+ at interface Test1
// expected-warning at +2 {{empty paragraph passed to '\brief' command}}
/**
* \brief\brief Aaa
@@ -20,5 +18,67 @@
* \param aab Aaa
*/
+ (NSString *)test2:(NSString *)aaa;
+
+// expected-warning at +1 {{empty paragraph passed to '\brief' command}}
+/// \brief\brief Aaa
+ at property int test3; // a property: ObjCPropertyDecl
+
+// expected-warning at +1 {{empty paragraph passed to '\brief' command}}
+/// \brief\brief Aaa
+ at property int test4; // a property: ObjCPropertyDecl
@end
+// expected-warning at +1 {{empty paragraph passed to '\brief' command}}
+/// \brief\brief Aaa
+ at interface Test1()
+ at end
+
+// expected-warning at +1 {{empty paragraph passed to '\brief' command}}
+/// \brief\brief Aaa
+ at implementation Test1 // a class implementation : ObjCImplementationDecl
++ (NSString *)test1:(NSString *)aaa suffix:(NSString *)bbb {
+ return 0;
+}
+
++ (NSString *)test2:(NSString *)aaa {
+ return 0;
+}
+
+ at synthesize test3; // a property implementation: ObjCPropertyImplDecl
+ at dynamic test4; // a property implementation: ObjCPropertyImplDecl
+
+// expected-warning at +1 {{empty paragraph passed to '\brief' command}}
+/// \brief\brief Aaa
+NSString *_test5;
+ at end
+
+// expected-warning at +1 {{empty paragraph passed to '\brief' command}}
+/// \brief\brief Aaa
+ at interface Test1(Test1Category) // a category: ObjCCategoryDecl
+// expected-warning at +1 {{empty paragraph passed to '\brief' command}}
+/// \brief\brief Aaa
++ (NSString *)test3:(NSString *)aaa;
+ at end
+
+// expected-warning at +1 {{empty paragraph passed to '\brief' command}}
+/// \brief\brief Aaa
+ at implementation Test1(Test1Category) // a category implementation: ObjCCategoryImplDecl
++ (NSString *)test3:(NSString *)aaa {
+ return 0;
+}
+ at end
+
+// expected-warning at +1 {{empty paragraph passed to '\brief' command}}
+/// \brief\brief Aaa
+ at protocol TestProto1 // a protocol: ObjCProtocolDecl
+ at end
+
+int a;
+
+// expected-warning at +1 {{empty paragraph passed to '\brief' command}}
+/// \brief\brief Aaa
+ at interface Test4
+ at end
+
+int b;
+
More information about the cfe-commits
mailing list