From a714617798efc6e40d28146dc916f12c4c913bc9 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Wed, 4 Sep 2024 12:43:07 -0700 Subject: [PATCH 2/2] Port to work with clang-19 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First two changes are calling getArgument().getAsType() to keep the function parameter types intact Fixes /mnt/b/yoe/master/build/tmp/work/x86_64-linux/qttools-native/6.8.0/git/src/qdoc/qdoc/src/qdoc/clangcodeparser.cpp: In function ‘std::string get_default_value_initializer_as_string(const clang::NonTypeTemplateParmDecl*)’: /mnt/b/yoe/master/build/tmp/work/x86_64-linux/qttools-native/6.8.0/git/src/qdoc/qdoc/src/qdoc/clangcodeparser.cpp:228:63: error: cannot convert ‘const clang::TemplateArgumentLoc’ to ‘const clang::Expr*’ 228 | get_expression_as_string(parameter->getDefaultArgument(), parameter->getASTContext()) : ""; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~ | | | const clang::TemplateArgumentLoc /mnt/b/yoe/master/build/tmp/work/x86_64-linux/qttools-native/6.8.0/git/src/qdoc/qdoc/src/qdoc/clangcodeparser.cpp:186:64: note: initializing argument 1 of ‘std::string get_expression_as_string(const clang::Expr*, const clang::ASTContext&)’ 186 | static std::string get_expression_as_string(const clang::Expr* expression, const clang::ASTContext& declaration_context) { | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~ /mnt/b/yoe/master/build/tmp/work/x86_64-linux/qttools-native/6.8.0/git/src/qdoc/qdoc/src/qdoc/clangcodeparser.cpp: In function ‘std::string get_default_value_initializer_as_string(const clang::TemplateTemplateParmDecl*)’: /mnt/b/yoe/master/build/tmp/work/x86_64-linux/qttools-native/6.8.0/git/src/qdoc/qdoc/src/qdoc/clangcodeparser.cpp:248:113: error: ‘Fully’ is not a member of ‘clang::TemplateName::Qualified’ 248 | template_name.print(ss, parameter->getASTContext().getPrintingPolicy(), clang::TemplateName::Qualified::Fully); | ^~~~~ Third change is because Fully is dropped in latest clang see [1] Reported: https://bugreports.qt.io/browse/QTBUG-128644 [1] https://github.com/llvm/llvm-project/commit/9c4a716c12920 Upstream-Status: Pending Signed-off-by: Khem Raj --- src/qdoc/qdoc/src/qdoc/clangcodeparser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qdoc/qdoc/src/qdoc/clangcodeparser.cpp b/src/qdoc/qdoc/src/qdoc/clangcodeparser.cpp index bc96cf8cd..ec64c069c 100644 --- a/src/qdoc/qdoc/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/qdoc/src/qdoc/clangcodeparser.cpp @@ -209,7 +209,7 @@ static std::string get_expression_as_string(const clang::Expr* expression, const */ static std::string get_default_value_initializer_as_string(const clang::TemplateTypeParmDecl* parameter) { return (parameter && parameter->hasDefaultArgument()) ? - get_fully_qualified_type_name(parameter->getDefaultArgument(), parameter->getASTContext()) : + get_fully_qualified_type_name(parameter->getDefaultArgument().getArgument().getAsType(), parameter->getASTContext()) : ""; } @@ -225,7 +225,7 @@ static std::string get_default_value_initializer_as_string(const clang::Template */ static std::string get_default_value_initializer_as_string(const clang::NonTypeTemplateParmDecl* parameter) { return (parameter && parameter->hasDefaultArgument()) ? - get_expression_as_string(parameter->getDefaultArgument(), parameter->getASTContext()) : ""; + get_expression_as_string(parameter->getDefaultArgument().getArgument().getAsExpr(), parameter->getASTContext()) : ""; } @@ -245,7 +245,7 @@ static std::string get_default_value_initializer_as_string(const clang::Template const clang::TemplateName template_name = parameter->getDefaultArgument().getArgument().getAsTemplate(); llvm::raw_string_ostream ss{default_value}; - template_name.print(ss, parameter->getASTContext().getPrintingPolicy(), clang::TemplateName::Qualified::Fully); + template_name.print(ss, parameter->getASTContext().getPrintingPolicy(), clang::TemplateName::Qualified::AsWritten); } return default_value;