xref: /freebsd/contrib/llvm-project/llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.h (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1 //===--- COFFDirectiveParser.h - JITLink coff directive parser --*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // MSVC COFF directive parser
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_EXECUTIONENGINE_JITLINK_COFFDIRECTIVEPARSER_H
14 #define LLVM_EXECUTIONENGINE_JITLINK_COFFDIRECTIVEPARSER_H
15 
16 #include "llvm/ExecutionEngine/JITLink/JITLink.h"
17 #include "llvm/Option/Arg.h"
18 #include "llvm/Option/ArgList.h"
19 #include "llvm/Support/CommandLine.h"
20 #include "llvm/Support/Error.h"
21 #include "llvm/Support/StringSaver.h"
22 #include "llvm/TargetParser/Triple.h"
23 
24 namespace llvm {
25 namespace jitlink {
26 
27 enum {
28   COFF_OPT_INVALID = 0,
29 #define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) COFF_OPT_##ID,
30 #include "COFFOptions.inc"
31 #undef OPTION
32 };
33 
34 /// Parser for the MSVC specific preprocessor directives.
35 /// https://docs.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp?view=msvc-160
36 class COFFDirectiveParser {
37 public:
38   Expected<opt::InputArgList> parse(StringRef Str);
39 
40 private:
41   llvm::BumpPtrAllocator bAlloc;
42   llvm::StringSaver saver{bAlloc};
43 };
44 
45 } // end namespace jitlink
46 } // end namespace llvm
47 
48 #endif // LLVM_EXECUTIONENGINE_JITLINK_COFFDIRECTIVEPARSER_H
49