summaryrefslogtreecommitdiff
path: root/src/qdoc/clangcodeparser.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix license headersJani Heikkinen2018-01-151-14/+20
| | | | | | | | old header.LGPL21 was used in few src files. Replace those with correct header.LGPL one Change-Id: I8333e14f89bd8175c98db6c60803c7c131448cbc Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Correct handling of functions declared in Q_OBJECTMartin Smith2018-01-121-4/+2
| | | | | | | | | | | | | These functions were being eliminated from the documentation in the clang visitor, but this doesn't when the functions actually have documentation. This update moves the test for whether they should be documented or not to the Generator class. This update also avoids reporting a qdoc warning for a typedef defined in Q_GADGET. Change-Id: Icca7297ec2123c684203d225d2bda96e50dacd8c Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Disable clang errors when the class is internalMartin Smith2018-01-121-4/+20
| | | | | | | | | | | | | | | | | | | | From time to time, we have classes added that are marked both \internal and \preliminary in their \class comment. This was a race condition that set the status of the class documentation to either internal or preliminary depending on the order of the \internal and \preliminary commands. But \preliminary should only be used when the class is meant to be included in the public API marked as preliminary, so users will understand that it might be changed before it is stable. So this update lets \internal win when both commands appear in the \class comment, regardless of their order. This update also prevents clang parsing errors from being reported for \fn commands where the class containing the member function is marked \internal. This eliminates a lot of qdoc warnings. Change-Id: Id1ecec4bdd573ae81fa5d589dfdd4afc4b313825 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Fix processing for \macro and QML method/signal topic commandsTopi Reinio2018-01-051-127/+0
| | | | | | | | | | | | | | | Because processing these commands do not use clang, their implementation is moved from ClangCodeParser to CppCodeParser - this ensures that these topic commands are processed also when they appear in .qdoc files (PureDocParser, used for .qdoc, derives from CppCodeParser). Also, these functions did nothing when qdoc was running in prepare phase which in turn meant that they were not written to .index, thus breaking cross-module linking for macros/QML methods/signals. That check is now removed and the functions always do their thing. Change-Id: I8d9333b02092708955b619b573254eda5d82f038 Reviewed-by: Martin Smith <martin.smith@qt.io>
* qdoc: Handle shared comments betterMartin Smith2017-11-161-113/+10
| | | | | | | | | | | | | | | The shared comment in qdoc was originally meant only for use with the \fn command, and only for multiple \fn commands in the same class. But it proved to be useful for other things, so people started using it in other contexts, even though it didn't work there. This update should handle them all. For example, when listing multiple \fn commands, they no longer need be for functions in the same class. Also, multiple \typedef commands are handled correctly. Change-Id: I4be86026a227d74822f5f2295577adf0fe170d49 Reviewed-by: Martin Smith <martin.smith@qt.io>
* qdoc: Document C++ functions that are invokableMartin Smith2017-11-161-0/+2
| | | | | | | | | | | | This update lets clang report to qdoc whenever Q_INVOKABLE appears in a C++ function declaration so that qdoc can add a note to the function's documentation telling the reader that the function is invokable via the meta-object system and from QML. Task-number: QTBUG-59083 Change-Id: I9b62ba1c9159a1ec43c6a59e576efdb71bff62e5 Reviewed-by: Martin Smith <martin.smith@qt.io>
* qdoc: Fix crash on ClangCodeParser::getMoreArgs()Topi Reinio2017-11-141-3/+4
| | | | | | | | ASSERT failure in QList<T>::at: "index out of range" for documentation modules that do not have any headers. Change-Id: Ia8bc776d9c48c34b962356a65f74b2c7fe1d2d8c Reviewed-by: Martin Smith <martin.smith@qt.io>
* qdoc: Fix compilation warnings on MSVCTopi Reinio2017-10-111-2/+2
| | | | | | | | | | | | | | We pass the size_t of an std::vector to a clang function taking an int as an argument, which on MSVC resulted in warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data To fix this, cast explicitly. Change-Id: I3636f7ced600c387c678aa59012274db490d8f8d Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io> Reviewed-by: Martin Smith <martin.smith@qt.io>
* qdoc: Correct a misuse of a local variableMartin Smith2017-09-181-5/+5
| | | | | | | | | | This update fixes a bug caused by reusing an index varible name declared in an outer loop in an inner loop, which made qdoc crash in one case. Change-Id: I27abb4ea3241be620c8c226732e83ef42b575da9 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
* qdoc: QPrivateSignal was not handled correctlyMartin Smith2017-09-181-3/+2
| | | | | | | | | | | | Now that clang-qdoc uses clang to parse the \fn commands, it must handle the QPrivateSignal flag correctly. It is not allowed in the signature in the \fn command. This update corrects a bug where the expected number or parameters was being reduced by 1 because the flag appeared in the declaration in the include file. Change-Id: I1c974100b2017b3058040937a03500a75dc69d82 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: This ends use of qdoc's old C++ parserMartin Smith2017-09-081-11/+192
| | | | | | | | | | This change replaces the last uses of qdoc's old, ad hoc C++ parser. Clang is now used for parsing all C++ code. \macro, \qmlxxx, and \jsxxx commands are parsed by simple pattern matching functions using QString::split(). Change-Id: If6f95b0487d1dd3206373bc55ec8e6b8b9c55b1e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* qdoc: Use clang to parse \fn commandsMartin Smith2017-09-061-10/+221
| | | | | | | | qdoc now uses clang to parse \fn commands. It even handles the multiple \fn case. Change-Id: I259fcdfc1bf180d32ef1cc9886a48aa3006e18fb Reviewed-by: Martin Smith <martin.smith@qt.io>
* qdoc: Remove uses of QRegular ExpressionMartin Smith2017-09-061-55/+58
| | | | | | | | | | | This change replaces two uses of QRegularExpression with a simple ad hoc parser. qdoc is not allowed to use QRegularExpression because it is not in the bootstrap library. Task-number: QTBUG-62845 Change-Id: Icfaca2181ff1879f02d111626a85fb3da758c731 Reviewed-by: Martin Smith <martin.smith@qt.io>
* Build fixJędrzej Nowacki2017-08-101-2/+2
| | | | | | | clangcodeparser.cpp:1025:39: error: no match for ‘operator+=’ (operand types are ‘QByteArray’ and ‘QChar’). Change-Id: Ibc6fa1f11996e9ab5805b85b3165da3b1d7b2afb Reviewed-by: Martin Smith <martin.smith@qt.io>
* qdoc: Better support for multi-\fn documentation blocksMartin Smith2017-08-101-4/+21
| | | | | | | | | | | | | | | | | This change is a partial fix for the multi-\fn documentation concept. It outputs the documentation once but listing all the function signatures from the \fn commands found in the qdoc comment. Multiple \since commands are not implemented; the \until command is not implemented, and providing text applicable to a specific \fn signature is not implemented. This change requires clang, which means it requires a sequence of other updates as well, so you can't test it unless you have all that stuff. Task-number: QTBUG-60420 Change-Id: Ib316b6f97fa427ef730c4badfc785101bff55dce Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Ignore declarations of anonymous structsMartin Smith2017-08-101-0/+2
| | | | | | | | | | | | | | | qdoc doesn't need to see declarations of anonymous structs. When it does see one inside a class or struct that is named, then the html generator tries to overwrite the html file for the outer class or struct. That causes a few qdoc error messages and it overwrites the html file for the class reference page and the all-members page. This update tells clang not to visit the declaration of the anonymous struct, so the html generator doesn't see it as something to be documented. Change-Id: Ie8c732e650c39f78c1374523d72a7e0448a31ba3 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: create the anonymous enum typeMartin Smith2017-08-101-3/+6
| | | | | | | | | | | | When clangqdoc encounters an unnamed enum type in a class, qdoc reports an error that enum type "global" is not found in any header file, and then the identifiers in the enum type can't be properly documented. This change makes the clang qdoc visitor name the unnamed enum type "anonymous" and allows it to be documented like a named enum type. Change-Id: I8b6dbc9bb78adc5f5c39a2a2d73c27ccb4543ceb Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Add moduleheader as config variableMartin Smith2017-08-101-1/+11
| | | | | | | | | | | | | | | moduleheader is a new config variable you can add to the qdocconf file when the name of the module header file for your module is different from the project name. When the name of the module header file is different from the project name, if you don't tell qdoc what the name of the module header file is by setting moduleheader in the qdocconf file, then clangqdoc will not find the module header file to build the precomiled header with, which will result in clang not finding a lot of stuff. Change-Id: I0da1a0b0be05cb9e6e95e0123583ddeedaf6741d Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Add (qdoc) to qWarning messagesMartin Smith2017-08-101-5/+6
| | | | | | | | These messages don't come from the warning() function in class Location, so each one must have (qdoc) added. Change-Id: Id49b979f8b051d8f4661fb3214989c9c959121c6 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Make qdoc handle ref qualifiers correctlyMartin Smith2017-08-101-0/+5
| | | | | | | | | | | | | | | This update makes qdoc parse and record the presence of ref qualifiers on the end of function declarations. It unfortunately increases the number of qdoc errors reported in QtBase, but that is because these functions are not documented correctly. There will be another update to qdoc to allow documenting multiple functions with a single comment, which is needed for documenting these ref qualified functions but also can be useful in other contexts. Change-Id: If2efb1a71c683a465d66608a20e238d84ea45d9a Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Create and Visit the PCH alwaysMartin Smith2017-08-101-80/+116
| | | | | | | | | | | | | | | | | | | | | | | The PCH for module QtPlatformHeaders was not being built because there are no .cpp files there, and clangqdoc was only building the PCH when it was asked to parse the first .cpp file. Now it builds the PCH by a direct call from the main.cpp file, after the headers have been gathered into a list, but before the .cpp files are parsed. This does reduce the qdoc error count by a few, but it does not fix the documentation for QtPlatformHeaders. From my debugging, it appears that visiting the PCH produces no qdoc nodes for the C++ classes and functions, etc in the PCH. This update also improves the selection of default include paths when inadequate include paths are provided. That is the case for module QtPlatformHeaders, where no include paths are provided. The algorithm for constructing a list of reasonable guesses is modified here. Change-Id: I0dee8dc0279894a4482df30703657558cdb098de Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Enable documentation of type alias as typedefMartin Smith2017-08-101-0/+16
| | | | | | | | | | clangqdoc now handles the type alias declaraction and provides the \typealias command for documenting it. It is documented as a typedef. Task-number: QTBUG-58158 Change-Id: Iee0c8dea66026a89b3625b40b92b056cada893c1 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: fix resolve inheritance bugMartin Smith2017-08-101-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | clangqdoc was unable to find base class nodes, when the base class node was in a different module from the subclass. This was mostly because the fixInheritance() function, which handles base class resolution after the headers have been parsed, was being called before the headers were parsed. This was caused by the new parsing strategy for clangqdoc, which is to use the old loop where qdoc used to parse the header files only to build up a list of all the required header files and to delay parsing the header files until clang is called to build the PCH. The basic fix is to mode the call to resolveInheritance() from main.cpp into clangcodeparser.cpp right after the PCH is built. There are also a few other minor changes in this change that make the base class resolution more robust by ensuring that as much useful information as possible is retained in the index file and in the base class list for a class node. Change-Id: I51433f618cdf40b37b0687ff1686da03359de111 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Match unqualified parameter typesMartin Smith2017-08-101-5/+9
| | | | | | | | | | | clangqdoc was unable to tie qdoc comments to their function declarations for nested classes, when the function had a formal parameter of the nested class type. The problem was that findNodeForCursor() didn't handle the type name scoping correctly. Change-Id: I64d81377193447b1af73ecd107f0431fac0d81a7 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Handle class decls outside the semantic parentMartin Smith2017-08-101-2/+22
| | | | | | | | | | | | | | | | We have the class declaration for QMetaObject::Connection in qobjectdefs.h, which is outside the declaration for QMetaObject. clangqdoc wasn't handling this correctly. It created the class node for Connection with the wrong parent. This update ensures that the class node for Connection is given the class node of QMetaObject as its parent. If the semantic and lexical parent cursors of the current cursor are not the same, find the Aggregate node for the semantic parent cursor and use that node as the parent when the new class node is created. Change-Id: I40f73dad9879e39452f83bb7c0f514a7ef319208 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Parse Friend declarationsOlivier Goffart2017-08-101-0/+11
| | | | | | | (Requires clang 4.0) Change-Id: I50240f0e4b9f538c65dbaa0e8d08469676ac9012 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Identify special constructors and assignment opsMartin Smith2017-08-101-2/+15
| | | | | | | | | | | | This change enables clangqdoc to identify copy constructors, move-copy constructors, copy-assignment operators and move-assignment operators. Identifying these special member functions allows clangqdoc to document them automatically if the documentation is missing, which also means fewer qdoc error reports. Change-Id: Ic50822c2939f0a84e707a1b3ff946bc731a0bd85 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Don't report error for things marked \internalMartin Smith2017-08-101-1/+1
| | | | | | | | | | | | | This change allows qdoc to avoid printing warnings about a qdoc comment, if the comment contains the \internal command. In these cases, the comment will not be used in the documentation, so there is no point reporting warnings about it. However, if the showinternal option is used, warnings about comments marked internal are printed anyway. Change-Id: Idcb329958681523c79e9f6a3a144ae26d44a6906 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Add "clangdefines" to Config classMartin Smith2017-08-101-3/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The qdoc 'defines' config variable lists values that contain '*' to represent wildcards, but clang doesn't accept them. This change adds a new config variable called 'clangdefines' which explicitly lists all the defines that match the wildcards. It also lists several Qt defines for C++11 stuff, because when clangqdoc comes into use, all the supported compilers for Qt will support C++11 constructs. There might be a few defines listed in clangdefines that are unnecessary and maybe a few that we really should not include, but we can adjust the list as needed. Also included in this change: Tell clang never to fail (i.e. keep parsing no matter how many errors are found), and tell clang not to print parsing errors, because they obscure the qdoc errors in the output. clangqdoc should assume that the source files are correct, but some of the include files, especially system level stuff, will not be present. clangqdoc doesn't care about these missing files, because they aren't part of the documentation. Change-Id: I84e1cae24d961a82d16ee705333d6f36955d35de Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* qdoc: Reduce total clang parse timeMartin Smith2017-08-101-4/+54
| | | | | | | | | | | | | | | | | | | | | Including the module's private headers in the PCH database can reduce the qdoc run time for the module by a few minutes. Apparently, including the private headers significantly reduces the number of header files that must be re-parsed. This change adds the module's private headers to the pre-compiled header database. When it finds the module's module header, it copies that module header to the temporary directory where it will construct the PCH. Then it finds the module's private header subdirectory, constructs the path to each header in that directory, and appends it to the temporary module header. Then it passes this augmented module header to clang to construct the PCH. Change-Id: Ie67485c7070ef7487345db90a8b27c64f5caa0f2 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Use clang as a parser in qdocOlivier Goffart2017-08-101-0/+1034
The file qt_find_clang.prf is inspired by qtcreator's clang_installation.pri. The code from the while loop in ClangVisitor::parseProperty contains code moved from CppCodeParser::matchProperty. The code in the for loop of ClangCodeParser::parseSourceFile (from the "Doc parses the comment"), is mostly moved from CppCodeParser::matchDocsAndStuff. In CppCodeParser, most of the code is removed since clang is used for parsing. We just need to leave enough to parse the declaration in the comments which still use the old parser (\fn, ...) Known issues: - When the parameter name is a comment, it is lost. (e.g. QObject::eventFilter(QObject * /* watched */, QEvent * /* event */) - I can't compute default parameters when they are expanded from a macro. (e.g. QObject::tr) - Instances of #ifndef Q_QDOC need to be reviewed Change-Id: I92d4ca4fc52810d9d3de433147a9953eea3a1802 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>