summaryrefslogtreecommitdiff
path: root/src/qdoc/clangcodeparser.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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>