mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-23 16:19:52 +00:00
MIR Parser: Use correct source locations for machine instruction diagnostics.
This commit translates the source locations for MIParser diagnostics from the locations in the machine instruction string to the locations in the MIR file. Reviewers: Duncan P. N. Exon Smith Differential Revision: http://reviews.llvm.org/D10574 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240474 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -22,7 +22,43 @@
|
||||
#include "llvm/Support/YAMLTraits.h"
|
||||
#include <vector>
|
||||
|
||||
LLVM_YAML_IS_SEQUENCE_VECTOR(std::string)
|
||||
namespace llvm {
|
||||
namespace yaml {
|
||||
|
||||
/// A wrapper around std::string which contains a source range that's being
|
||||
/// set during parsing.
|
||||
struct StringValue {
|
||||
std::string Value;
|
||||
SMRange SourceRange;
|
||||
|
||||
StringValue() {}
|
||||
StringValue(std::string Value) : Value(std::move(Value)) {}
|
||||
|
||||
bool operator==(const StringValue &Other) const {
|
||||
return Value == Other.Value;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct ScalarTraits<StringValue> {
|
||||
static void output(const StringValue &S, void *, llvm::raw_ostream &OS) {
|
||||
OS << S.Value;
|
||||
}
|
||||
|
||||
static StringRef input(StringRef Scalar, void *Ctx, StringValue &S) {
|
||||
S.Value = Scalar.str();
|
||||
if (const auto *Node =
|
||||
reinterpret_cast<yaml::Input *>(Ctx)->getCurrentNode())
|
||||
S.SourceRange = Node->getSourceRange();
|
||||
return "";
|
||||
}
|
||||
|
||||
static bool mustQuote(StringRef Scalar) { return needsQuotes(Scalar); }
|
||||
};
|
||||
|
||||
} // end namespace yaml
|
||||
} // end namespace llvm
|
||||
|
||||
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::StringValue)
|
||||
|
||||
namespace llvm {
|
||||
namespace yaml {
|
||||
@@ -34,7 +70,7 @@ struct MachineBasicBlock {
|
||||
bool AddressTaken = false;
|
||||
// TODO: Serialize the successors and liveins.
|
||||
|
||||
std::vector<std::string> Instructions;
|
||||
std::vector<StringValue> Instructions;
|
||||
};
|
||||
|
||||
template <> struct MappingTraits<MachineBasicBlock> {
|
||||
|
||||
Reference in New Issue
Block a user