Issue 181294
Summary Clang-cl incorrectly handles `/external:I`. MSVC does not use this arg to add system include paths.
Labels new issue
Assignees
Reporter Colengms
    This is the inverse of another issue which contains an incorrect analysis of how the argument works in MSVC: https://github.com/llvm/llvm-project/issues/61796

With MSVC, `/external:I` can add an include path (if `/external:W#` is also specified) to be considered "external" for the purpose of external header diagnostics only. It does not specify that the include path should be a "system" include path (like gcc and clang's `-isystem` arg).  I don't believe MSVC provides an argument that would allow the caller to add a system include path.

The following examples use multiple include paths containing a header of the same name.

```
cl /nologo /external:I path_A /c test_include_paths.cpp
-- cl : Command line warning D9007 : '/external:I' requires '/external:W'; option ignored
-- Header is not found
```

The following imply that an include path is added by `/external:I`, but the first example would have found path B if `/external:I` had made `path_A` a system include path, as user include paths take priority over system include paths (and otherwise equal priority is from left-to-right). If `/external:I` had specified a different priority than `/I`, these command lines would have the same result - path B.

```
cl /nologo /external:W4 /external:I path_A /I path_B /c test_include_paths.cpp
-- Finds path A.

cl /nologo /external:W4 /I path_B /external:I path_A /c test_include_paths.cpp 
-- Finds path B.
```

It looks link clang-cl (21.1.0) is currently inconsistent with MSVC:

```
clang-cl  /nologo /external:I path_A /c test_include_paths.cpp
 -- Finds path A.
```

```
clang-cl /nologo /external:W4 /external:I path_A /I path_B /c test_include_paths.cpp
 -- Finds path B.

clang-cl /nologo /external:W4 /I path_B /external:I path_A /c test_include_paths.cpp
 -- Finds path B.
```



_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to