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
This commit is contained in:
Daniel Dunbar
2010-07-18 22:22:07 +00:00
parent 030794bd87
commit 1edf6ca2cb
5 changed files with 104 additions and 188 deletions

View File

@@ -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

View File

@@ -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();