<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/91690>91690</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Using Clang-Tidy breaks build with C++ 20 modules.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          AdityaShantanu
      </td>
    </tr>
</table>

<pre>
    **Repro:**

I have 3 files.
- cmakeCppModules.cpp
- Printers.ixx
- CMakeLists.txt

Adding this line:
```
set(CMAKE_CXX_CLANG_TIDY
clang-tidy;
-checks=cppcoreguidelines-avoid-goto; # adjust to suit your needs
-warnings-as-errors=*; # treat all warnings as errors
)
```
into CMakeList.txt breaks the build.  **Remove it and it builds fine.**

Error:
```
C:\repos\eng-exp-foundation\src\experimental\cmakeCppModules\build>cmake --build .
[0/1] Re-running CMake...-- Configuring done (0.1s)
-- Generating done (0.0s)
-- Build files have been written to: C:/repos/eng-exp-foundation/src/experimental/cmakeCppModules/build

[3/7] Building CXX object CMakeFiles\modules_lib.dir\Printers.ixx.obj
FAILED: CMakeFiles/modules_lib.dir/Printers.ixx.obj CMakeFiles/modules_lib.dir/Printers.ifc
"C:\Program Files\CMake\bin\cmake.exe" -E __run_co_compile --tidy=clang-tidy;-checks=cppcoreguidelines-avoid-goto;-warnings-as-errors=*;--extra-arg-before=--driver-mode=cl --source=C:\repos\eng-exp-foundation\src\experimental\cmakeCppModules\Printers.ixx -- C:\PROGRA~1\MIB055~1\2022\ENTERP~1\VC\Tools\MSVC\1439~1.335\bin\Hostx64\x64\cl.exe /nologo /TP   /DWIN32 /D_WINDOWS /EHsc /Zi /Ob0 /Od /RTC1 -std:c++latest -MDd -Zi /showIncludes @CMakeFiles\modules_lib.dir\Printers.ixx.obj.modmap /FoCMakeFiles\modules_lib.dir\Printers.ixx.obj /FdCMakeFiles\modules_lib.dir\modules_lib.pdb /FS -c C:\repos\eng-exp-foundation\src\experimental\cmakeCppModules\Printers.ixx
error: unable to handle compilation, expected exactly one compiler job in '' [clang-diagnostic-error]
error: C:\repos\eng-exp-foundation\src\experimental\cmakeCppModules\Printers.ixx: 'linker' input unused [clang-diagnostic-unused-command-line-argument,-warnings-as-errors]
error: argument unused during compilation: '-MDd' [clang-diagnostic-unused-command-line-argument,-warnings-as-errors]
error: argument unused during compilation: '-Zi' [clang-diagnostic-unused-command-line-argument,-warnings-as-errors]
error: argument unused during compilation: '-c' [clang-diagnostic-unused-command-line-argument,-warnings-as-errors]
error: argument unused during compilation: '-std:c++latest' [clang-diagnostic-unused-command-line-argument,-warnings-as-errors]
Error while processing C:\repos\eng-exp-foundation\src\experimental\cmakeCppModules\Printers.ixx.
5 warnings treated as errors
ninja: build stopped: subcommand failed.
```


Files:
```
# CMakeList.txt : CMake project for cmakeCppModules, include source and define
# project specific logic here.
#
# set(CMAKE_CXX_COMPILER clang++)

cmake_minimum_required (VERSION 3.28)

project (cmakeCppModules CXX)

set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 23)

set(CMAKE_CXX_CLANG_TIDY
clang-tidy;
-checks=cppcoreguidelines-avoid-goto; # adjust to suit your needs
-warnings-as-errors=*; # treat all warnings as errors
)

add_library(modules_lib)
target_sources(modules_lib PUBLIC FILE_SET CXX_MODULES FILES Printers.ixx)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()

if(CMAKE_BUILD_TYPE STREQUAL Debug)
if(MSVC)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} /Zi)
else()
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -g)
endif()
elseif(CMAKE_BUILD_TYPE STREQUAL Release)
add_compile_options(-O3)
endif()

# Add source to this project's executable.
add_executable (cmakeCppModules cmakeCppModules.cpp)
target_link_libraries(cmakeCppModules modules_lib)
```

```
// cmakeCppModules.cpp : Defines the entry point for the application.
//

// Conventional #includes and module imports can be freely mixed.
#include vector

// Import the Printers module defined in Printers.ixx.
import Printers;

using namespace std;

void print_vector(const vectorint list) {
// SimplePrinter and get_default_printer are imported from the
// Printers module.
SimplePrinter printer = get_default_printer();

for (auto i : list) {
printer.print_element(i);
}

printer.print_separator();
}

int main() {
const vectorint vec = {1, 2, 3, 4, 5};
print_vector(vec);
return 0;
}
```

```
// Printers.ixx
//
// The .ixx extension lets the build system know this file contains
// a module interface.

// Begin global module fragment.
module;

// Headers included in the global module fragment (between module; and
// export module Printers;) can be used by the module implementation but
// are not exported. These included headers are invisible to translation
// units that import the Printers module.
#include iostream

// Creates the Printers module. This can be imported into other translation
// units with import Printers; Any items marked with the export keyword
// will be available in translation units that import the Printers module.
export module Printers;

// This only applies to this module's translation unit. It does not leak
// into translation units that import the Printers module.
using namespace std;

// These constants are not exported, they are invisible from translation
// units that import the Printer module.
const string default_spacer = ;
const string default_separator = ,\n;

// SimplePrinter is exported and accessible to any code that imports the
// Printers module.
export struct SimplePrinter {
string element_spacer;
string separator;

void print_element(int e) { std::cout e element_spacer; }

void print_separator() { std::cout separator; }
};

// Exports the function get_default_printer.
// This is accessible from translation units that import the Printers module.
export SimplePrinter get_default_printer() {
// while (1) {
// goto dummy_label;
// }

// dummy_label:
return SimplePrinter{.element_spacer = default_spacer, .separator = default_separator};
}
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUWVtz4rjy_zTKS5ddIMcTeMgD11nqn8v8E2Z3dl8oYTWgiS35SHICL_vZT0kyFxuyM7N15tSeqpQJUqv71_eWYcaItUS8JemQpOMrVtmN0rcDLuyOPW-YtExWV0vFd7eEDggdPGGpFUkG4RvpjEmnfs5gw14REliJHE0cFiPICvaCo7K8V7xy61lZ7rc-aSEtahOL7Xa_NrpnL3gnjDWx3dpT_gPOhVyD3QgDuZDoQITtD536z381aAntje4H_zdZjL58WYzuBg8fF_PZ-Pewn-VMriMr-I4k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