[llvm-commits] [PATCH] YAML I/O

Nick Kledzik kledzik at apple.com
Thu Sep 13 15:58:50 PDT 2012


I have the traits based approach working for C++11.   I have a way to get it 
working for C++03, but it uses the typeof() (aka __typeof__()) language extension.  
It that extension legal in the LLVM code base?  It is used in one place
in lib/Support/Unix/Program.inc.  But that might be ok because that file
is  only compile by gcc or clang??

I need a way to test if a class implements a particular method with particular parameters.

template <class T>
struct has_scalar_trait
{
private:
  struct two {char _[2];};
  static two test(...);
  template <class U, class X> 
  static __typeof__(U::doScalar(declval<class IO&>(), declval<X&>()), char()) test(U& u, X& x);
public:
  static const bool value = (sizeof(test(declval<ScalarTrait<T>&>(), declval<T&>())) == 1);
};


-Nick

On Aug 28, 2012, at 9:28 AM, Sean Silva wrote:
>> This format is the most compact.  It is also the format that is easiest for
>> YAML I/O to validate, since the legal keys at any point are well defined.
>> What is lost though, is the original order of shapes.  For lld, that does
>> not matter.  In fact the lld::File model does not have one list of all
>> Atoms.  It already has four lists.  One for each Atom kind.
> 
> Ok, this seems satisfactory. I think it's important though that there
> actually be an order here, for the sake of testing. E.g. it could be
> that the keys are output in alphabetical order.
> 
> --Sean Silva




More information about the llvm-commits mailing list