llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Corentin Kerisit (cerisier) <details> <summary>Changes</summary> Libclang's spelling and editor-placeholder defaults currently trigger unknown-argument warnings in clang-cl mode. This becomes errors under `/WX`. Forward them through `/clang:` so valid inputs parse without these diagnostics. @<!-- -->codex assisted . Human driven and reviewed. --- Full diff: https://github.com/llvm/llvm-project/pull/237563.diff 2 Files Affected: - (modified) clang/test/Index/allow-editor-placeholders.cpp (+1) - (modified) clang/tools/libclang/CIndex.cpp (+8-2) ``````````diff diff --git a/clang/test/Index/allow-editor-placeholders.cpp b/clang/test/Index/allow-editor-placeholders.cpp index 2870777d935c7c..f3cd63696bac13 100644 --- a/clang/test/Index/allow-editor-placeholders.cpp +++ b/clang/test/Index/allow-editor-placeholders.cpp @@ -1,4 +1,5 @@ // RUN: c-index-test -test-load-source all %s 2>&1 | FileCheck %s +// RUN: c-index-test -test-load-source all --driver-mode=cl --target=x86_64-pc-windows-msvc /WX %s 2>&1 | FileCheck %s <#placeholder#>; diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index 8d246d41f31f66..cf8c24aaece327 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -39,6 +39,7 @@ #include "clang/Basic/TargetInfo.h" #include "clang/Basic/Version.h" #include "clang/Driver/CreateASTUnitFromArgs.h" +#include "clang/Driver/Driver.h" #include "clang/Frontend/ASTUnit.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Index/CommentToXML.h" @@ -4402,8 +4403,12 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename, Args->insert(Args->end(), command_line_args, command_line_args + num_command_line_args); + // Use the driver pass-through spelling for options not accepted by clang-cl. + bool IsCLMode = driver::IsClangCL( + driver::getDriverMode((*Args)[0], llvm::ArrayRef(*Args).slice(1))); if (!FoundSpellCheckingArgument) - Args->insert(Args->begin() + 1, "-fno-spell-checking"); + Args->insert(Args->begin() + 1, IsCLMode ? "/clang:-fno-spell-checking" + : "-fno-spell-checking"); // The 'source_filename' argument is optional. If the caller does not // specify it then it is assumed that the source file is specified @@ -4420,7 +4425,8 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename, } // Suppress any editor placeholder diagnostics. - Args->push_back("-fallow-editor-placeholders"); + Args->push_back(IsCLMode ? "/clang:-fallow-editor-placeholders" + : "-fallow-editor-placeholders"); unsigned NumErrors = Diags->getClient()->getNumErrors(); std::unique_ptr<ASTUnit> ErrUnit; `````````` </details> https://github.com/llvm/llvm-project/pull/237563 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
