Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-130789

clangtoolastreader.cpp and clangcodeparser.cpp don't compile with Clang 19

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 6.7.3
    • None

    Description

      Clang 19 changed its AST API. The following places don't compile anymore.

      clangcodeparser.cpp

      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()) :
                      "";
      
      }
      

      There, getDefaultArgument doesn't return QualType anymore. The fragment has to be changed to

      static std::string get_default_value_initializer_as_string(const clang::TemplateTypeParmDecl* parameter) {
          return (parameter && parameter->hasDefaultArgument()) ?
                      get_fully_qualified_type_name(parameter->getDefaultArgument().getArgument().getAsType(), parameter->getASTContext()) :
                      "";
      
      }
      

      Next fragment:

      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()) : "";
      
      }
      

      My understanding is that it has to be changed to:

      static std::string get_default_value_initializer_as_string(const clang::NonTypeTemplateParmDecl* parameter) {
          return (parameter && parameter->hasDefaultArgument()) ?
              get_expression_as_string(parameter->getDefaultArgument().getArgument().getAsExpr(), parameter->getASTContext()) : "";
      
      }
      

      Next fragment:

      static std::string get_default_value_initializer_as_string(const clang::TemplateTemplateParmDecl* parameter) {
          std::string default_value{};
      
          if (parameter && parameter->hasDefaultArgument()) {
              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);
          }
      
          return default_value;
      }
      

      clang::TemplateName::Qualified enumeration doesn't have Fully anymore. I am not sure about a fix.

      clangtoolastreader.cpp

      Here

      bool LupdateVisitor::VisitNamedDecl(clang::NamedDecl *namedDeclaration)
      {
          if (!m_macro)
              return true;
          auto fullLocation = m_context->getFullLoc(namedDeclaration->getBeginLoc());
          if (!fullLocation.isValid() || !fullLocation.getFileEntry())
              return true;
      
          if (!LupdatePrivate::isFileSignificant(fullLocation.getFileEntry()->getName().str()))
              return true;
      
          qCDebug(lcClang) << "NamedDecl Name:   " << QString::fromStdString(namedDeclaration->getQualifiedNameAsString());
          qCDebug(lcClang) << "NamedDecl source: " << QString::fromStdString(namedDeclaration->getSourceRange().printToString(
              m_context->getSourceManager()));
          // Checks if there is a macro located within the range of this NamedDeclaration
          // in order to find a context for the macro
          findContextForTranslationStoresFromPP(namedDeclaration);
          return true;
      }
      

      FileEntry doesn't have getName anymore. I am not sure about a fix,

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              docinfrastructure Documentation Infrastructure Team
              dreghor Pavel Baxtin
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes