mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
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:
@@ -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
|
||||
|
@@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user