From 5c6ce2f2a1355363f2ab78bdc14a5fe6f6311956 Mon Sep 17 00:00:00 2001 From: fundamental Date: Sat, 9 Aug 2014 13:43:08 -0400 Subject: [PATCH] Edge Cases For VTable --- src/pass1.cpp | 22 ++++++++++++++-------- test/virtual-methods.cpp | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/pass1.cpp b/src/pass1.cpp index 3c19349..ed7d445 100644 --- a/src/pass1.cpp +++ b/src/pass1.cpp @@ -289,14 +289,20 @@ struct DummyPass4 : public ModulePass { for(unsigned i=2; igetOperand(i); - auto alias = dyn_cast(op->getOperand(0));//dyn_cast(op); - auto someth = op->getOperand(0); - Function *function = NULL; - if(alias) - function = dyn_cast(alias->getOperand(0)); - else - function = dyn_cast(someth); - fprintf(stderr, " %d: %s\n", i-2, function->getName().str().c_str()); + const char *fname = NULL; + if(!dyn_cast(op)) { + Function *function = NULL; + auto alias = dyn_cast(op->getOperand(0));//dyn_cast(op); + auto someth = op->getOperand(0); + auto etc = dyn_cast(someth); + if(alias) + function = dyn_cast(alias->getOperand(0)); + else + function = dyn_cast(someth); + if(function) + fname = function->getName().str().c_str(); + } + fprintf(stderr, " %d: %s\n", i-2, fname); } } diff --git a/test/virtual-methods.cpp b/test/virtual-methods.cpp index 11d5ecb..bb534c7 100644 --- a/test/virtual-methods.cpp +++ b/test/virtual-methods.cpp @@ -19,7 +19,7 @@ class C : public B void other(void); }; -class D : public virtual C +class D : public C { public: virtual void RT method(void) {};