Skip to content

MSVC slash options ignored even in 'cl' driver mode #44701

@bradking

Description

@bradking
Bugzilla Link 45356
Version unspecified
OS Windows NT
CC @AtnNn,@Ivan171,@mizvekov

Extended Description

It does not seem possible to invoke clang-tidy with a cl command line that uses slash-style options:

clang-tidy --extra-arg-before=--driver-mode=cl ... -- cl /GR /EHsc ... 

I tried the following with clang-tidy 7 and 10.

With a source foo.cpp:

#if __cplusplus < 201703L #error "__cplusplus is not C++17" #endif #if _MSVC_LANG < 201703L #error "_MSVC_LANG is not C++17" #endif int main() { try { } catch (...) { }; return 0; }

I tried the following combinations:

>clang-tidy foo.cpp -- cl /GR /EHsc /std:c++17 C:\...\foo.cpp:2:2: error: "__cplusplus is not C++17" [...] #error "__cplusplus is not C++17" ^ C:\...\foo.cpp:5:2: error: "_MSVC_LANG is not C++17" [...] #error "_MSVC_LANG is not C++17" ^ >clang-tidy foo.cpp -- cl -GR -EHsc -std:c++17 error: unknown argument: '-EHsc' [...] error: unknown argument: '-std:c++17' [...] C:\...\foo.cpp:2:2: error: "__cplusplus is not C++17" [...] #error "__cplusplus is not C++17" ^ C:\...\foo.cpp:5:2: error: "_MSVC_LANG is not C++17" [...] #error "_MSVC_LANG is not C++17" ^ >clang-tidy --extra-arg-before=--driver-mode=cl foo.cpp -- cl /GR /EHsc -std:c++17 C:\...\foo.cpp:10:3: error: cannot use 'try' with exceptions disabled [...] try { } catch (...) { }; ^ >clang-tidy --extra-arg-before=--driver-mode=cl foo.cpp -- cl -GR -EHsc -std:c++17 (works) 

Without --extra-arg-before=--driver-mode=cl, /std:... is accepted but does nothing. With --extra-arg-before=--driver-mode=cl, only the cl option forms starting in - instead of / seem to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions