aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/MC
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-07-18 22:22:07 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-07-18 22:22:07 +0000
commite4cfd69509a64e215b3c0bcf7089d2cb099377b1 (patch)
tree25d232634f4b787fd9da793a340251cbaec0ef81 /include/llvm/MC
parent958169411fdc9bc1ee9df3fa111bf33b5df7b5d9 (diff)
downloadexternal_llvm-e4cfd69509a64e215b3c0bcf7089d2cb099377b1.zip
external_llvm-e4cfd69509a64e215b3c0bcf7089d2cb099377b1.tar.gz
external_llvm-e4cfd69509a64e215b3c0bcf7089d2cb099377b1.tar.bz2
MC/AsmParser: Stop playing unsafe member function pointer calls, this isn't
portable enough. - Downside is we now double dispatch through a stub function, but this isn't performance critical. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108661 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/MC')
-rw-r--r--include/llvm/MC/MCParser/MCAsmParser.h2
-rw-r--r--include/llvm/MC/MCParser/MCAsmParserExtension.h10
2 files changed, 11 insertions, 1 deletions
diff --git a/include/llvm/MC/MCParser/MCAsmParser.h b/include/llvm/MC/MCParser/MCAsmParser.h
index c3b0c91..9457987 100644
--- a/include/llvm/MC/MCParser/MCAsmParser.h
+++ b/include/llvm/MC/MCParser/MCAsmParser.h
@@ -31,7 +31,7 @@ class Twine;
/// assembly parsers.
class MCAsmParser {
public:
- typedef bool (MCAsmParserExtension::*DirectiveHandler)(StringRef, SMLoc);
+ typedef bool (*DirectiveHandler)(MCAsmParserExtension*, StringRef, SMLoc);
private:
MCAsmParser(const MCAsmParser &); // DO NOT IMPLEMENT
diff --git a/include/llvm/MC/MCParser/MCAsmParserExtension.h b/include/llvm/MC/MCParser/MCAsmParserExtension.h
index 5b65f4e..95184cd 100644
--- a/include/llvm/MC/MCParser/MCAsmParserExtension.h
+++ b/include/llvm/MC/MCParser/MCAsmParserExtension.h
@@ -11,6 +11,7 @@
#define LLVM_MC_MCASMPARSEREXTENSION_H
#include "llvm/MC/MCParser/MCAsmParser.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/SMLoc.h"
namespace llvm {
@@ -28,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();