aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r--lib/AST/ASTContext.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 2a1521e21e..a9681d8669 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -78,9 +78,21 @@ RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const {
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 @@ RawComment *ASTContext::getRawCommentForDeclNoCache(const Decl *D) const {
// 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;