Skip to content

Commit

Permalink
[clang-extdef-mapping] register necessary targest for ms-style asm block
Browse files Browse the repository at this point in the history
Without targets registered gives: "error: MS-style inline assembly is not
available: Unable to find target for this triple (no targets are registered)"

Differential Revision: https://reviews.llvm.org/D154983
  • Loading branch information
danix800 committed Jul 18, 2023
1 parent e953669 commit 2c65118
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions clang/test/Tooling/ms-asm-clang-extdef-mapping.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// RUN: clang-extdef-mapping "%s" -- -fasm-blocks 2>&1 | FileCheck %s

void Break() {
__asm { int 3 }
}

// CHECK: {{c:@F@Break .*}}
3 changes: 3 additions & 0 deletions clang/tools/clang-extdef-mapping/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
set(LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
AllTargetsAsmParsers
AllTargetsDescs
AllTargetsInfos
support
)

Expand Down
5 changes: 5 additions & 0 deletions clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "clang/Tooling/Tooling.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/TargetSelect.h"
#include <optional>
#include <sstream>
#include <string>
Expand Down Expand Up @@ -214,6 +215,10 @@ int main(int argc, const char **argv) {
}
CommonOptionsParser &OptionsParser = ExpectedParser.get();

llvm::InitializeAllTargetInfos();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllAsmParsers();

return HandleFiles(OptionsParser.getSourcePathList(),
OptionsParser.getCompilations());
}

0 comments on commit 2c65118

Please sign in to comment.