[cfe-dev] Disabling the automatic method renaming when performing error recovery

Alex L via cfe-dev cfe-dev at lists.llvm.org
Fri Sep 30 10:01:59 PDT 2016


Hello,

Consider the following example:

  class Foo {
    int* create_process(int pid, const char* name);
  };

  int *Foo::create_process2(int pid, const char* name) {
    return 0;
  }

If I run '-ast-dump' on the example above, clang dumps the AST with the
method create_process2 renamed to create_process:

`-CXXMethodDecl 0x7f90ca07ccd0 parent 0x7f90ca07c050 prev 0x7f90ca07c398
<line:5:1, line:7:1> line:5:11 create_process 'int *(int, const char *)'
  |-ParmVarDecl 0x7f90ca07c480 <col:27, col:31> col:31 pid 'int'
  |-ParmVarDecl 0x7f90ca07c4f0 <col:36, col:48> col:48 name 'const char *'
  `-CompoundStmt 0x7f90ca800dc0 <col:54, line:7:1>
    `-ReturnStmt 0x7f90ca800da8 <line:6:3, col:10>
      `-ImplicitCastExpr 0x7f90ca800d90 <col:10> 'int *' <NullToPointer>
        `-IntegerLiteral 0x7f90ca800d70 <col:10> 'int' 0

This happens due to automatic renaming when recovering from this error:
"out-of-line definition of 'create_process2' does not match any declaration
in 'Foo'; did you mean 'create_process'?".

I would like clang to parse the example without performing this automatic
rename, i.e. create_process2 should keep its original name (or at least it
should know that it was renamed to create_process and that the original
name was create_process2). Is there a command line option that disables
this kind of renaming, or is there any other way to determine that such a
rename has occurred?

Thanks,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160930/9719ee47/attachment.html>


More information about the cfe-dev mailing list