[cfe-commits] r165769 - /cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h

Abramo Bagnara abramo.bagnara at bugseng.com
Fri Oct 12 00:31:33 PDT 2012

Il 12/10/2012 04:31, Sean Silva ha scritto:
>> Stupid attempt:
>> struct A { void f(); };
>> struct B : A {
>> #ifdef B_HAS_F
>>   void f();
>> #endif
>> };
>> decltype(&B::f) x;
>> extern void (B::*x)(); // error unless B_HAS_F
>> Unfortunately, not a complete solution, because you don't know the
>> precise signature of the classof you're looking for.
> Thanks! (there's a typedef needed before the decltype, right?)
> Could this be made workable if we know that the classof() has the signature
>     static bool classof(const T *);
> where T is strictly is_base_of the enclosing class?

The trick does not work for static methods. Can you use non-static ones?

> Also, is it possible to do without the decltype?

You can use

template <typename T, T x>
struct has_type;

to check if B::f is indeed a void (B::*)()

Abramo Bagnara

BUGSENG srl - http://bugseng.com
mailto:abramo.bagnara at bugseng.com

More information about the cfe-commits mailing list