[PATCH] D32439: Fix for incorrect source position of dependent c'tor initializer (bug:26195)

Serge Preis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 25 05:11:47 PDT 2017


Serge_Preis added a comment.

In https://reviews.llvm.org/D32439#736503, @malcolm.parsons wrote:

> Is it possible to add a test for this change?
>  There are some source range checks in test/Misc/ast-dump-decl.cpp


I looked into test/Misc/ast-dump-decl.cpp and other tests around, but they all use -ast-dump which doesn't dump source locations of affected entities (at least for problematic codes I've got). The only tool that exposed the difference is c-index-test -test-load-source all bug.cpp
bug.cpp:

  template<typename MyBase>
  struct Derived:  MyBase::InnerIterator
  {
      Derived() : MyBase::InnerIterator() {}
  };

Bad (trunk) has:

  // CHECK: bug.cpp:4:25: TypeRef=MyBase:1:19 Extent=[4:25 - 4:38]

Good (patched) has:

  // CHECK: bug.cpp:4:17: TypeRef=MyBase:1:19 Extent=[4:17 - 4:23]

I am new to clang development, but think that this difference can be exploited to craft proper test.

Something like:

  // RUN: c-index-test -test-load-source all %s | FileCheck %s
  template<typename MyBase>
  struct Derived:  MyBase::InnerIterator
  {
      Derived() : MyBase::InnerIterator() {}
  // CHECK:  TypeRef=MyBase:1:19 Extent=[4:17 - 4:23]
  };

What do you think? 
I may add some other cases similar to this to the test including other variants of dependent and independent names.


https://reviews.llvm.org/D32439





More information about the cfe-commits mailing list