[PATCH] D56160: [clang-tidy] modernize-use-trailing-return check

Bernhard Manfred Gruber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 9 17:39:14 PST 2019


bernhardmgruber marked an inline comment as done.
bernhardmgruber added a comment.

I spent some time now to get member pointers as return values working and I am afraid but it seems there is a problem with the clang AST. Given the following code in my check (where `F` is a `FunctionDecl`):

  const TypeSourceInfo *TSI = F.getTypeSourceInfo();
  const FunctionTypeLoc FTL = TSI->getTypeLoc().IgnoreParens().getAs<FunctionTypeLoc>();
  auto rl = FTL.getReturnLoc();
  rl.getSourceRange().dump(SM);
  rl.getLocalSourceRange().dump(SM);
  rl.castAs<MemberPointerTypeLoc>().getSourceRange().dump(SM);
  rl.castAs<MemberPointerTypeLoc>().getLocalSourceRange().dump(SM);
  rl.castAs<MemberPointerTypeLoc>().getBeginLoc().dump(SM);
  rl.castAs<MemberPointerTypeLoc>().getStarLoc().dump(SM);

with the following input:

  namespace std {
      template <typename T>
      class vector;
  
      class string;
  }
  
  int std::vector<std::string>::* e6();
  }

yields these source locations:

  <...\aa.cpp:8:1, col:5>
  <...\aa.cpp:8:5>
  <...\aa.cpp:8:1, col:5>
  <...\aa.cpp:8:5>
  ...\aa.cpp:8:1
  ...\aa.cpp:8:5

The first is the value I usually obtain via `F.getReturnTypeSourceRange()`. The following lines are what I saw in my debugger when I stepped into the implementation. I believe that `getStarLoc()` should point at the asterisk at column 31, not at std at column 5.

I did not find an easy workaround and I would like to avoid manual lexing because of the interference with macros. For now, I will just disable the check for member pointers.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56160/new/

https://reviews.llvm.org/D56160





More information about the cfe-commits mailing list