[Sema] Maintain ellipsis location when transforming lambda captures
authorMeador Inge <meadori@codesourcery.com>
Fri, 26 Jun 2015 00:09:55 +0000 (00:09 +0000)
committerMeador Inge <meadori@codesourcery.com>
Fri, 26 Jun 2015 00:09:55 +0000 (00:09 +0000)
commit4f9dee7511473c86b8e22f76dfc6ed569314e017
tree03f2172741713f6f619c7ad65ec1c857276d5dc9
parent459a23e0a3f076515b5dbfd0a33273d20d6a60f0
[Sema] Maintain ellipsis location when transforming lambda captures

This patch fixes a crash caused by the following case:

  template<typename T>
  auto f(T x) {
    auto g = [](auto ... args) {
      auto h = [args...]() -> int {
        return 0;
      };
      return h;
    };
    return g;
  }

  auto x = f(0)();

When the templated function 'f' is instantiated and the inner-most
lambda is transformed the ellipsis location on the captured variable
is lost.  Then the lambda returned by 'f' is instantiated and the
tree transformer chokes on the invalid ellipsis location.  The
problem is fixed by making a minor change to properly track the
ellipsis location.

This fixes PR23716.

Differential Revision: http://reviews.llvm.org/D10590

llvm-svn: 240740
clang/lib/Sema/TreeTransform.h
clang/test/SemaCXX/cxx1y-generic-lambdas.cpp