New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 682835 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Jan 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug

Blocking:
issue 578344



Sign in to add a comment

rewrite_to_chrome_style: blink::V8Document::openMethodCustom should not be renamed (b/c it has canonical method in generated code)

Project Member Reported by lukasza@chromium.org, Jan 19 2017

Issue description

../../third_party/WebKit/Source/bindings/core/v8/custom/V8DocumentCustom.cpp:56:18: error: out-of-line definition of 'OpenMethodCustom' does not match any declaration in 'blink::V8Document'; did you mean 'openMethodCustom'?
void V8Document::OpenMethodCustom(
                 ^~~~~~~~~~~~~~~~
                 openMethodCustom
gen/blink/bindings/core/v8/V8Document.h:49:15: note: 'openMethodCustom' declared here
  static void openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&);
              ^
 
Fix proposal @ https://crrev.com/2640283003.  This seems to help (i.e. before the fix the command below would see renaming of openMethodCustom, but this doesn't happen after the fix):

$ tools/clang/scripts/run_tool.py rewrite_to_chrome_style --generate-compdb out/gn third_party/WebKit/Source/bindings/core/v8/custom/V8DocumentCustom.cpp | grep MethodCustom

Before asking for CR of the fix, let me go through an automatic rename cycle to see if there are any obvious unintended consequences.
Labels: -Pri-3 Pri-2
It turns out that https://crrev.com/2640283003 regresses handling of function template specializations (|to| is not rewritten to |To| on lines 347, 352, 357, 361 below):

  343 template <unsigned long sizeOfValue>
  344 int toV8SignedIntegerInternal(long value);
  345
  346 template <>
  347 int toV8SignedIntegerInternal<4>(long value) {
  348   return 123 + value;
  349 }
  350
  351 template <>
  352 int toV8SignedIntegerInternal<8>(long value) {
  353   return 456 + value;
  354 }
  355
  356 int toV8(int value) {
  357   return toV8SignedIntegerInternal<sizeof value>(value);
  358 }
  359
  360 int toV8(long value) {
  361   return toV8SignedIntegerInternal<sizeof value>(value);
  362 }

I still have to investigate what is happening here.

Hypothesis 1: getCanonicalDecl does something weird for templates
Hypothesis 2: using getCanonicalDecl messes up which AST node gets bound to "decl" id
FWIW, the skipped / not renamed decl looks as follows:

FunctionDecl 0x400a2f0 prev 0x400a5a0 </usr/local/google/home/lukasza/src/chromium4/src/tools/clang/rewrite_to_chrome_style/tests/template-actual.cc:8:1, line:11:1> line:9:5 used toV8SignedIntegerInternal 'int (long)'
|-TemplateArgument integral 4
|-ParmVarDecl 0x400a260 <col:34, col:39> col:39 used value 'long'
`-CompoundStmt 0x400a7e8 <col:46, line:11:1>
  `-ReturnStmt 0x400a7d0 <line:10:3, col:16>
    `-ImplicitCastExpr 0x400a7b8 <col:10, col:16> 'int' <IntegralCast>
      `-BinaryOperator 0x400a790 <col:10, col:16> 'long' '+'
        |-ImplicitCastExpr 0x400a778 <col:10> 'long' <IntegralCast>
        | `-IntegerLiteral 0x400a718 <col:10> 'int' 123
        `-ImplicitCastExpr 0x400a760 <col:16> 'long' <LValueToRValue>
          `-DeclRefExpr 0x400a738 <col:16> 'long' lvalue ParmVar 0x400a260 'value' 'long'

And its canonical decl is:

FunctionDecl 0x400a5a0 </usr/local/google/home/lukasza/src/chromium4/src/tools/clang/rewrite_to_chrome_style/tests/template-actual.cc:6:1, col:41> line:9:5 used toV8SignedIntegerInternal 'int (long)'
|-TemplateArgument integral 4
`-ParmVarDecl 0x400a510 <line:6:31, col:36> col:36 value 'long'

I think I will proceed with only applying hasCanonicalDecl matcher to detection of generated files, and keep using the main decl under consideration with |decl_under_blink_namespace|.  This approach passes unit tests and seems to work fine with the big rename as well.  OTOH, let me take a closer look at the remaining errors after the big rename.
Status: Fixed (was: Started)
This should be fixed by r445466.

Sign in to add a comment