Lines Matching +full:string +full:- +full:support

1 //===- JSONCompilationDatabase.cpp ----------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
22 #include "llvm/Support/Allocator.h"
23 #include "llvm/Support/Casting.h"
24 #include "llvm/Support/CommandLine.h"
25 #include "llvm/Support/ErrorOr.h"
26 #include "llvm/Support/MemoryBuffer.h"
27 #include "llvm/Support/Path.h"
28 #include "llvm/Support/StringSaver.h"
29 #include "llvm/Support/VirtualFileSystem.h"
30 #include "llvm/Support/YAMLParser.h"
31 #include "llvm/Support/raw_ostream.h"
37 #include <string>
50 /// Assumes \-escaping for quoted arguments (see the documentation of
55 : Input(CommandLine), Position(Input.begin()-1) {} in CommandLineArgumentParser()
57 std::vector<std::string> parse() { in parse()
60 std::string Argument; in parse()
70 bool parseStringInto(std::string &String) { in parseStringInto() argument
73 if (!parseDoubleQuotedStringInto(String)) return false; in parseStringInto()
75 if (!parseSingleQuotedStringInto(String)) return false; in parseStringInto()
77 if (!parseFreeStringInto(String)) return false; in parseStringInto()
83 bool parseDoubleQuotedStringInto(std::string &String) { in parseDoubleQuotedStringInto() argument
87 String.push_back(*Position); in parseDoubleQuotedStringInto()
93 bool parseSingleQuotedStringInto(std::string &String) { in parseSingleQuotedStringInto() argument
96 String.push_back(*Position); in parseSingleQuotedStringInto()
102 bool parseFreeStringInto(std::string &String) { in parseFreeStringInto() argument
105 String.push_back(*Position); in parseFreeStringInto()
132 std::vector<std::string> CommandLine;
135 std::vector<std::string> unescapeCommandLine(JSONCommandLineSyntax Syntax, in unescapeCommandLine()
151 std::vector<std::string> Result(T.begin(), T.end()); in unescapeCommandLine()
163 loadFromDirectory(StringRef Directory, std::string &ErrorMessage) override { in loadFromDirectory()
180 X("json-compilation-database", "Reads JSON formatted compilation databases");
194 std::string &ErrorMessage, in loadFromFile()
196 // Don't mmap: if we're a long-lived process, the build system may overwrite. in loadFromFile()
207 if (!Database->parse(ErrorMessage)) in loadFromFile()
214 std::string &ErrorMessage, in loadFromBuffer()
220 if (!Database->parse(ErrorMessage)) in loadFromBuffer()
230 std::string Error; in getCompileCommands()
239 getCommands(CommandsRefI->getValue(), Commands); in getCompileCommands()
243 std::vector<std::string>
245 std::vector<std::string> Result; in getAllFiles()
263 // There are compiler-wrappers (ccache, distcc) that take the "real"
264 // compiler as an argument, e.g. distcc gcc -O3 foo.c.
267 static bool unwrapCommand(std::vector<std::string> &Args) { in unwrapCommand()
273 // Most of these wrappers support being invoked 3 ways: in unwrapCommand()
285 (Args[1][0] != '-') && in unwrapCommand()
296 static std::vector<std::string>
300 std::vector<std::string> Arguments; in nodeToCommandLine()
302 Arguments = unescapeCommandLine(Syntax, Nodes[0]->getValue(Storage)); in nodeToCommandLine()
305 Arguments.push_back(std::string(Node->getValue(Storage))); in nodeToCommandLine()
321 std::get<0>(CommandRef)->getValue(DirectoryStorage), in getCommands()
322 std::get<1>(CommandRef)->getValue(FilenameStorage), in getCommands()
324 Output ? Output->getValue(OutputStorage) : ""); in getCommands()
328 bool JSONCompilationDatabase::parse(std::string &ErrorMessage) { in parse()
334 llvm::yaml::Node *Root = I->getRoot(); in parse()
361 StringRef KeyValue = KeyString->getValue(KeyStorage); in parse()
381 Command->push_back(Scalar); in parse()
385 ErrorMessage = "Expected string as value."; in parse()
399 ("Unknown key: \"" + KeyString->getRawValue() + "\"").str(); in parse()
417 StringRef FileName = File->getValue(FileStorage); in parse()
421 SmallString<128> AbsolutePath(Directory->getValue(DirectoryStorage)); in parse()