aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/Comment.cpp
AgeCommit message (Collapse)AuthorFilesLines
2017-04-26[AST] Look through attribute type locs when searching for function typeAlex Lorenz1-0/+3
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-21[PR32667] -Wdocumentation should allow @param/@returns for fields/variablesAlex Lorenz1-0/+17
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
2016-08-25[Sema][Comments] Add support for TypeAliasTemplateBruno Cardoso Lopes1-0/+14
Emit proper diagnostics when -Wdocumentation is used with constructs such as: template<typename T> using fn = int(T aaa, int ccc); Previously clang wouldn't recognize the function and complain with 'comment that is not attached to a function declaration'. Differential Revision: https://reviews.llvm.org/D23860 rdar://problem/27300695 llvm-svn: 279754
2016-08-25[Sema][Comments] Factor out function type loc logic. NFCIBruno Cardoso Lopes1-64/+64
This is in prepatation for @param TypeAliasTemplate support. llvm-svn: 279691
2016-08-24[Sema][Comments] Support @param with c++ 'using' keywordBruno Cardoso Lopes1-6/+6
Give appropriate warnings with -Wdocumentation for @param comments that refer to function aliases defined with 'using'. Very similar to typedef's behavior. This does not add support for TypeAliasTemplateDecl yet. Differential Revision: https://reviews.llvm.org/D23783 rdar://problem/27300695 llvm-svn: 279662
2016-07-18[NFC] Header cleanupMehdi Amini1-2/+1
Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
2016-06-24Use more ArrayRefsDavid Majnemer1-3/+3
No functional change is intended, just a small refactoring. llvm-svn: 273647
2014-08-30Use llvm::makeArrayRef instead of explicitly calling ArrayRef constructor ↵Craig Topper1-12/+5
and mentioning the type. This works now that we have a conversion from ArrayRef<T*> to ArrayRef<const T*>. llvm-svn: 216824
2014-05-12[C++11] Use 'nullptr'. AST edition.Craig Topper1-1/+1
llvm-svn: 208517
2014-01-25Rename getResultLoc() tooAlp Toker1-2/+2
Follow up to r200082. Spotted by Dmitri llvm-svn: 200105
2014-01-25Rename getResultType() on function and method declarations to getReturnType()Alp Toker1-5/+5
A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
2013-12-17Documentation comment parsing: when checking if we have typedef to somethingDmitri Gribenko1-0/+5
that we consider a function for the purposes of checking \param and \returns, look through reference types. llvm-svn: 197530
2013-12-17Documentation comment parsing: allow \param and \returns on std::function,Dmitri Gribenko1-0/+26
boost::function and similar function-like objects llvm-svn: 197528
2013-12-05Add an AdjustedType sugar node for adjusting calling conventionsReid Kleckner1-0/+5
Summary: In general, this type node can be used to represent any type adjustment that occurs implicitly without losing type sugar. The immediate use of this is to adjust the calling conventions of member function pointer types without breaking template instantiation. Fixes PR17996. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D2332 llvm-svn: 196451
2013-09-10Add unused markings to suppress warnings.Eli Friedman1-1/+3
trunk clang is a bit more aggressive about emitting unused-declaration warnings, so adjust some AST code to match. Specifically, use LLVM_ATTRIBUTE_UNUSED for declarations which are never supposed to be referenced, and turn references to declarations which are supposed to be referenced into odr-uses. llvm-svn: 190443
2013-08-23Use CharInfo.h routines in TextComment::isWhitespaceNoCacheDmitri Gribenko1-3/+2
llvm-svn: 189115
2013-07-05[comment parsing]: Removes an unsafe API whoseFariborz Jahanian1-2/+2
use can cause crash. No test is available. It is uncovered by code browsing. // rdar://14348205 llvm-svn: 185732
2013-06-24Comment parsing: allow "\param ..." to describe variadic argumentsDmitri Gribenko1-0/+2
Original patch by Fariborz Jahanian; extended by me. Fixes rdar://14124644 llvm-svn: 184688
2013-05-05Replace ArrayRef<T>() with None, now that we have an implicit ArrayRef ↵Dmitri Gribenko1-1/+1
constructor from None Patch by Robert Wilhelm. llvm-svn: 181139
2013-02-18Replace TypeLoc llvm::cast support to be well-defined.David Blaikie1-13/+13
The TypeLoc hierarchy used the llvm::cast machinery to perform undefined behavior by casting pointers/references to TypeLoc objects to derived types and then using the derived copy constructors (or even returning pointers to derived types that actually point to the original TypeLoc object). Some context is in this thread: http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-December/056804.html Though it's spread over a few months which can be hard to read in the mail archive. llvm-svn: 175462
2013-01-14Dump comments in -ast-dump.Alexander Kornienko1-14/+0
http://llvm-reviews.chandlerc.com/D269 "Added dumping of declaration comments in ASTDumper. This required moving the comment dumping code from CommentDumper so that the indentation is correct." Patch by Philip Craig! llvm-svn: 172409
2012-10-19Remove const_casts by propagating constness down to called functions.Dmitri Gribenko1-3/+3
llvm-svn: 166287
2012-10-18[doc parsing] use getParamName to access parameter Fariborz Jahanian1-13/+11
for current(rewritten) comment and getParamNameAsWritten to access param name coming with \param marker. llvm-svn: 166231
2012-10-17[Doc parsing]: This patch adds <Declaration> tag to Fariborz Jahanian1-1/+1
XML comment for declarations which pretty-prints declaration. I had to XFAIL one test annotate-comments.cpp. This test is currently unmaintainable as written. Dmitri G., can you see what we can do about this test. We should change this test such that adding a new tag does not wreck havoc to the test. llvm-svn: 166130
2012-10-15Fixes location of overriding declaration with no commentFariborz Jahanian1-1/+2
of their own. llvm-svn: 165972
2012-10-15structured document comment: patch to provide comment for overriding functionFariborz Jahanian1-0/+15
template when comment is comming from overridden declaration. // rdar://12378793 llvm-svn: 165953
2012-10-11search for overridden methods with comment when overriding methodFariborz Jahanian1-0/+6
has none of its own. Factor in Doug's comments. // rdar://12378793 llvm-svn: 165771
2012-10-10[Doc parsing] This patch searches overridden objc/c++Fariborz Jahanian1-10/+10
methods looking for documentation on a particular base class inherited by any method that overrides the base class. In case of redeclaration, as when objc method is defined in the implementation, it also looks up for documentation in class/class extension being redeclared. llvm-svn: 165643
2012-09-15Comment parsing: don't treat typedef to a typedef to a function as aDmitri Gribenko1-8/+0
'function-like' type that can be annotated with \param. Thanks to Eli Friedman for noticing! llvm-svn: 163985
2012-09-10Comment AST: TableGen'ize all command lists in CommentCommandTraits.cpp.Dmitri Gribenko1-3/+5
Now we have a list of all commands. This is a good thing in itself, but it also enables us to easily implement typo correction for command names. With this change we have objects that contain information about each command, so it makes sense to resolve command name just once during lexing (currently we store command names as strings and do a linear search every time some property value is needed). Thus comment token and AST nodes were changed to contain a command ID -- index into a tables of builtin and registered commands. Unknown commands are registered during parsing and thus are also uniformly assigned an ID. Using an ID instead of a StringRef is also a nice memory optimization since ID is a small integer that fits into a common bitfield in Comment class. This change implies that to get any information about a command (even a command name) we need a CommandTraits object to resolve the command ID to CommandInfo*. Currently a fresh temporary CommandTraits object is created whenever it is needed since it does not have any state. But with this change it has state -- new commands can be registered, so a CommandTraits object was added to ASTContext. Also, in libclang CXComment has to be expanded to include a CXTranslationUnit so that all functions working on comment AST nodes can get a CommandTraits object. This breaks binary compatibility of CXComment APIs. Now clang_FullComment_getAsXML(CXTranslationUnit TU, CXComment CXC) doesn't need TU parameter anymore, so it was removed. This is a source-incompatible change for this C API. llvm-svn: 163540
2012-08-24Comment semantic analysis: treat function typedefs as functions so that one canDmitri Gribenko1-1/+52
use \param and \returns in documentation. Fixes PR13533. llvm-svn: 162507
2012-08-07Comment AST: DeclInfo: add a special kind for enums.Dmitri Gribenko1-0/+3
Comment XML: add a root node kind for enums. llvm-svn: 161442
2012-08-07Comment AST: treat enumerators as "variables" in DeclInfo.Dmitri Gribenko1-0/+1
llvm-svn: 161435
2012-08-06Comment AST: DeclInfo: collapse a bunch of boolean flags into an enum.Dmitri Gribenko1-12/+7
llvm-svn: 161352
2012-08-06Comment diagnostics: \return in void function: specialize diagnostic text forDmitri Gribenko1-0/+2
ObjC methods. llvm-svn: 161324
2012-08-03Comment diagnostics: warn if \returns is used in a non-function comment or ifDmitri Gribenko1-2/+7
the function returns void. llvm-svn: 161261
2012-08-03Comment AST: convert a huge if -- else if statement on Decl's type into aDmitri Gribenko1-17/+56
switch. Thanks Sean Silva for suggestion! llvm-svn: 161225
2012-08-02Comments AST: refactor DeclInfo to use an enum for decl kind instead ofDmitri Gribenko1-4/+17
separate flags. llvm-svn: 161217
2012-08-02Comments: handle template paramter documentation in alias-declarationDmitri Gribenko1-0/+4
templates. llvm-svn: 161215
2012-08-01Comment AST: add DeclInfo to store information about the declaration. Sema wasDmitri Gribenko1-0/+64
already extracting most of this, but discarding at the end of semantic analysis. llvm-svn: 161140
2012-07-19Fix ParagraphComment::isWhitespace(): a paragraph without a non-whitespaceDmitri Gribenko1-1/+2
TextComment node was considered whitespace even if it contained other child nodes. llvm-svn: 160474
2012-07-18Add caching for TextComment::isWhitespace(), ParagraphComment::isWhitespace().Dmitri Gribenko1-2/+2
llvm-svn: 160452
2012-07-18On Darwin, the linker removes functions in CommentDumper.o (Comment::dump())Dmitri Gribenko1-0/+14
despite __attribute__(__used__). As explained by Argyrios, > .a archive files do some stripping of their own and they remove .o files that > contain functions that are not referenced by any other .o file. The fix is to use these functions from another .o file. Thanks, Argyrios! llvm-svn: 160437
2012-07-11Enable comment parsing and semantic analysis to emit diagnostics. A fewDmitri Gribenko1-0/+32
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-06Sprinkle llvm_unreachable around to placate GCC's -Wreturn-type.Matt Beaumont-Gay1-1/+2
llvm-svn: 159860
2012-07-06Implement AST classes for comments, a real parser for Doxygen comments and aDmitri Gribenko1-0/+90
very simple semantic analysis that just builds the AST; minor changes for lexer to pick up source locations I didn't think about before. Comments AST is modelled along the ideas of HTML AST: block and inline content. * Block content is a paragraph or a command that has a paragraph as an argument or verbatim command. * Inline content is placed within some block. Inline content includes plain text, inline commands and HTML as tag soup. llvm-svn: 159790