llvm15.patch 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. diff -Nuar a/src/linguist/lupdate/cpp_clang.cpp b/src/linguist/lupdate/cpp_clang.cpp
  2. --- a/src/linguist/lupdate/cpp_clang.cpp 2022-09-23 14:50:40.000000000 +0300
  3. +++ b/src/linguist/lupdate/cpp_clang.cpp 2023-01-19 11:46:35.771012198 +0300
  4. @@ -243,40 +243,37 @@
  5. static clang::tooling::ArgumentsAdjuster getClangArgumentAdjuster()
  6. {
  7. const QByteArrayList compilerIncludeFlags = getIncludePathsFromCompiler();
  8. - return [=](const clang::tooling::CommandLineArguments &args,
  9. - llvm::StringRef /*unused*/) {
  10. - clang::tooling::CommandLineArguments adjustedArgs;
  11. - for (size_t i = 0, e = args.size(); i < e; ++i) {
  12. - llvm::StringRef arg = args[i];
  13. - // FIXME: Remove options that generate output.
  14. - if (!arg.startswith("-fcolor-diagnostics") && !arg.startswith("-fdiagnostics-color"))
  15. - adjustedArgs.push_back(args[i]);
  16. - }
  17. - adjustedArgs.push_back("-fparse-all-comments");
  18. - adjustedArgs.push_back("-nostdinc");
  19. + return [=](const clang::tooling::CommandLineArguments &args, llvm::StringRef /*unused*/) {
  20. + clang::tooling::CommandLineArguments adjustedArgs(args);
  21. + clang::tooling::CommandLineArguments adjustedArgsTemp;
  22. +
  23. + adjustedArgsTemp.push_back("-fparse-all-comments");
  24. + adjustedArgsTemp.push_back("-nostdinc");
  25. // Turn off SSE support to avoid usage of gcc builtins.
  26. // TODO: Look into what Qt Creator does.
  27. // Pointers: HeaderPathFilter::removeGccInternalIncludePaths()
  28. // and gccInstallDir() in gcctoolchain.cpp
  29. // Also needed for Mac, No need for CLANG_RESOURCE_DIR when this is part of the argument.
  30. - adjustedArgs.push_back("-mno-sse");
  31. + adjustedArgsTemp.push_back("-mno-sse");
  32. - adjustedArgs.push_back("-fsyntax-only");
  33. #ifdef Q_OS_WIN
  34. - adjustedArgs.push_back("-fms-compatibility-version=19");
  35. - adjustedArgs.push_back("-DQ_COMPILER_UNIFORM_INIT"); // qtbase + clang-cl hack
  36. + adjustedArgsTemp.push_back("-fms-compatibility-version=19");
  37. + adjustedArgsTemp.push_back("-DQ_COMPILER_UNIFORM_INIT"); // qtbase + clang-cl hack
  38. // avoid constexpr error connected with offsetof (QTBUG-97380)
  39. - adjustedArgs.push_back("-D_CRT_USE_BUILTIN_OFFSETOF");
  40. + adjustedArgsTemp.push_back("-D_CRT_USE_BUILTIN_OFFSETOF");
  41. #endif
  42. - adjustedArgs.push_back("-Wno-everything");
  43. + adjustedArgsTemp.push_back("-Wno-everything");
  44. for (const QByteArray &flag : compilerIncludeFlags)
  45. - adjustedArgs.push_back(flag.data());
  46. + adjustedArgsTemp.push_back(flag.data());
  47. for (auto alias : aliasDefinition) {
  48. - adjustedArgs.push_back(alias);
  49. + adjustedArgsTemp.push_back(alias);
  50. }
  51. +
  52. + clang::tooling::CommandLineArguments::iterator it = llvm::find(adjustedArgs, "--");
  53. + adjustedArgs.insert(it, adjustedArgsTemp.begin(), adjustedArgsTemp.end());
  54. return adjustedArgs;
  55. };
  56. }
  57. @@ -461,7 +458,11 @@
  58. ReadSynchronizedRef<std::string> ppSources(sources);
  59. WriteSynchronizedRef<TranslationRelatedStore> ppStore(stores.Preprocessor);
  60. size_t idealProducerCount = std::min(ppSources.size(), size_t(std::thread::hardware_concurrency()));
  61. - clang::tooling::ArgumentsAdjuster argumentsAdjuster = getClangArgumentAdjuster();
  62. + clang::tooling::ArgumentsAdjuster argumentsAdjusterSyntaxOnly =
  63. + clang::tooling::getClangSyntaxOnlyAdjuster();
  64. + clang::tooling::ArgumentsAdjuster argumentsAdjusterLocal = getClangArgumentAdjuster();
  65. + clang::tooling::ArgumentsAdjuster argumentsAdjuster =
  66. + clang::tooling::combineAdjusters(argumentsAdjusterLocal, argumentsAdjusterSyntaxOnly);
  67. for (size_t i = 0; i < idealProducerCount; ++i) {
  68. std::thread producer([&ppSources, &db, &ppStore, &argumentsAdjuster]() {
  69. diff -Nuar a/src/linguist/lupdate/lupdatepreprocessoraction.cpp b/src/linguist/lupdate/lupdatepreprocessoraction.cpp
  70. --- a/src/linguist/lupdate/lupdatepreprocessoraction.cpp 2022-09-23 14:50:40.000000000 +0300
  71. +++ b/src/linguist/lupdate/lupdatepreprocessoraction.cpp 2023-01-19 12:01:15.475030465 +0300
  72. @@ -144,7 +144,7 @@
  73. const char *end = sm.getCharacterData(sourceRange.getEnd());
  74. llvm::StringRef skippedText = llvm::StringRef(begin, end - begin);
  75. if (ClangCppParser::stringContainsTranslationInformation(skippedText)) {
  76. - qCDebug(lcClang) << "SourceRangeSkipped: skipped text:" << skippedText.str();
  77. + qCDebug(lcClang) << "SourceRangeSkipped: skipped text:" << QString::fromStdString(skippedText.str());
  78. unsigned int beginLine = sm.getExpansionLineNumber(sourceRange.getBegin());
  79. unsigned int endLine = sm.getExpansionLineNumber(sourceRange.getEnd());
  80. qWarning("%s Code with translation information has been skipped "
  81. @@ -156,14 +156,23 @@
  82. // To list the included files
  83. void LupdatePPCallbacks::InclusionDirective(clang::SourceLocation /*hashLoc*/,
  84. const clang::Token & /*includeTok*/, clang::StringRef /*fileName*/, bool /*isAngled*/,
  85. - clang::CharSourceRange /*filenameRange*/, const clang::FileEntry *file,
  86. + clang::CharSourceRange /*filenameRange*/,
  87. +#if (LUPDATE_CLANG_VERSION >= LUPDATE_CLANG_VERSION_CHECK(15,0,0))
  88. + const clang::Optional<clang::FileEntryRef> file,
  89. +#else
  90. + const clang::FileEntry *file,
  91. +#endif
  92. clang::StringRef /*searchPath*/, clang::StringRef /*relativePath*/,
  93. const clang::Module */*imported*/, clang::SrcMgr::CharacteristicKind /*fileType*/)
  94. {
  95. if (!file)
  96. return;
  97. - clang::StringRef fileNameRealPath = file->tryGetRealPathName();
  98. + clang::StringRef fileNameRealPath = file->
  99. +#if (LUPDATE_CLANG_VERSION >= LUPDATE_CLANG_VERSION_CHECK(15,0,0))
  100. + getFileEntry().
  101. +#endif
  102. + tryGetRealPathName();
  103. if (!LupdatePrivate::isFileSignificant(fileNameRealPath.str()))
  104. return;
  105. diff -Nuar a/src/linguist/lupdate/lupdatepreprocessoraction.h b/src/linguist/lupdate/lupdatepreprocessoraction.h
  106. --- a/src/linguist/lupdate/lupdatepreprocessoraction.h 2022-09-23 14:50:40.000000000 +0300
  107. +++ b/src/linguist/lupdate/lupdatepreprocessoraction.h 2023-01-19 12:01:57.650503199 +0300
  108. @@ -51,7 +51,12 @@
  109. void SourceRangeSkipped(clang::SourceRange sourceRange, clang::SourceLocation endifLoc) override;
  110. void InclusionDirective(clang::SourceLocation /*hashLoc*/, const clang::Token &/*includeTok*/,
  111. clang::StringRef /*fileName*/, bool /*isAngled*/,
  112. - clang::CharSourceRange /*filenameRange*/, const clang::FileEntry *file,
  113. + clang::CharSourceRange /*filenameRange*/,
  114. +#if (LUPDATE_CLANG_VERSION >= LUPDATE_CLANG_VERSION_CHECK(15,0,0))
  115. + const clang::Optional<clang::FileEntryRef> file,
  116. +#else
  117. + const clang::FileEntry *file,
  118. +#endif
  119. clang::StringRef /*searchPath*/, clang::StringRef /*relativePath*/,
  120. const clang::Module */*imported*/,
  121. clang::SrcMgr::CharacteristicKind /*fileType*/) override;