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"
37 std::pair<StringRef, StringRef> ColSplit = Str.rsplit(
':');
38 std::pair<StringRef, StringRef> LineSplit =
39 ColSplit.first.rsplit(
':');
42 if (!ColSplit.second.getAsInteger(10, PSL.
Column) &&
43 !LineSplit.second.getAsInteger(10, PSL.
Line) &&
45 PSL.
FileName = std::string(LineSplit.first);
69 std::pair<unsigned, unsigned>
Begin;
72 std::pair<unsigned, unsigned>
End;
83 static std::optional<ParsedSourceRange>
fromString(StringRef Str) {
84 std::pair<StringRef, StringRef> RangeSplit = Str.rsplit(
'-');
85 unsigned EndLine, EndColumn;
86 bool HasEndLoc =
false;
87 if (!RangeSplit.second.empty()) {
88 std::pair<StringRef, StringRef> Split = RangeSplit.second.rsplit(
':');
89 if (Split.first.getAsInteger(10, EndLine) ||
90 Split.second.getAsInteger(10, EndColumn)) {
94 RangeSplit.first = Str;
97 if (EndLine == 0 || EndColumn == 0)
103 if (
Begin.FileName.empty())
106 EndLine =
Begin.Line;
107 EndColumn =
Begin.Column;
111 {EndLine, EndColumn}};
122 class parser<
clang::ParsedSourceLocation> final
125 inline bool parse(Option &O, StringRef ArgName, StringRef ArgValue,
130 parser<clang::ParsedSourceLocation>::
131 parse(Option &O, StringRef ArgName, StringRef ArgValue,
133 using namespace clang;
135 Val = ParsedSourceLocation::FromString(ArgValue);
138 <<
"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.