![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
#include "clangcodeparser.h"#include "cppcodeparser.h"#include "access.h"#include "classnode.h"#include "config.h"#include "doc.h"#include "enumnode.h"#include "functionnode.h"#include "genustypes.h"#include "inclusionpolicy.h"#include "namespacenode.h"#include "propertynode.h"#include "qdocdatabase.h"#include "typedefnode.h"#include "variablenode.h"#include "sourcefileparser.h"#include "utilities.h"#include <QtCore/qdebug.h>#include <QtCore/qdir.h>#include <QtCore/qelapsedtimer.h>#include <QtCore/qfile.h>#include <QtCore/qregularexpression.h>#include <QtCore/qscopedvaluerollback.h>#include <QtCore/qtemporarydir.h>#include <QtCore/qtextstream.h>#include <QtCore/qvarlengtharray.h>#include <clang-c/Index.h>#include <clang/AST/Decl.h>#include <clang/AST/DeclFriend.h>#include <clang/AST/DeclTemplate.h>#include <clang/AST/Expr.h>#include <clang/AST/Type.h>#include <clang/AST/TypeLoc.h>#include <clang/Basic/SourceLocation.h>#include <clang/Frontend/ASTUnit.h>#include <clang/Lex/Lexer.h>#include <llvm/Support/Casting.h>#include "clang/AST/QualTypeNames.h"#include "template_declaration.h"#include <algorithm>#include <cstdio>#include <optional>#include <string_view>Go to the source code of this file.
Classes | |
| struct | CompilationIndex |
| struct | TranslationUnit |
| struct | FileCacheEntry |
| Returns the spelling in the file for a source range. More... | |
| class | ClangVisitor |
Functions | |
| template<class T> | |
| static QDebug | operator<< (QDebug debug, const std::vector< T > &v) |
| static void | printDiagnostics (const CXTranslationUnit &translationUnit) |
| static const clang::Decl * | get_cursor_declaration (CXCursor cursor) |
| Returns the underlying Decl that cursor represents. | |
| static std::string | ensureAnonymousTagKeyword (std::string typeName, clang::QualType type) |
| Returns a string representing the name of type as if it was referred to at the end of the translation unit that it was parsed from. | |
| static std::string | get_fully_qualified_type_name (clang::QualType type, const clang::ASTContext &declaration_context) |
| static QString | cleanAnonymousTypeName (const QString &typeName) |
| static std::string | get_expression_as_string (const clang::Expr *expression, const clang::ASTContext &declaration_context) |
| static std::string | get_default_value_initializer_as_string (const clang::TemplateTypeParmDecl *parameter) |
| static std::string | get_default_value_initializer_as_string (const clang::NonTypeTemplateParmDecl *parameter) |
| static std::string | get_default_value_initializer_as_string (const clang::TemplateTemplateParmDecl *parameter) |
| static std::string | get_default_value_initializer_as_string (const clang::ParmVarDecl *parameter) |
| static std::string | get_default_value_initializer_as_string (const clang::NamedDecl *declaration) |
| template<typename T> | |
| bool | visitChildrenLambda (CXCursor cursor, T &&lambda) |
| Call clang_visitChildren on the given cursor with the lambda as a callback T can be any functor that is callable with a CXCursor parameter and returns a CXChildVisitResult (in other word compatible with function<CXChildVisitResult(CXCursor)>. | |
| static QString | fromCXString (CXString &&string) |
| convert a CXString to a QString, and dispose the CXString | |
| static const clang::TemplateSpecializationType * | find_template_specialization_through_sugar (const clang::Type *type) |
| static bool | is_enable_if_name (const std::string &qualified_name) |
| static std::optional< SfinaeConstraint > | detect_sfinae_constraint (const clang::NonTypeTemplateParmDecl *param) |
| static RelaxedTemplateDeclaration | get_template_declaration (const clang::TemplateDecl *template_declaration) |
| static Location | fromCXSourceLocation (CXSourceLocation location) |
| convert a CXSourceLocation to a qdoc Location | |
| static Access | fromCX_CXXAccessSpecifier (CX_CXXAccessSpecifier spec) |
| convert a CX_CXXAccessSpecifier to Node::Access | |
| static QString | fromCache (const QByteArray &cache, unsigned int offset1, unsigned int offset2) |
| static QString | readFile (CXFile cxFile, unsigned int offset1, unsigned int offset2) |
| static QString | getSpelling (CXSourceRange range) |
| QString | functionName (CXCursor cursor) |
| Returns the function name from a given cursor representing a function declaration. | |
| static QString | reconstructQualifiedPathForCursor (CXCursor cur) |
| Reconstruct the qualified path name of a function that is being overridden. | |
| static std::optional< QString > | classNameFromParameterType (clang::QualType param_type) |
| static Node * | findNodeForCursor (QDocDatabase *qdb, CXCursor cur) |
| Find the node from the QDocDatabase qdb that corresponds to the declaration represented by the cursor cur, if it exists. | |
| static void | setOverridesForFunction (FunctionNode *fn, CXCursor cursor) |
| static void | autoGenerateSmfDoc (FunctionNode *fn, const QString &className) |
| void | getDefaultArgs (const QList< QByteArray > &defines, std::vector< const char * > &args) |
| Load the default arguments and the defines into args. | |
| static QList< QByteArray > | includePathsFromHeaders (const std::set< Config::HeaderFilePath > &allHeaders) |
| void | getMoreArgs (const std::vector< QByteArray > &include_paths, const std::set< Config::HeaderFilePath > &all_headers, std::vector< const char * > &args) |
| Load the include paths into moreArgs. | |
| std::optional< PCHFile > | buildPCH (QDocDatabase *qdb, QString module_header, const std::set< Config::HeaderFilePath > &all_headers, const std::vector< QByteArray > &include_paths, const QList< QByteArray > &defines, const InclusionPolicy &policy) |
| Building the PCH must be possible when there are no .cpp files, so it is moved here to its own member function, and it is called after the list of header files is complete. | |
| static float | getUnpatchedVersion (QString t) |
Variables | |
| static const auto | kClangDontDisplayDiagnostics = 0 |
| static CXTranslationUnit_Flags | flags_ = static_cast<CXTranslationUnit_Flags>(0) |
| constexpr const char | fnDummyFileName [] = "/fn_dummyfile.cpp" |
| static const char * | defaultArgs_ [] |
|
static |
Auto-generates documentation for explicitly defaulted or deleted special member functions that don't already have documentation.
Definition at line 1130 of file clangcodeparser.cpp.
References Node< _Tp >::hasDoc(), FunctionNode::isCAssign(), FunctionNode::isCCtor(), FunctionNode::isCtor(), FunctionNode::isDeletedAsWritten(), FunctionNode::isDtor(), FunctionNode::isExplicitlyDefaulted(), FunctionNode::isMAssign(), FunctionNode::isMCtor(), FunctionNode::isSpecialMemberFunction(), Node< _Tp >::location(), Doc::markAutoGenerated(), FunctionNode::parameters(), and Node< _Tp >::setDoc().
| std::optional< PCHFile > buildPCH | ( | QDocDatabase * | qdb, |
| QString | module_header, | ||
| const std::set< Config::HeaderFilePath > & | all_headers, | ||
| const std::vector< QByteArray > & | include_paths, | ||
| const QList< QByteArray > & | defines, | ||
| const InclusionPolicy & | policy ) |
Building the PCH must be possible when there are no .cpp files, so it is moved here to its own member function, and it is called after the list of header files is complete.
Definition at line 2113 of file clangcodeparser.cpp.
References flags_, kClangDontDisplayDiagnostics, printDiagnostics(), TranslationUnit::tu, and ClangVisitor::visitChildren().
|
static |
Extract a class name from a Clang parameter type, stripping references, pointers, and qualifiers. Returns {std::nullopt} if the type doesn't represent a class.
Definition at line 860 of file clangcodeparser.cpp.
Definition at line 270 of file clangcodeparser.cpp.
|
static |
Definition at line 516 of file clangcodeparser.cpp.
References find_template_specialization_through_sugar().
|
static |
Returns a string representing the name of type as if it was referred to at the end of the translation unit that it was parsed from.
For example, given the following code:
Given a parsed translation unit and an AST node, say {decl}, representing the parameter declaration of the first argument of {bam}, calling {get_fully_qualified_name(decl->getType(), * decl->getASTContext())} would result in the string {foo::Bar<T>::Baz}.
This should generally be used every time the stringified representation of a type is acquired as part of parsing with Clang, so as to ensure a consistent behavior and output.
Definition at line 199 of file clangcodeparser.cpp.
|
static |
Definition at line 453 of file clangcodeparser.cpp.
Referenced by detect_sfinae_constraint().
|
static |
Find the node from the QDocDatabase qdb that corresponds to the declaration represented by the cursor cur, if it exists.
Definition at line 897 of file clangcodeparser.cpp.
References findNodeForCursor(), fromCXSourceLocation(), get_cursor_declaration(), Node< _Tp >::isAggregate(), Node< _Tp >::isClassNode(), Node< _Tp >::isFunction(), Node< _Tp >::isNamespace(), Node< _Tp >::isTypedef(), Node< _Tp >::isVariable(), and QDocDatabase::primaryTreeRoot().
Referenced by findNodeForCursor().
|
inlinestatic |
Definition at line 743 of file clangcodeparser.cpp.
|
static |
convert a CX_CXXAccessSpecifier to Node::Access
Definition at line 719 of file clangcodeparser.cpp.
|
static |
convert a CXSourceLocation to a qdoc Location
Definition at line 705 of file clangcodeparser.cpp.
References Location::setColumnNo(), and Location::setLineNo().
Referenced by findNodeForCursor(), and ClangCodeParser::parse_cpp_file().
|
static |
convert a CXString to a QString, and dispose the CXString
Definition at line 438 of file clangcodeparser.cpp.
| QString functionName | ( | CXCursor | cursor | ) |
Returns the function name from a given cursor representing a function declaration.
This is usually clang_getCursorSpelling, but not for the conversion function in which case it is a bit more complicated
Definition at line 794 of file clangcodeparser.cpp.
|
static |
Returns the underlying Decl that cursor represents.
This can be used to drop back down from a LibClang's CXCursor to the underlying C++ AST that Clang provides.
It should be used when LibClang does not expose certain functionalities that are available in the C++ AST.
The CXCursor should represent a declaration. Usages of this function on CXCursors that do not represent a declaration may produce undefined results.
Definition at line 144 of file clangcodeparser.cpp.
Referenced by findNodeForCursor().
|
static |
Definition at line 400 of file clangcodeparser.cpp.
|
static |
Definition at line 338 of file clangcodeparser.cpp.
|
static |
Definition at line 382 of file clangcodeparser.cpp.
|
static |
Definition at line 358 of file clangcodeparser.cpp.
|
static |
Definition at line 316 of file clangcodeparser.cpp.
|
static |
Definition at line 292 of file clangcodeparser.cpp.
|
static |
Definition at line 253 of file clangcodeparser.cpp.
References clang::TypeName::getFullyQualifiedName().
|
static |
Definition at line 593 of file clangcodeparser.cpp.
| void getDefaultArgs | ( | const QList< QByteArray > & | defines, |
| std::vector< const char * > & | args ) |
Load the default arguments and the defines into args.
Clear args first.
Definition at line 2059 of file clangcodeparser.cpp.
References defaultArgs_.
| void getMoreArgs | ( | const std::vector< QByteArray > & | include_paths, |
| const std::set< Config::HeaderFilePath > & | all_headers, | ||
| std::vector< const char * > & | args ) |
Load the include paths into moreArgs.
If no include paths were provided, try to guess reasonable include paths.
Definition at line 2085 of file clangcodeparser.cpp.
|
static |
Definition at line 774 of file clangcodeparser.cpp.
|
static |
Definition at line 2254 of file clangcodeparser.cpp.
|
static |
Definition at line 2069 of file clangcodeparser.cpp.
|
static |
Definition at line 481 of file clangcodeparser.cpp.
|
static |
Definition at line 96 of file clangcodeparser.cpp.
|
static |
Definition at line 113 of file clangcodeparser.cpp.
Referenced by buildPCH(), FnCommandParser::operator()(), and ClangCodeParser::parse_cpp_file().
|
static |
Definition at line 749 of file clangcodeparser.cpp.
|
static |
Reconstruct the qualified path name of a function that is being overridden.
Definition at line 822 of file clangcodeparser.cpp.
|
static |
Definition at line 1109 of file clangcodeparser.cpp.
References FunctionNode::setOverride().
| bool visitChildrenLambda | ( | CXCursor | cursor, |
| T && | lambda ) |
Call clang_visitChildren on the given cursor with the lambda as a callback T can be any functor that is callable with a CXCursor parameter and returns a CXChildVisitResult (in other word compatible with function<CXChildVisitResult(CXCursor)>.
Definition at line 426 of file clangcodeparser.cpp.
|
static |
Definition at line 2033 of file clangcodeparser.cpp.
Referenced by getDefaultArgs().
|
static |
Definition at line 90 of file clangcodeparser.cpp.
Referenced by buildPCH(), and ClangCodeParser::parse_cpp_file().
|
constexpr |
Definition at line 92 of file clangcodeparser.cpp.
Referenced by FnCommandParser::operator()().
|
static |
Definition at line 88 of file clangcodeparser.cpp.
Referenced by buildPCH(), FnCommandParser::operator()(), and ClangCodeParser::parse_cpp_file().