This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Link targets and Asm parsers
ClosedPublic

Authored by zturner on Oct 4 2017, 9:52 AM.

Details

Summary

Currently clang-tidy fails on any file that includes inline assembly. This is not a great out-of-the-box experience since many system headers include inline assembly, particularly on Windows.

I checked through the various other clang tools and they all have similar logic to link in a minimal amount of backend stuff to get a target registry, so this patch does the same for clang-tidy

Diff Detail

Repository
rL LLVM

Event Timeline

zturner created this revision.Oct 4 2017, 9:52 AM
alexfh accepted this revision.Oct 5 2017, 5:57 PM

The first attempt to fix this (https://reviews.llvm.org/D17981) was stuck on figuring out whether we care about the binary size. It seems to me that the binary size is secondary to maintaining proper functionality for platforms that use inline assembly in headers. Thus, LG

This revision is now accepted and ready to land.Oct 5 2017, 5:57 PM

Zachary, do you plan to commit this? I'd also suggest adding a regression test.

Thanks!

zturner updated this revision to Diff 119677.Oct 20 2017, 11:55 AM

Added a test. Alex, if you can confirm this test gives sufficient coverage I can go ahead and submit today. Thanks!

alexfh added inline comments.Oct 20 2017, 3:24 PM
clang-tools-extra/test/clang-tidy/hicpp-no-assembler.cpp
13–16 ↗(On Diff #119677)

Will this compile on linux and mac? If no, maybe a separate test just for windows is the way to go.

alexfh added inline comments.Oct 20 2017, 3:28 PM
clang-tools-extra/test/clang-tidy/hicpp-no-assembler.cpp
13–16 ↗(On Diff #119677)

... answering my own question: no, it doesn't compile on linux (https://godbolt.org/g/9HVvjp).

Please add a separate test guarded by REQUIRES: system-windows and ensure it breaks before your patch and passes with it.

This revision was automatically updated to reflect the committed changes.