Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 19 additions & 21 deletions llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,6 @@ class ParseStatus {
}
};

enum class DiagnosticPredicateTy {
Match,
NearMatch,
NoMatch,
};

// When an operand is parsed, the assembler will try to iterate through a set of
// possible operand classes that the operand might match and call the
// corresponding PredicateMethod to determine that.
Expand All @@ -198,21 +192,25 @@ enum class DiagnosticPredicateTy {
// This is a light-weight alternative to the 'NearMissInfo' approach
// below which collects *all* possible diagnostics. This alternative
// is optional and fully backward compatible with existing
// PredicateMethods that return a 'bool' (match or no match).
struct DiagnosticPredicate {
DiagnosticPredicateTy Type;

explicit DiagnosticPredicate(bool Match)
: Type(Match ? DiagnosticPredicateTy::Match
: DiagnosticPredicateTy::NearMatch) {}
DiagnosticPredicate(DiagnosticPredicateTy T) : Type(T) {}
DiagnosticPredicate(const DiagnosticPredicate &) = default;
DiagnosticPredicate& operator=(const DiagnosticPredicate &) = default;

operator bool() const { return Type == DiagnosticPredicateTy::Match; }
bool isMatch() const { return Type == DiagnosticPredicateTy::Match; }
bool isNearMatch() const { return Type == DiagnosticPredicateTy::NearMatch; }
bool isNoMatch() const { return Type == DiagnosticPredicateTy::NoMatch; }
// PredicateMethods that return a 'bool' (match or near match).
class DiagnosticPredicate {
public:
enum PredicateTy {
Match, // Matches
NearMatch, // Close Match: use Specific Diagnostic
NoMatch, // No Match: use `InvalidOperand`
} Predicate;

constexpr DiagnosticPredicate(PredicateTy T) : Predicate(T) {}

explicit constexpr DiagnosticPredicate(bool Matches)
: Predicate(Matches ? Match : NearMatch) {}

explicit operator bool() const { return Predicate == Match; }

constexpr bool isMatch() const { return Predicate == Match; }
constexpr bool isNearMatch() const { return Predicate == NearMatch; }
constexpr bool isNoMatch() const { return Predicate == NoMatch; }
};

// When matching of an assembly instruction fails, there may be multiple
Expand Down
Loading