[cfe-dev] Status of constexpr

Peter Collingbourne peter at pcc.me.uk
Wed May 11 13:19:07 PDT 2011


On Tue, May 10, 2011 at 07:16:04PM -0700, Sean Hunt wrote:
> On 05/10/11 08:48, Peter Collingbourne wrote:
>> Hi Sean,
>>
>> I have been working on a constexpr branch recently, but I have been
>> really bad about getting my changes into trunk (mainly due to a lack
>> of time).  My branch is available here:
>>
>> http://git.pcc.me.uk/?p=~peter/clang.git;a=shortlog;h=refs/heads/constexpr
>>
>> The main problem is that some of the changes cause test regressions,
>> but there are some earlier changes (e.g. a literal type test) that we
>> should be able to commit.  Once I find some time I'll try to commit
>> some of this.
>>
>> Thanks,
>
> I'd like to take a look at it except that it's got some weird build  
> problems, possibly due to out of date.

Try r128978 of LLVM, that was the latest version of clang that I
merged from.

> You also have  
> include/clang/AST/StmtVisitor.inc in the repository, which is a no-no.

StmtVisitor.inc isn't a generated file, if that's what you're thinking.
StmtVisitor.inc contains the common implementation of StmtVisitor and
ConstStmtVisitor which I #include twice to define those two classes.
I guess the other way to do it would be to use a base class with
a template template parameter (e.g. below) which may be slightly
less ugly.

-----------------------------------------------------------------------
template <typename T> struct make_ptr {
  typedef T *type;
};

template <typename T> struct make_const_ptr {
  typedef const T *type;
};

template<template <typename> class Ptr, typename ImplClass,
         typename RetTy=void>
class StmtVisitorBase {
public:
  RetTy Visit(typename Ptr<Stmt>::type S) {
    ...
  }
  ...
};

template<typename ImplClass, typename RetTy=void>
class StmtVisitor
  : public StmtVisitorBase<make_ptr, ImplClass, RetTy> {};

template<typename ImplClass, typename RetTy=void>
class ConstStmtVisitor
  : public StmtVisitorBase<make_const_ptr, ImplClass, RetTy> {};
-----------------------------------------------------------------------

> Looking at the history, I also see that you have interspersed your SVN  
> history with your own rather than rebasing it. I'm not quite sure how  
> you managed that 

That is just a git merge from SVN trunk every so often.  Perhaps gitk
will show the commit graph more clearly.

> but it makes it almost impossible to deal with from a  
> git perspective - in order to do useful work on it, it would be  
> necessary to extract all the patches you've made and re-apply them on a  
> clean tree.

Well, it works for me in practice.  I just commit and merge when
necessary.  If I wanted to commit something from that branch to SVN
trunk then I use git cherry-pick and rebase if necessary.  This method
saves me from having to mess around with rewriting history until I
commit to trunk.

Thanks,
-- 
Peter



More information about the cfe-dev mailing list