forked from OSchip/llvm-project
[clang-tidy] Don't error on MS-style inline assembly.
To get MS-style inline assembly, we need to link in the various backends. Some other clang tools already do this, and this issue has been raised with clang-tidy several times, indicating there is sufficient desire to make this work. Differential Revision: https://reviews.llvm.org/D38549 llvm-svn: 316246
This commit is contained in:
parent
6f4f0f1865
commit
fbdca1daec
|
@ -1,4 +1,7 @@
|
|||
set(LLVM_LINK_COMPONENTS
|
||||
AllTargetsAsmParsers
|
||||
AllTargetsDescs
|
||||
AllTargetsInfos
|
||||
Support
|
||||
)
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "../ClangTidy.h"
|
||||
#include "clang/Tooling/CommonOptionsParser.h"
|
||||
#include "llvm/Support/Process.h"
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
|
||||
using namespace clang::ast_matchers;
|
||||
using namespace clang::driver;
|
||||
|
@ -403,6 +404,10 @@ static int clangTidyMain(int argc, const char **argv) {
|
|||
|
||||
ProfileData Profile;
|
||||
|
||||
llvm::InitializeAllTargetInfos();
|
||||
llvm::InitializeAllTargetMCs();
|
||||
llvm::InitializeAllAsmParsers();
|
||||
|
||||
ClangTidyContext Context(std::move(OwningOptionsProvider));
|
||||
runClangTidy(Context, OptionsParser.getCompilations(), PathList,
|
||||
EnableCheckProfile ? &Profile : nullptr);
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// REQUIRES: system-windows
|
||||
// RUN: %check_clang_tidy %s hicpp-no-assembler %t
|
||||
|
||||
void f() {
|
||||
_asm {
|
||||
mov al, 2;
|
||||
// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler]
|
||||
}
|
||||
}
|
|
@ -9,4 +9,9 @@ static int s asm("spam");
|
|||
void f() {
|
||||
__asm("mov al, 2");
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler]
|
||||
|
||||
_asm {
|
||||
mov al, 2;
|
||||
// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue