14#ifndef LLVM_CLANG_FRONTEND_COMMANDLINESOURCELOC_H
15#define LLVM_CLANG_FRONTEND_COMMANDLINESOURCELOC_H
18#include "llvm/Support/CommandLine.h"
19#include "llvm/Support/raw_ostream.h"
35 std::pair<StringRef, StringRef> ColSplit = Str.rsplit(
':');
36 std::pair<StringRef, StringRef> LineSplit =
37 ColSplit.first.rsplit(
':');
40 if (!ColSplit.second.getAsInteger(10, PSL.
Column) &&
41 !LineSplit.second.getAsInteger(10, PSL.
Line)) {
42 PSL.
FileName = std::string(LineSplit.first);
66 std::pair<unsigned, unsigned>
Begin;
69 std::pair<unsigned, unsigned>
End;
80 static std::optional<ParsedSourceRange>
fromString(StringRef Str) {
81 std::pair<StringRef, StringRef> RangeSplit = Str.rsplit(
'-');
82 unsigned EndLine, EndColumn;
83 bool HasEndLoc =
false;
84 if (!RangeSplit.second.empty()) {
85 std::pair<StringRef, StringRef> Split = RangeSplit.second.rsplit(
':');
86 if (Split.first.getAsInteger(10, EndLine) ||
87 Split.second.getAsInteger(10, EndColumn)) {
91 RangeSplit.first = Str;
96 if (
Begin.FileName.empty())
100 EndColumn =
Begin.Column;
104 {EndLine, EndColumn}};
115 class parser<
clang::ParsedSourceLocation> final
118 inline bool parse(Option &O, StringRef ArgName, StringRef ArgValue,
123 parser<clang::ParsedSourceLocation>::
124 parse(Option &O, StringRef ArgName, StringRef ArgValue,
126 using namespace clang;
128 Val = ParsedSourceLocation::FromString(ArgValue);
131 <<
"source location must be of the form filename:line:column\n";
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
The JSON file list parser is used to communicate input to InstallAPI.
Diagnostic wrappers for TextAPI types for error reporting.
A source location that has been parsed on the command line.
static ParsedSourceLocation FromString(StringRef Str)
Construct a parsed source location from a string; the Filename is empty on error.
std::string ToString() const
Serialize ParsedSourceLocation back to a string.
A source range that has been parsed on the command line.
std::pair< unsigned, unsigned > End
The ending location of the range.
static std::optional< ParsedSourceRange > fromString(StringRef Str)
Returns a parsed source range from a string or std::nullopt if the string is invalid.
std::pair< unsigned, unsigned > Begin
The starting location of the range.