Coder Social home page Coder Social logo

caphyon / clang-power-tools Goto Github PK

View Code? Open in Web Editor NEW
472.0 16.0 56.0 49.56 MB

Bringing clang-tidy magic to Visual Studio C++ developers.

Home Page: http://www.clangpowertools.com

License: Apache License 2.0

C# 68.56% PowerShell 31.44%
clang clang-compile clang-tidy modernize static-analysis cpp clang-format llvm

clang-power-tools's Introduction

clang-power-tools's People

Contributors

alexandear avatar burcadoruciprian avatar calumr avatar cpp-red-lion avatar dmateja avatar enache-ionut avatar gerboengels avatar germanaizek avatar hero101111 avatar hprica avatar infinitestatemachine avatar jherico avatar jwtowner avatar mariru27 avatar marthinsen avatar mrexodia avatar rodicamihaelavasilescu avatar shaneharper avatar vahtis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clang-power-tools's Issues

Settings from Directory.Build.props are ignored

I use normally the file Directory.Build.props to configure global settings for my C++ projects. MSBuild will pick this file up by walking up the directory tree. The clang-power-tools are unable to detect this file and thus assume that my projects are targeting WinSDK 8.1 and cannot file the OS include files (my projects are using the win10 sdk headers)

Output window keeps stealing focus

The outputWindow.Show call in OutputManager is forcing focus to the VS output window on every message. For long builds with lots of messages this makes it impossible to do any text editing while clang-power-tools is running.

Regex for parsing errors and warnings does not allow '-' in path

Currently the regex for wanings and errors looks like this:
(.\:\\[ \w+\\\/.]*[h|cpp])(\r\n|\r|\n| |:)*(\d+)(\r\n|\r|\n| |:)*(\d+)(\r\n|\r|\n| |:)*(error|note|warning)[^s](\r\n|\r|\n| |:)*(.*)
The \w only allows names for files/direcrories consisting of words ([a-zA-Z0-9_])
In my projects I also have -.
Can we relax the regex to
(.\:\\[ \S+\\\/.]*[h|cpp])(\r\n|\r|\n| |:)*(\d+)(\r\n|\r|\n| |:)*(\d+)(\r\n|\r|\n| |:)*(error|note|warning)[^s](\r\n|\r|\n| |:)*(.*)
allowing any non whitespace in file names? Or how does a correct regex for file names look like?

Error: Cannot find given project

When I try to run (Compile or Tidy Code) on any project or file, I get an error message:

`
Start Clang Compile

Cannot find given project

Done Clang Compile
`
I'm using Visual C++ 2017, but with the standard solution file format, and Toolset: 14.0 (Visual Studio 2015) project format.

double-click on reported issues doesn't take you to the correct line

The clang tidy output is formatted like so...
C:\Users\bdavis\Git\hifi\libraries\shared\src\BaseScriptEngine.cpp:295:9: warning: use '= default' to define a trivial destructor [modernize-use-equals-default]

If you double-click on this line in Visual Studio it will open the correct file, but it won't take you to the specific line in question. Compare with native visual studio errors...

1>C:\Users\bdavis\Git\hifi\libraries\shared\src\SharedUtil.cpp(75): fatal error C1189: #error: x

You can fix this by capturing the tidy output and reformatting it to match the Visual Studio expectations. I've been playing with integrating clang-tidy as an external tool, although I've been using python instead of Powershell to trigger the launch. My python for capturing the output and processing it looks like this...

  p = re.compile('^(.*):(\d+):(\d+): (.*)$')
  process = subprocess.Popen(clangTidyCall + clangTidyArgs, stdout=subprocess.PIPE)
  out, err = process.communicate()
  lines = out.decode("utf-8").split('\n')
  # Reformat lines so that when clicked on in the output they 
  for line in lines:
    m = p.match(line)
    if (m):
      print(m.group(1) + "(" + m.group(2) + "): " + m.group(4))
    else:
      print(line)

the critical part is the regular expression ^(.*):(\d+):(\d+): (.*)$ The four capture groups capture the full path to the file, the line number, the position within the line and then the rest of the message to the end of the line.

When that expression is matched then I can reformat it using print(m.group(1) + "(" + m.group(2) + "): " + m.group(4)) This puts parens around the line number and drops the position within the line.

Errors when trying to compile file with plugin

Hi,

With the following project i get errors when compiling:
TidyRepro.zip
Note: this is the same project as another bug i reported in #34 and is a simple empty visual studio project on windows 10.

I downloaded the latest version of the plugin today, with last updated 20-10-2017 16:12:55

Errors:

Start Clang Compile

[ INFO ] WILL PROCESS PROJECTS: 
	TidyRepro.vcxproj
[ INFO ] 1. PROCESSING PROJECT D:\src\TidyRepro\TidyRepro\TidyRepro.vcxproj
Get-Item : Cannot find path 'D:\src\TidyRepro\TidyRepro\kVs2015RegistryKey' because it does not exist.
At C:\Users\jacobk\AppData\Local\Microsoft\VisualStudio\14.0\Extensions\mqajv2rz.dww\clang-build.ps1:493 char:25
+     $installLocation = (Get-Item kVs2015RegistryKey).GetValue("Instal ...
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (D:\src\TidyRepr...2015RegistryKey:String) [Get-Item], ItemNotFoundExcep 
   tion
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand
You cannot call a method on a null-valued expression.
At C:\Users\jacobk\AppData\Local\Microsoft\VisualStudio\14.0\Extensions\mqajv2rz.dww\clang-build.ps1:493 char:5
+     $installLocation = (Get-Item kVs2015RegistryKey).GetValue("Instal ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
Canonize-Path : Cannot bind argument to parameter 'base' because it is an empty string.
At C:\Users\jacobk\AppData\Local\Microsoft\VisualStudio\14.0\Extensions\mqajv2rz.dww\clang-build.ps1:494 char:32
+     return Canonize-Path -base $installLocation -child "..\.."
+                                ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Canonize-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Canonize-Path
Get-VisualStudio-Includes : Cannot bind argument to parameter 'vsPath' because it is an empty string.
At C:\Users\jacobk\AppData\Local\Microsoft\VisualStudio\14.0\Extensions\mqajv2rz.dww\clang-build.ps1:521 char:55
+     $returnArray += Get-VisualStudio-Includes -vsPath $vsPath
+                                                       ~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-VisualStudio-Includes], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Get-VisualStudio-Includes
clang++.exe: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
In file included from D:\src\TidyRepro\TidyRepro\stdafx.h:8:
D:\src\TidyRepro\TidyRepro/targetver.h:8:10: fatal error: 'SDKDDKVer.h' file not found
#include <SDKDDKVer.h>
         ^~~~~~~~~~~~~
1 error generated.
Errors encountered during PCH creation

Done Clang Compile

Invoke CompileCommand has no observable effect

Hi, i just downloaded your awesome plugin! Got powershell 5.1 on windows 10, installed LLVM and the latest version of the plugin of the marketplace using VS2015.3

When i press Invoke CompileCommand it has no observable effect and doesn't show anything in the output window. How can i trace what is going wrong? I suspect its something in my setup, but without any logging its hard to figure it out.

Provide option to use -fix-errors with Clang-Tidy

I'm running the extension on a rather large codebase, which fails to compile with Clang, because of includes like WinSock2.h. Therefor -fix does not work, because the project fails to compile with Clang.

It would be useful to add the option -fix-errors in the extension settings.

Add a VERBOSE mode setting for VS extension

PS script logging.

For the PS script, you can execute $verbosePreference = "Continue" before running the script.
This will print the verbose logging generated by the script, including include paths.

Invalid path attempting to run clang-tidy

When I attempt to run clang tidy via the project context menu on one of my solution projects I get this error:

'C:\Users\bdavis\Git\hifi\build\libraries\shared\C:\Users\bdavis\Git\hifi\libraries\shared\src\AABox.cpp' because it 
does not exist.

For some reason the extension is concatenating the project path with the full path to the source file. This project has been created by CMake.

This is the project file, located in 'C:\Users\bdavis\Git\hifi\build\libraries\shared`
shared.zip

The solution file is located in 'C:\Users\bdavis\Git\hifi\build` while the source files are located in C:\Users\bdavis\Git\hifi\libraries\shared\src\

I'm guessing that the parser isn't expecting an absolute path to the source file when parsing the project information, but that's probably always going to be the case when using CMake to create an out-of-source build.

Please feel free to ping me if you need additional information. I may try to extract and build the plugin myself so I can offer a patch, but my C# isn't all that great.

Extract include paths from project automatically

The settings dialog has a field for Include Directories, but this appears to be global to all projects and solutions. It also has isn't automatically populated by the project's include directories.

Error in case of empty ProjectAdditionalIncludes

This test project is apparently a good bugfinder, if you are going to automate testing i recommend it.

Start Clang Compile

[ INFO ] WILL PROCESS PROJECTS: 
	TidyRepro.vcxproj
[ INFO ] 1. PROCESSING PROJECT D:\src\TidyRepro\TidyRepro\TidyRepro.vcxproj
Canonize-Path : Cannot bind argument to parameter 'child' because it is an empty string.
At C:\Users\jacobk\AppData\Local\Microsoft\VisualStudio\14.0\Extensions\jokknqjg.a4e\clang-build.ps1:1059 char:43
+       Canonize-Path -base $projDir -child $token -ignoreErrors
+                                           ~~~~~~
    + CategoryInfo          : InvalidData: (:) [Canonize-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Canonize-Path
Canonize-Path : Cannot bind argument to parameter 'child' because it is an empty string.
At C:\Users\jacobk\AppData\Local\Microsoft\VisualStudio\14.0\Extensions\jokknqjg.a4e\clang-build.ps1:1059 char:43
+       Canonize-Path -base $projDir -child $token -ignoreErrors
+                                           ~~~~~~
    + CategoryInfo          : InvalidData: (:) [Canonize-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Canonize-Path
 
clang++.exe: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
1: D:\src\TidyRepro\TidyRepro\TidyRepro.cpp

Done Clang Compile

I already fixed it myself, here you go:

Function Get-ProjectAdditionalIncludes([Parameter(Mandatory=$true)][string] $vcxprojPath)
{
  [string[]] $tokens = (Select-ProjectNodes $kVcxprojXpathAdditionalIncludes).InnerText -split ";"
  if (!$tokens)
  {
    return
  }

  [string] $projDir = Get-FileDirectory($vcxprojPath)
  
  foreach ($token in $tokens)
  {
    if (![string]::IsNullOrEmpty($token))
    {
      if ($token -eq $kVStudioVarProjDir)
      {
        $projDir
      }
      Else
      {
        Canonize-Path -base $projDir -child $token -ignoreErrors
      }
    }
  }
}

I am no hero with powershell, preferably the string split would not include empty strings by itself.

TidyRepro.zip

Clang Compile/Tidy error (MissingEqualsInNamedArgument) in clang-build.ps1

When using the released extension from VS marketplace, I get an error when trying to run Clang Compile or Clang Tidy.

Sorry it's German, but I guess the error can be checked.

Start Clang Compile

Der =-Operator fehlt nach einem benannten Argument.
Bei C:\Users\.....\AppData\Local\Microsoft\VisualStudio\15.0_cb0b111a\Extensions\
p3bc2z0b.pwl\clang-build.ps1:226 Zeichen:49
+ Function Write-Err([parameter(ValueFromPipeline, <<<<  Mandatory=$true)][stri
ng] $msg)
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : MissingEqualsInNamedArgument

Done Clang Compile


Start Clang Tidy

Der =-Operator fehlt nach einem benannten Argument.
Bei C:\Users\.....\AppData\Local\Microsoft\VisualStudio\15.0_cb0b111a\Extensions\
p3bc2z0b.pwl\clang-build.ps1:226 Zeichen:49
+ Function Write-Err([parameter(ValueFromPipeline, <<<<  Mandatory=$true)][stri
ng] $msg)
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : MissingEqualsInNamedArgument

Done Clang Tidy

I use VS 2017 (15.3)

Clang Power Tools/Tidy/Checks is missing a few checks vs llvm 5.0.0 release

First off, thanks for this amazing toolset, it is great to be able to do this stuff directly in VS.

I noticed this since some these checks are active by default, so they get applied even if you set all the checks to "False". I'm trying to roll out these fixes in small doses, so it's a little hard to control as much as I'd like.

bugprone-integer-division
cppcoreguidelines-owning-memory
hicpp-braces-around-statements
hicpp-deprecated-headers
hicpp-exception-baseclass
hicpp-move-const-arg
hicpp-no-array-decay
hicpp-no-malloc
hicpp-signed-bitwise
hicpp-static-assert
hicpp-use-auto
hicpp-use-emplace
hicpp-use-nullptr
hicpp-vararg
readability-static-accessed-through-instance

Some seem spelled differently:
performance-implicit-conversion-in-loop != performance-implicit-cast-in-loop
readability-implicit-bool-conversion != readability-implicit-bool-cast

Add support for force includes

-include
Adds an implicit #include into the predefines buffer which is read before the source file is pre-processed.
Translate MSVC flag /FI to clang++ -include

Support for custom $(Configuration)|$(Platform) conditions in VS property-sheets

screenshot

I don't know if it's a problem with my configuration, but i can't configure includes...
I have two VS 2015 opened (different git branches for the same code), and on one of them the include appears, on the second one doesn't. Furthermore, on the first one I can use power-tools, but on the second (without includes) execution of compile/tidy gives error:

Start Clang Tidy

[ INFO ] WILL PROCESS PROJECTS: 
	xxx.vcxproj
[ INFO ] 1. PROCESSING PROJECT D:\xxx.vcxproj
Did not expect that
At C:\Users\gglowacki\AppData\Local\Microsoft\VisualStudio\14.0\Extensions\h3be4nct.gu5\clang-build.ps1:802 char:9
+         throw "Did not expect that"
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Did not expect that:String) [], RuntimeException
    + FullyQualifiedErrorId : Did not expect that
 

Done Clang Tidy


Clang-power-tools 1.5.0

Extract preprocessor define directives from project automatically

Currently, if you have preprocessor defines set in your project, you need to manually move those over to the "Compile Flags" field in the settings dialog. I believe the settings dialog is also global, and not project specific, so if you have multiple projects with different preprocessor defines, you will need to frequently switch them back and forth.

Environment variables in vcxproj not replaced

Example output doesn't replace $(GeoSLAM) with C:\Repositories\ct-geoslam and thus prepends the current directory. i.e. Path should be
C:\Repositories\ct-geoslam\src\nrrslam\apps\dataset_merger\src\apply_transform.cpp
and not
C:\Repositories\win-geoslam\geoslam$(GeoSLAM)\src\nrrslam\apps\dataset_merger\src\apply_transform.cpp

Unfortunately I've never done any PowerShell so cannot fix myself.

===

Start Clang Compile

[ INFO ] WILL PROCESS PROJECTS:
apply_transform.vcxproj
[ INFO ] 1. PROCESSING PROJECT C:\Repositories\win-geoslam\geoslam\apply_transform.vcxproj
Join-Path : Cannot find path
'C:\Repositories\win-geoslam\geoslam$(GeoSLAM)\src\nrrslam\apps\dataset_merger\src\apply_transform.cpp' because it
does not exist.
At C:\Users\Zeb\AppData\Local\Microsoft\VisualStudio\15.0_8121d886\Extensions\lryuk1gn.tm5\clang-build.ps1:297 char:22

  • ... ng] $path = Join-Path -Path "$base" -ChildPath "$child" -Resolve -Err ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (C:\Repositories...y_transform.cpp:String) [Join-Path], ItemNotFoundExce
      ption
    • FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.JoinPathCommand

Done Clang Compile

Extract C++ language standard version from project files.

Map MSVC /std:c++14 /std:c++17 /std:c++latest compiler options to corresponding clang++ flags:
-std=c++14 -std=c++17 -std=c++1z

Note that VS property-sheet syntax for these options is:

<ClCompile>
   <LanguageStandard>stdcpp14</LanguageStandard>
   <LanguageStandard>stdcpp17</LanguageStandard>
   <LanguageStandard>stdcpplatest</LanguageStandard>
</ClCompile>

Properly use include paths with spaces and x86 (e.g. C:\Program Files(x86))

If I try to add Windows SDK include paths to the setting Include Directories the compilation fails, because the PowerShell script chokes on spaces or x86.

Start Clang Tidy

Die Benennung "x86" wurde nicht als Name eines Cmdlet, einer Funktion, einer 
Skriptdatei oder eines ausfuehrbaren Programms erkannt. Ueberpruefen Sie die 
Schreibweise des Namens, oder ob der Pfad korrekt ist (sofern enthalten), und 
wiederholen Sie den Vorgang.In Zeile:1 Zeichen:445
+ ... '%PROGRAMFILES(x86)%\\Windows Kits\\10\\Include\\10.0.15063.0\\um\\' 
-tidy-fix ' ...
+                    ~~~
    + CategoryInfo          : ObjectNotFound: (x86:String) [], CommandNotFound 
   Exception
    + FullyQualifiedErrorId : CommandNotFoundException

Done Clang Tidy

Non of the following attempts worked:

  • '%PROGRAMFILES(x86)%\\Windows Kits\\10\\Include\\10.0.15063.0\\um\\'
  • "%PROGRAMFILES(x86)%\\Windows Kits\\10\\Include\\10.0.15063.0\\um\\"
  • "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.15063.0\\um\\"
  • "C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um\"

Pure 64 bit builds broken

The shell script clang-build.ps1 doesn't properly fetch the includes or pre-processor definitions if the project has no Debug|Win32 configuation. We use cmake to generate project files and specifically target 64 bit builds, so our project files contain only Debug|x64 and Release|x64 configurations.

This means that the common snippet $_.GetAttribute("Condition") -eq $kPlatformFilter will never be true on our projects as is. I would suggest that either this condition needs to be expanded into a larger series of or conditions, or the current target platform should be passed as a parameter to the shell script.

Property sheet parsing still doesn't work right

Using 1.5.0
When using the Clang Power Tools->Compile option it still doesn't find all the preprocessor defines and include file paths that are in our various property sheets. I have a stripped down version of our solution that demonstrates the issue but I would rather not post it on a public forum. Is there an email I can send it to?

Can't compile on dual CPU PC

I have a dual CPU PC (2 x 4 physical cores -> 2 x 8 logical cores). Calling compile gives an error;

  • [System.IO.DirectoryInfo] $child = ($directory | Get-ChildItem)
  • + CategoryInfo          : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : ConvertToFinalInvalidCastException
    

Could not compare "0" to "8 8". Error: "Cannot convert the "System.Object[]"
value of type "System.Object[]" to type "System.Int32"."
At C:\Users\xxx\AppData\Local\Microsoft\VisualStudio\15.0_e15d5032\Extension
s\d0kad1w4.pp0\clang-build.ps1:926 char:7

Looks like it is failing to parse "8 8" coming back from Get-WmiObject -class Win32_processor | Select-Object -property NumberOfLogicalProcessors -ExpandProperty NumberOfLogicalProcessors

Use the active project configuration

I expected Clang-Tidy to use the 'active' Solution in VS and the Project configuration that goes with it.

But the current implementation always uses the configuration mentioned first in the "ItemGroup" "ProjectConfigurations" within each projects' vcxproj-file.

I ran into this while trying to set-up at least one configuration with explicit paths to external libraries. To circumvent #80 and #81, after the global include setting was removed.
As an work-around I've added a Project Configuration called "ClangTidy" to each project, that I modify to get the required behaviour.

Clang Power Tools v1.5.1
VS Community v15.4.2

Get-Project-SDKVer returns empty version when not specified in .vcxproj

I analyzed a case where it couldn't find includes in windows specific libraries and when $vcxproj.Project.PropertyGroup.WindowsTargetPlatformVersion is not specified in the .vcxproj you now get an empty version. It is possible to specify it default in the vcxproj template and then its not available.
TidyRepro.zip

I think the fix would be to know which version is the default version for a platform. I already noticed the flag $aDefaultWinSdkVersion, but apparently its empty.

consider custom properties in property files

When you define a property like that:
<BuildUtilitiesDirectory Condition="Exists('../../../../BuildUtilities')">../../../../BuildUtilities</BuildUtilitiesDirectory>

it can be reused in other places like that:
<ClCompile> <AdditionalIncludeDirectories>$(SrcDirectory);$(BuildUtilitiesDirectory)/Cpp/include;$(BuildUtilitiesDirectory)/Cpp/boost;$(BuildUtilitiesDirectory)/Cpp/opencv;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

Currently those properties are not evaluated.

It would be nice to have that.

thx for this extension, it's really helpful to get better code quality

Provide better defaults for "Checks" dialog

After installing the clang-power-tools extension, all the checks start off disabled. This probably isn't what people want. Consider setting most of them to enabled by default. The main ones I can see leaving off by default would be the clang-analyzer-optin category.

Alternatively, make it easier to switch large chunks from false to true.

A project without a PCH fails to tidy

If you don't have a PCH configured in your project, no CPPs are returned from Get-ProjectCpps because of the $_.Include -notmatch $pchCppName predicate.

Add more logging to see clang command line arguments

After installing the latest version of this great tool i still have issues, but i am so far unable to reproduce it on a smaller project. Would it be possible to add some more logging (configurable in settings) such that i can see the command line arguments being passed to clang to detect what is going wrong? I suspect still some include paths are missing in a specific case

Remove deprecated "Include Directories" global option

Project Include Directories should be automatically extracted from your *.vcxproj or VS property-sheets.
There is no need to configure them manually.
The global setting you are referring to is there for historical reasons and will be removed in the next version, to avoid any further confusion.

Use clang-cl driver by default

Hi, i work on clang for Windows. Found out about this via Victor’s talk. I told him this in person but I’m putting it here so it doesn’t get forgotten.

Clang on windows is generally expected to be invoked as clang-cl.exe, but the extension uses clang++.exe. It’s possible to make this work, as you’ve discovered, but there’s several surprising issues that can arise, so I’m not sure it’s the right “default” experience.

For starters, it will be harder to get your code to even compile at all because there are a lot of special options that you need to pass to get it into ms compatibility mode with the right paths. But worse, you may end up checking different code than you’re actually building because you’re not using the same options your build system uses. This puts a large burden on the user to make sure they understand how to translate msvc compilation flags to clang compilation flags.

Since you’re already hooking into the vcxproj, you can determine on a per file basis the exact msvc style command line, this way you guarantee you are checking the same code you are shipping.

Of course, you can still provide options to override this or add clang specific command line options, but it seems like this should be “advanced” and not the default experience.

A couple of things you might not know that could help:

  1. If you run clang-cl.exe you literally pass the exact same command line as you would to cl.exe. But if you add -### at the end, instead of compiling, it will show you the “real” command line being generated. Perhaps the system could use this intelligently as a starting point.

  2. You can still pass most (all?) clang dash-options to clang-cl.exe and even mix msvc slash options with clang dash options.

  3. clang++.exe is a synonym for clang.exe —driver-mode=g++ and clang-cl.exe is a synonym for clang.exe —driver-mode=cl

In any case, I encourage you to look into defaulting to using the cl driver as I think it will be more familiar to users and in most cases will allow everything to “just work” immediately out of the box without having to futz around with clang command lines

Allow other file endings than .cpp

First: Thanks a lot for this project! I hoping for something like this for months!

It looks like your extension is currently filtering source files by the file ending .cpp

Please broaden the filter in clang-build.ps1, for example like
Set-Variable -name kExtensionCpp -value ".cpp|.c|.cxx" -Option Constant
or even make it configurable.

Best regards,
Gerriet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.