[cfe-commits] r160078 - in /cfe/trunk: include/clang/AST/ include/clang/Basic/ include/clang/Sema/ lib/AST/ lib/Basic/ lib/Sema/ test/Sema/ tools/diagtool/ unittests/AST/

Douglas Gregor dgregor at apple.com
Wed Jul 11 17:19:59 PDT 2012


On Jul 11, 2012, at 2:38 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:

> Author: gribozavr
> Date: Wed Jul 11 16:38:39 2012
> New Revision: 160078
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=160078&view=rev
> Log:
> Enable comment parsing and semantic analysis to emit diagnostics.  A few
> diagnostics implemented -- see testcases.
> 
> I created a new TableGen file for comment diagnostics,
> DiagnosticCommentKinds.td, because comment diagnostics don't logically
> fit into AST diagnostics file.  But I don't feel strongly about it.
> 
> This also implements support for self-closing HTML tags in comment
> lexer and parser (for example, <br />).
> 
> In order to issue precise diagnostics CommentSema needs to know the
> declaration the comment is attached to.  There is no easy way to find a decl by 
> comment, so we match comments and decls in lockstep: after parsing one
> declgroup we check if we have any new, not yet attached comments.  If we do --
> then we do the usual comment-finding process.
> 
> It is interesting that this automatically handles trailing comments.
> We pick up not only comments that precede the declaration, but also
> comments that *follow* the declaration -- thanks to the lookahead in
> the lexer: after parsing the declgroup we've consumed the semicolon
> and looked ahead through comments.
> 
> Added -Wdocumentation-html flag for semantic HTML errors to allow the user to 
> disable only HTML warnings (but not HTML parse errors, which we emit as
> warnings in -Wdocumentation).

Awesome!

> Added: cfe/trunk/test/Sema/warn-documentation.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.m?rev=160078&view=auto
> ==============================================================================
> --- cfe/trunk/test/Sema/warn-documentation.m (added)
> +++ cfe/trunk/test/Sema/warn-documentation.m Wed Jul 11 16:38:39 2012
> @@ -0,0 +1,24 @@
> +// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s
> +
> + at class NSString;
> +
> +// expected-warning at +2 {{empty paragraph passed to '\brief' command}}
> +/**
> + * \brief\brief Aaa
> + */
> + at interface A
> +// expected-warning at +2 {{empty paragraph passed to '\brief' command}}
> +/**
> + * \brief\brief Aaa
> + * \param aaa Aaa
> + * \param bbb Bbb
> + */
> ++ (NSString *)test1:(NSString *)aaa suffix:(NSString *)bbb;
> +
> +// expected-warning at +2 {{parameter 'aab' not found in the function declaration}} expected-note at +2 {{did you mean 'aaa'?}}
> +/**
> + * \param aab Aaa
> + */
> ++ (NSString *)test2:(NSString *)aaa;
> + at end
> +

There are a bunch of Objective-C things that may need special handling, because they won't go through DeclGroups. Here they are:

@interface A(Category) // a category: ObjCCategoryDecl
@property id foo; // a property: ObjCPropertyDecl
@end

@interface A() // a class extension: ObjCCategoryDecl
@end

@implementation A // a class implementation : ObjCImplementationDecl
@synthesize foo; // a property implementation: ObjCPropertyImplDecl
@dynamic foo; // a property implementation: ObjCPropertyImplDecl
@end

@implementation A(Category) // a category implementation: ObjCCategoryImplDecl
@end

@protocol P // a protocol: ObjCProtocolDecl
@end

	- Doug




More information about the cfe-commits mailing list