aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/MC/MCParser/MCAsmParserExtension.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/MC/MCParser/MCAsmParserExtension.h')
-rw-r--r--include/llvm/MC/MCParser/MCAsmParserExtension.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/include/llvm/MC/MCParser/MCAsmParserExtension.h b/include/llvm/MC/MCParser/MCAsmParserExtension.h
index ad9ccf79d12a..95184cdfcf32 100644
--- a/include/llvm/MC/MCParser/MCAsmParserExtension.h
+++ b/include/llvm/MC/MCParser/MCAsmParserExtension.h
@@ -11,9 +11,11 @@
#define LLVM_MC_MCASMPARSEREXTENSION_H
#include "llvm/MC/MCParser/MCAsmParser.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/SMLoc.h"
namespace llvm {
+class Twine;
/// \brief Generic interface for extending the MCAsmParser,
/// which is implemented by target and object file assembly parser
@@ -27,6 +29,15 @@ class MCAsmParserExtension {
protected:
MCAsmParserExtension();
+ // Helper template for implementing static dispatch functions.
+ template<typename T, bool (T::*Handler)(StringRef, SMLoc)>
+ static bool HandleDirective(MCAsmParserExtension *Target,
+ StringRef Directive,
+ SMLoc DirectiveLoc) {
+ T *Obj = static_cast<T*>(Target);
+ return (Obj->*Handler)(Directive, DirectiveLoc);
+ }
+
public:
virtual ~MCAsmParserExtension();
@@ -49,15 +60,14 @@ public:
bool Error(SMLoc L, const Twine &Msg) {
return getParser().Error(L, Msg);
}
+ bool TokError(const Twine &Msg) {
+ return getParser().TokError(Msg);
+ }
const AsmToken &Lex() { return getParser().Lex(); }
const AsmToken &getTok() { return getParser().getTok(); }
- bool TokError(const char *Msg) {
- return getParser().TokError(Msg);
- }
-
/// @}
};