summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Comment.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove trailing spaceFangrui Song2018-07-301-1/+1
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* [AST] Look through attribute type locs when searching for function typeAlex Lorenz2017-04-261-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
* [PR32667] -Wdocumentation should allow @param/@returns for fields/variablesAlex Lorenz2017-04-211-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
* [Sema][Comments] Add support for TypeAliasTemplateBruno Cardoso Lopes2016-08-251-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
* [Sema][Comments] Factor out function type loc logic. NFCIBruno Cardoso Lopes2016-08-251-64/+64
| | | | | | This is in prepatation for @param TypeAliasTemplate support. llvm-svn: 279691
* [Sema][Comments] Support @param with c++ 'using' keywordBruno Cardoso Lopes2016-08-241-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
* [NFC] Header cleanupMehdi Amini2016-07-181-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
* Use more ArrayRefsDavid Majnemer2016-06-241-3/+3
| | | | | | No functional change is intended, just a small refactoring. llvm-svn: 273647
* Use llvm::makeArrayRef instead of explicitly calling ArrayRef constructor ↵Craig Topper2014-08-301-12/+5
| | | | | | and mentioning the type. This works now that we have a conversion from ArrayRef<T*> to ArrayRef<const T*>. llvm-svn: 216824
* [C++11] Use 'nullptr'. AST edition.Craig Topper2014-05-121-1/+1
| | | | llvm-svn: 208517
* Rename getResultLoc() tooAlp Toker2014-01-251-2/+2
| | | | | | | | Follow up to r200082. Spotted by Dmitri llvm-svn: 200105
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-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
* Documentation comment parsing: when checking if we have typedef to somethingDmitri Gribenko2013-12-171-0/+5
| | | | | | | that we consider a function for the purposes of checking \param and \returns, look through reference types. llvm-svn: 197530
* Documentation comment parsing: allow \param and \returns on std::function,Dmitri Gribenko2013-12-171-0/+26
| | | | | | boost::function and similar function-like objects llvm-svn: 197528
* Add an AdjustedType sugar node for adjusting calling conventionsReid Kleckner2013-12-051-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
* Add unused markings to suppress warnings.Eli Friedman2013-09-101-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
* Use CharInfo.h routines in TextComment::isWhitespaceNoCacheDmitri Gribenko2013-08-231-3/+2
| | | | llvm-svn: 189115
* [comment parsing]: Removes an unsafe API whoseFariborz Jahanian2013-07-051-2/+2
| | | | | | | use can cause crash. No test is available. It is uncovered by code browsing. // rdar://14348205 llvm-svn: 185732
* Comment parsing: allow "\param ..." to describe variadic argumentsDmitri Gribenko2013-06-241-0/+2
| | | | | | | | Original patch by Fariborz Jahanian; extended by me. Fixes rdar://14124644 llvm-svn: 184688
* Replace ArrayRef<T>() with None, now that we have an implicit ArrayRef ↵Dmitri Gribenko2013-05-051-1/+1
| | | | | | | | constructor from None Patch by Robert Wilhelm. llvm-svn: 181139
* Replace TypeLoc llvm::cast support to be well-defined.David Blaikie2013-02-181-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
* Dump comments in -ast-dump.Alexander Kornienko2013-01-141-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
* Remove const_casts by propagating constness down to called functions.Dmitri Gribenko2012-10-191-3/+3
| | | | llvm-svn: 166287
* [doc parsing] use getParamName to access parameter Fariborz Jahanian2012-10-181-13/+11
| | | | | | | for current(rewritten) comment and getParamNameAsWritten to access param name coming with \param marker. llvm-svn: 166231
* [Doc parsing]: This patch adds <Declaration> tag to Fariborz Jahanian2012-10-171-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
* Fixes location of overriding declaration with no commentFariborz Jahanian2012-10-151-1/+2
| | | | | | of their own. llvm-svn: 165972
* structured document comment: patch to provide comment for overriding functionFariborz Jahanian2012-10-151-0/+15
| | | | | | | template when comment is comming from overridden declaration. // rdar://12378793 llvm-svn: 165953
* search for overridden methods with comment when overriding methodFariborz Jahanian2012-10-111-0/+6
| | | | | | | has none of its own. Factor in Doug's comments. // rdar://12378793 llvm-svn: 165771
* [Doc parsing] This patch searches overridden objc/c++Fariborz Jahanian2012-10-101-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
* Comment parsing: don't treat typedef to a typedef to a function as aDmitri Gribenko2012-09-151-8/+0
| | | | | | | | 'function-like' type that can be annotated with \param. Thanks to Eli Friedman for noticing! llvm-svn: 163985
* Comment AST: TableGen'ize all command lists in CommentCommandTraits.cpp.Dmitri Gribenko2012-09-101-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
* Comment semantic analysis: treat function typedefs as functions so that one canDmitri Gribenko2012-08-241-1/+52
| | | | | | | | use \param and \returns in documentation. Fixes PR13533. llvm-svn: 162507
* Comment AST: DeclInfo: add a special kind for enums.Dmitri Gribenko2012-08-071-0/+3
| | | | | | Comment XML: add a root node kind for enums. llvm-svn: 161442
* Comment AST: treat enumerators as "variables" in DeclInfo.Dmitri Gribenko2012-08-071-0/+1
| | | | llvm-svn: 161435
* Comment AST: DeclInfo: collapse a bunch of boolean flags into an enum.Dmitri Gribenko2012-08-061-12/+7
| | | | llvm-svn: 161352
* Comment diagnostics: \return in void function: specialize diagnostic text forDmitri Gribenko2012-08-061-0/+2
| | | | | | ObjC methods. llvm-svn: 161324
* Comment diagnostics: warn if \returns is used in a non-function comment or ifDmitri Gribenko2012-08-031-2/+7
| | | | | | the function returns void. llvm-svn: 161261
* Comment AST: convert a huge if -- else if statement on Decl's type into aDmitri Gribenko2012-08-031-17/+56
| | | | | | switch. Thanks Sean Silva for suggestion! llvm-svn: 161225
* Comments AST: refactor DeclInfo to use an enum for decl kind instead ofDmitri Gribenko2012-08-021-4/+17
| | | | | | separate flags. llvm-svn: 161217
* Comments: handle template paramter documentation in alias-declarationDmitri Gribenko2012-08-021-0/+4
| | | | | | templates. llvm-svn: 161215
* Comment AST: add DeclInfo to store information about the declaration. Sema wasDmitri Gribenko2012-08-011-0/+64
| | | | | | already extracting most of this, but discarding at the end of semantic analysis. llvm-svn: 161140
* Fix ParagraphComment::isWhitespace(): a paragraph without a non-whitespaceDmitri Gribenko2012-07-191-1/+2
| | | | | | | TextComment node was considered whitespace even if it contained other child nodes. llvm-svn: 160474
* Add caching for TextComment::isWhitespace(), ParagraphComment::isWhitespace().Dmitri Gribenko2012-07-181-2/+2
| | | | llvm-svn: 160452
* On Darwin, the linker removes functions in CommentDumper.o (Comment::dump())Dmitri Gribenko2012-07-181-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
* Enable comment parsing and semantic analysis to emit diagnostics. A fewDmitri Gribenko2012-07-111-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
* Sprinkle llvm_unreachable around to placate GCC's -Wreturn-type.Matt Beaumont-Gay2012-07-061-1/+2
| | | | llvm-svn: 159860
* Implement AST classes for comments, a real parser for Doxygen comments and aDmitri Gribenko2012-07-061-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
OpenPOWER on IntegriCloud