Caphyon / clang-power-tools

Bringing clang-tidy magic to Visual Studio C++ developers.
http://www.clangpowertools.com
Apache License 2.0
487 stars 57 forks source link

tidy/tidy-fix in cpt.config causes tidy call on compile #492

Open elviiix opened 5 years ago

elviiix commented 5 years ago

You set $aTidyFlags/$aTidyFixFlags from cpt and later set WorkloadType based on loaded from cpt values

  [WorkloadType] $workloadType = [WorkloadType]::Compile

  if (![string]::IsNullOrEmpty($aTidyFlags))
  {
     $workloadType = [WorkloadType]::Tidy
  }

  if (![string]::IsNullOrEmpty($aTidyFixFlags))
  {
     $workloadType = [WorkloadType]::TidyFix
  }

Need for example to store somewhere values after params and use that stores values for setting workloadType

.. , [alias("vs-sku")] .. [Parameter(Mandatory=$false, HelpMessage="Edition of Visual Studio toolset to use for loading project")] .. [string] $aVisualStudioSku .. )

if (![string]::IsNullOrEmpty($aTidyFixFlags))
{
    Set-Variable -name aTidyFixFlagsOnStart -value "1" -option Constant
}

if (![string]::IsNullOrEmpty($aTidyFlags))
{
    Set-Variable -name aTidyFlagsOnStart -value "1" -option Constant
}

```.....

if (![string]::IsNullOrEmpty($aTidyFlagsOnStart)) { $workloadType = [WorkloadType]::Tidy }

if (![string]::IsNullOrEmpty($aTidyFixFlagsOnStart)) { $workloadType = [WorkloadType]::TidyFix }

elviiix commented 5 years ago

Do you need pull request with fix or do you prefer to fix it yourself/other way?

hero101111 commented 5 years ago

The cpt.config file is overriding the script parameter values by design. We introduced this mechanism a few releases ago as a way of enabling teams to share and reuse Clang Power Tools settings easily, using source version control.

The Clang Power Tools user interface in the Visual Studio extension is not yet aware of this configuration file and leads to the behavior you are experiencing. We will address this in a future update.

Regards, Gabriel.

elviiix commented 5 years ago

It's ok, that cpt.config overrides script parameters. The problem is that it also overrides type of call from outside of script, not only from extension (compile/tidy/tidy-fix). You call compile (from VS or from command line) and get tidy-fix instead of it, and that's pretty nasty.