diff options
author | Martin Smith <martin.smith@qt.io> | 2017-03-15 13:21:08 +0100 |
---|---|---|
committer | Martin Smith <martin.smith@qt.io> | 2017-08-10 07:34:59 +0000 |
commit | 853b1989f671061e1354233d78aae091fc2bfb6c (patch) | |
tree | 123df06d1d244ba47171271ba6a416afba81406e /src/qdoc/clangcodeparser.cpp | |
parent | 2b3798ecd21ad938f6a22a9a1adc51a988a6a87a (diff) | |
download | qttools-853b1989f671061e1354233d78aae091fc2bfb6c.tar.gz |
qdoc: create the anonymous enum type
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>
Diffstat (limited to 'src/qdoc/clangcodeparser.cpp')
-rw-r--r-- | src/qdoc/clangcodeparser.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp index 142b495be..6d55a1a13 100644 --- a/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/clangcodeparser.cpp @@ -552,10 +552,12 @@ CXChildVisitResult ClangVisitor::visitHeader(CXCursor cursor, CXSourceLocation l } #endif case CXCursor_EnumDecl: { - QString t = fromCXString(clang_getCursorSpelling(cursor)); - if (findNodeForCursor(qdb_, cursor)) // Was already parsed, propably in another translation unit + if (findNodeForCursor(qdb_, cursor)) // Was already parsed, propably in another tu return CXChildVisit_Continue; - auto en = new EnumNode(parent_, fromCXString(clang_getCursorSpelling(cursor))); + QString enumTypeName = fromCXString(clang_getCursorSpelling(cursor)); + if (enumTypeName.isEmpty()) + enumTypeName = "anonymous"; + auto en = new EnumNode(parent_, enumTypeName); en->setAccess(fromCX_CXXAccessSpecifier(clang_getCXXAccessSpecifier(cursor))); en->setLocation(fromCXSourceLocation(clang_getCursorLocation(cursor))); // Enum values @@ -1081,6 +1083,7 @@ void ClangCodeParser::precompileHeaders() */ void ClangCodeParser::parseSourceFile(const Location& /*location*/, const QString& filePath) { + currentFile_ = filePath; flags_ = (CXTranslationUnit_Flags) (CXTranslationUnit_Incomplete | CXTranslationUnit_SkipFunctionBodies | CXTranslationUnit_KeepGoing); index_ = clang_createIndex(1, 0); |