question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

clang-build.ps1: -tidy -parallel gives errors (introduced with always writing a .clang-tidy file)

See original GitHub issue

PR #886 broke clang-build.ps1 MySolution.sln -tidy .clang-tidy -parallel.

With this (simplified) snippet from Function Run-ClangJobs:

    if (![string]::IsNullOrWhiteSpace($job.TidyFlagsTempFile) -and (Test-Path $job.TidyFlagsTempFile))
    {
        $clangTidyFile       = "$cppDirectory\.clang-tidy"
    }
    if (![string]::IsNullOrWhiteSpace($clangTidyFile))
    {
      Copy-Item -Path $job.TidyFlagsTempFile -Destination $clangTidyFile                         #### A
    }
    $callOutput = cmd.exe /c "$($job.FilePath) $($job.ArgumentList) 2>&1" | Out-String           #### B
    if (![string]::IsNullOrWhiteSpace($clangTidyFile))
    {
	Remove-Item $clangTidyFile                                                               #### C
    }

I’ve got .clang-tidy, project\a.cpp and project\b.cpp, and run tidy on a.cpp and b.cpp. They start right after each other. First, a.cpp get at A and copies .clang-tidy to project\.clang-tidy. Then it starts processing for some time (B). Meanwhile b.cpp gets at A and copies .clang-tidy to project\.clang-tidy, but that already exists! Then it also starts processing for some time (B). After processing is done (say, a.cpp is a bit quicker), it removes project\.clang-tidy (C). Then b.cpp wants to remove project\.clang-tidy (C) as well, but it is already gone! This results in an error.

So this copying (and creating backups) doesn’t play well with parallellism. And on top of that, I already have a .clang-tidy file, and I don’t provide explicit checks on the command line. So why is this copying needed at all?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bo3bcommented, Feb 21, 2022

Hello @bo3b

It looks like what you’re experiencing is a bit different from the original issue. Please enable verbose logging and attach the full log to help us investigate this.

Hello-

<strike>OK, I tried to capture a verbose log, but I can no longer reproduce the problem. I tried a few experiments to see if I could get back to a failing case, but I don’t know what has changed.

If you can give me some idea of where that Copy/Remove operation would be active, I can try to reproduce that setup. In all my experiments to try to reproduce this, I no longer see the Copy-Item in the log. </strike>

Edit: Well, spoke too soon. When I switched back to the same Util.cpp file, I can reproduce the problem. This file is at the solution level, not the DX11 project level, because it’s shared with other projects in the solution. It is at the same level as the .clang-tidy file.

Here is the verbose log: clangpower.log

1reaction
hero101111commented, Nov 10, 2020

Hi @gerboengels

Apologies for the inconveniences you’ve encountered. This is clearly a bug, the copying mechanism is intended to address only the explicit checks situation, because we’ve encountered issues when a lot of them are passed (the PR you mentioned addressed such an issue). We will fix the bug you’ve encountered as soon as possible and push it to a bugfix release of Clang Power Tools.

Thank you for the helpful feedback.

Regards, Gabriel

Read more comments on GitHub >

github_iconTop Results From Across the Web

Frequently Asked Questions
Does Clang Power Tools generate object files when running the Compile command? ... clang++ - Clang compile (syntax-only); clang-tidy - Clang Tidy (checks, ......
Read more >
How to build the latest clang-tidy? - c++
I've tried to build clang-tidy from sources but it complains about an undefined CMake command: CMake Error at clang-apply-replacements/ ...
Read more >
Clang-Tidy — Extra Clang Tools 18.0.0git documentation
Its purpose is to provide an extensible framework for diagnosing and fixing typical programming errors, like style violations, interface misuse, or bugs that ......
Read more >
Bringing Clang-tidy Magic to Visual Studio C++ Developers
Reference PowerShell script from the job working directory. Both the bootstrapper PS script (eg. ai-clang-build.ps1) and the main PS script ( ...
Read more >
Clang-Tidy, part 1: Modernize your source code using C ...
This blog series will introduce the clang-tidy utility from the Clang/LLVM project and show how to use it to automatically refactor C++ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found