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



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to