aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-10-20 23:00:51 +0000
committerZachary Turner <zturner@google.com>2017-10-20 23:00:51 +0000
commitd2b688a3b0d7485bd2d1351babeee4c511cb2e58 (patch)
tree0f4729284935886f0af3cc7c6f7623e7e48d3f4b
parent9c7f566e8f93bdd2a8eae96256648a94a97959e7 (diff)
[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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@316246 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--clang-tidy/CMakeLists.txt3
-rw-r--r--clang-tidy/tool/ClangTidyMain.cpp5
-rw-r--r--test/clang-tidy/hicpp-no-assembler-msvc.cpp9
-rw-r--r--test/clang-tidy/hicpp-no-assembler.cpp5
4 files changed, 22 insertions, 0 deletions
diff --git a/clang-tidy/CMakeLists.txt b/clang-tidy/CMakeLists.txt
index 9d6fc7f0..7efc63b0 100644
--- a/clang-tidy/CMakeLists.txt
+++ b/clang-tidy/CMakeLists.txt
@@ -1,4 +1,7 @@
set(LLVM_LINK_COMPONENTS
+ AllTargetsAsmParsers
+ AllTargetsDescs
+ AllTargetsInfos
Support
)
diff --git a/clang-tidy/tool/ClangTidyMain.cpp b/clang-tidy/tool/ClangTidyMain.cpp
index a57fde87..79c0d0b3 100644
--- a/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tidy/tool/ClangTidyMain.cpp
@@ -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);
diff --git a/test/clang-tidy/hicpp-no-assembler-msvc.cpp b/test/clang-tidy/hicpp-no-assembler-msvc.cpp
new file mode 100644
index 00000000..f89e92bf
--- /dev/null
+++ b/test/clang-tidy/hicpp-no-assembler-msvc.cpp
@@ -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]
+ }
+}
diff --git a/test/clang-tidy/hicpp-no-assembler.cpp b/test/clang-tidy/hicpp-no-assembler.cpp
index d08ea74f..90173312 100644
--- a/test/clang-tidy/hicpp-no-assembler.cpp
+++ b/test/clang-tidy/hicpp-no-assembler.cpp
@@ -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]
+ }
}