LLVM 24.0.0git
COFFDirectiveParser.cpp
Go to the documentation of this file.
1//===-- COFFDirectiveParser.cpp - 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#include "COFFDirectiveParser.h"
14
15using namespace llvm;
16using namespace jitlink;
17
18#define DEBUG_TYPE "jitlink"
19
20using namespace llvm::opt;
21#define OPTTABLE_CODE
22#include "COFFOptions.inc"
23
25public:
26 COFFOptTable() : OptTable(optionTables(), true) {}
27};
28
30
34 cl::TokenizeWindowsCommandLineNoCopy(Str, saver, Tokens);
35 for (StringRef Tok : Tokens) {
36 bool HasNul = Tok.end() != Str.end() && Tok.data()[Tok.size()] == '\0';
37 Buffer.push_back(HasNul ? Tok.data() : saver.save(Tok).data());
38 }
39
40 unsigned missingIndex;
41 unsigned missingCount;
42
43 auto Result = optTable.ParseArgs(Buffer, missingIndex, missingCount);
44
45 if (missingCount)
46 return make_error<JITLinkError>(Twine("COFF directive parsing failed: ") +
47 Result.getArgString(missingIndex) +
48 " missing argument");
50 for (auto *arg : Result.filtered(COFF_OPT_UNKNOWN))
51 dbgs() << "Unknown coff option argument: " << arg->getAsString(Result)
52 << "\n";
53 });
54 return std::move(Result);
55}
static COFFOptTable optTable
#define LLVM_DEBUG(...)
Definition Debug.h:119
Tagged union holding either a T or a Error.
Definition Error.h:485
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
Provide access to the Option info table.
Definition OptTable.h:54
LLVM_ABI void TokenizeWindowsCommandLineNoCopy(StringRef Source, StringSaver &Saver, SmallVectorImpl< StringRef > &NewArgv)
Tokenizes a Windows command line while attempting to avoid copies.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
Definition Error.h:340