Commit Graph

28 Commits

Author SHA1 Message Date
Erik Pilkington 29a4239d31 [Sema] Fix a crash when attaching comments to an implicit decl
When an implicitly generated decl was the first entry in the group, we
attempted to lookup comments with an empty FileID, leading to crashes. Avoid
this by trying to use the other declarations in the group, and then bailing out
if none are valid.

rdar://59919733
Differential revision: https://reviews.llvm.org/D75483
2020-03-02 16:49:53 -08:00
Dmitri Gribenko d94b42f422 [Wdocumentation] fixes an assertion failure with typedefed function and block pointer
Summary:
The assertion happens when compiling with -Wdocumentation with variable declaration to a typedefed function pointer. I not too familiar with the ObjC syntax but first two tests assert without this patch.

Fixes https://bugs.llvm.org/show_bug.cgi?id=42844

Reviewers: gribozavr

Reviewed By: gribozavr

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D66706

llvm-svn: 370677
2019-09-02 18:24:33 +00:00
Alexander Kornienko 2a8c18d991 Fix typos in clang
Found via codespell -q 3 -I ../clang-whitelist.txt
Where whitelist consists of:

  archtype
  cas
  classs
  checkk
  compres
  definit
  frome
  iff
  inteval
  ith
  lod
  methode
  nd
  optin
  ot
  pres
  statics
  te
  thru

Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few
files that have dubious fixes reverted.)

Differential revision: https://reviews.llvm.org/D44188

llvm-svn: 329399
2018-04-06 15:14:32 +00:00
Alex Lorenz e9baea8178 -Wdocumentation should allow '...' params in variadic function type aliases
rdar://34811344

llvm-svn: 315103
2017-10-06 20:51:04 +00:00
Alex Lorenz 00353a0bf9 -Wdocumentation should not check the @returns command for Objective-C
function/block pointer properties

The commit r300981 allowed @param/@return commands for function/block
pointer property declarations. This meant that -Wdocumentation started warning
about @return that was used to document properties whose function/block type
returned void. However, prior to that commit, we allowed @return for all
property declarations, because it can be used to document the value that's
returned by the property getter. This commit restores the previous behaviour:
now the @return command can be used to document all properties without warnings.

rdar://24978538

llvm-svn: 301402
2017-04-26 13:09:28 +00:00
Alex Lorenz 6246cc6c0e [AST] Look through attribute type locs when searching for function type
loc

Prior to this commit -Wdocumentation crashed when checking the @returns command
for declarations whose function/block pointer type included an attribute like
_Nullable.

rdar://31818195

llvm-svn: 301400
2017-04-26 12:46:27 +00:00
Alex Lorenz 6b82a75df5 [PR32667] -Wdocumentation should allow @param/@returns for fields/variables
that have a function/block pointer type

This commit improves the -Wdocumentation warning by making sure that @param and
@returns commands won't trigger warnings when used for fields, variables,
or properties whose type is a function/block pointer type. The
function/block pointer type must be specified directly with the declaration,
and when a typedef is used the warning is still emitted.

In the future we might also want to handle the std::function type as well.

rdar://24978538

llvm-svn: 300981
2017-04-21 14:17:49 +00:00
Dmitri Gribenko 02489eb406 Comment parsing: allow "\param ..." to describe variadic arguments
Original patch by Fariborz Jahanian; extended by me.

Fixes rdar://14124644

llvm-svn: 184688
2013-06-24 04:41:32 +00:00
NAKAMURA Takumi dc2e2fb9ce Revert r184249, "doc. parsing: Allow parameter name "..." for variadic functions/methods."
It crashes in the case;

/// Without any "param"s in the description.
int printf(const char *format, ...);

llvm-svn: 184283
2013-06-19 06:58:14 +00:00
Fariborz Jahanian 5222608310 doc. parsing: Allow parameter name "..." for variadic functions/methods.
// rdar://14124644

llvm-svn: 184249
2013-06-18 22:40:39 +00:00
Argyrios Kyrtzidis 0f6d5ca0bf Fix potential infinite loop when iterating over redeclarations of an ObjMethodDecl, resulting from invalid code.
Check for invalid decls in ObjCMethodDecl::getNextRedeclaration(); otherwise if we start from an invalid redeclaration
of an @implementation we would move to the @interface and not reach the original declaration again.

Fixes rdar://14024851

llvm-svn: 182951
2013-05-30 18:53:21 +00:00
Fariborz Jahanian 04eb8abba9 doc. parsing. HeaderDoc documentaton allows use of
@class command on an @interface declaration. Turn off
the warning for this case. // rdar://13927330

llvm-svn: 182334
2013-05-20 23:40:39 +00:00
Fariborz Jahanian 096f7c1e05 Objective-C error recovery. This patch makes a quick
recovery form duplicate method definition error thus
preventing doc parsing to loop trying to find comment
for the invalid redefinition in a previous declaration.
// rdar://13836387

llvm-svn: 181710
2013-05-13 17:27:00 +00:00
Fariborz Jahanian 0321b8ffd6 [doc parsing]: make single character command impostures
warn in pedantic mode.

llvm-svn: 181523
2013-05-09 17:18:52 +00:00
Fariborz Jahanian 5b637078e1 [Doc parsing] Provide diagnostics for unknown documentation
commands. // rdar://12381408

llvm-svn: 181071
2013-05-03 23:15:20 +00:00
Fariborz Jahanian abbcbaeb4c documentation comment parsing. Added couple of
top-level HeaderDoc tags @functiongroup and
@methodgroup to doc. tags recognized.
// rdar://12379114 

llvm-svn: 177358
2013-03-18 23:45:52 +00:00
Fariborz Jahanian a649eee9e8 HeaderDoc: Support more of HeaderDoc documentation
commands; top level tags such as @interface and
their 2nd level tags such as @coclass, etc.
// rdar://12379114

llvm-svn: 176667
2013-03-07 23:33:11 +00:00
Fariborz Jahanian ff81b824a2 Spell Objective-C correctly.
llvm-svn: 176563
2013-03-06 17:55:30 +00:00
Fariborz Jahanian 41bb7131b3 say objective-C in the warning and streamline
several diagnostics into one. // rdar://13094352

llvm-svn: 176560
2013-03-06 17:36:51 +00:00
Fariborz Jahanian 56fe4066e5 doc. parsing. Improve on diagnostics on my last patch.
// rdar://13094352.

llvm-svn: 176525
2013-03-05 22:46:07 +00:00
Fariborz Jahanian f4ba35d809 doc parsing. Add @method and @callback for
checkings and few other refactoring/cleanup.
// rdar://13094352.

llvm-svn: 176509
2013-03-05 19:40:47 +00:00
Dmitri Gribenko 219bd1554f Comment diagnostics: for unresolved parameters, do not suggest parameter fixit
with parameter that is documented.

Fixes PR13670, <rdar://problem/12155840>.

llvm-svn: 162570
2012-08-24 17:45:39 +00:00
Dmitri Gribenko 907f6b8c06 Comment semantic analysis: treat function typedefs as functions so that one can
use \param and \returns in documentation.

Fixes PR13533.

llvm-svn: 162507
2012-08-24 00:05:30 +00:00
Dmitri Gribenko 5ec0c7536a Comment diagnostics: warn on duplicate \brief and \return commands.
Doxygen manual claims that multiple \brief or \returns commands will be merged
together, but actual behavior is different (second \brief command becomes a
part of a discussion, second \returns becomes a "Returns: blah" paragraph on
its own).  Anyway, it seems to be a bad idea to use multiple \brief or \returns
commands in a single command.

llvm-svn: 161325
2012-08-06 17:08:27 +00:00
Dmitri Gribenko 558babc53b Comment diagnostics: \return in void function: specialize diagnostic text for
ObjC methods.

llvm-svn: 161324
2012-08-06 16:29:26 +00:00
Ted Kremenek 875a402dc3 Turn -Wobjc-root-class on by default. <rdar://problem/11203649>.
llvm-svn: 160707
2012-07-25 07:26:32 +00:00
Dmitri Gribenko e7bb944c85 Attaching comments to declarations during parsing: handle more Objective-C declarations.
llvm-svn: 160156
2012-07-13 01:06:46 +00:00
Dmitri Gribenko f26054f0fb 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).

llvm-svn: 160078
2012-07-11 21:38:39 +00:00