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

Issue 688132 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Jul 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug


Participants' hotlists:
blink-rename


Sign in to add a comment

rewrite_to_chrome_style: windows: clang assert: Found node that is not in the parent map

Project Member Reported by lukasza@chromium.org, Feb 2 2017

Issue description

When trying to use rewrite_to_chrome_style on Windows, I get the following assert:

Assertion failed: !Parents.empty() && "Found node that is not in the parent map.", file D:\src\chromium\src\third_party\llvm\tools\clang\lib\ASTMatchers\ASTMatchFinder.cpp, line 671


Note - this bug is a continuation of the investigation that started in  https://crbug.com/674196#c3  and went on in the other bug until https://bugs.chromium.org/p/chromium/issues/detail?id=674196#c9.
 
So far I have narrowed down the repro to:

template<class... Ts> struct foo : _Arg_types<Ts...> { typedef int type_alias; };
template<class... Ts> struct foo<void(Ts...)> : _Arg_types<Ts...> { typedef type1 type_alias; };
template<class... Ts> struct foo<void(Ts...)> : _Arg_types<Ts...> { typedef type1 type_alias; };
template<class... Ts> struct foo<void(Ts...)> : _Arg_types<Ts...> { typedef type1 type_alias; };
template<class... Ts> struct foo<void(Ts...)> : _Arg_types<Ts...> { typedef type1 type_alias; };
template<class... Ts> struct foo<void(Ts...)> : _Arg_types<Ts...> { typedef type1 type_alias; };
template<class... Ts> struct foo<void(Ts...)> : _Arg_types<Ts...> { typedef type1 type_alias; };
template<class... Ts> struct foo<void(Ts...)> : _Arg_types<Ts...> { typedef type1 type_alias; };
template<class... Ts> struct foo<void(Ts...)> : _Arg_types<Ts...> { typedef type1 type_alias; };
template<class... Ts> struct foo<void(Ts...)> : _Arg_types<Ts...> { typedef type1 type_alias; };

template<class T>
struct add_const {
  typedef const T type;
};

namespace some_namespace {
  using ::other_namespace:: add_const;
}

template<class T>
using add_const_t = typename add_const<T>::type;

template<class T> inline
constexpr add_const_t<T>& as_const(T& v) { return v; }



Notes:
- I have trouble narrowing down further (i.e. removing any of the duplicated 9 lines will make the repro go away).
- The AST-related assert is hit despite the narrowed down repro resulting in compilation errors.
Maybe it's somehow due to delayed template parsing (cf eg https://chromium.googlesource.com/chromium/src/+/28c1b1099fb09782841d891ca43e83e71cd8dfc6)
Summary: rewrite_to_chrome_style: windows: clang assert: Found node that is not in the parent map (was: rewrite_to_chrome_style: windows: clang assert: Name is not a simple identifier)
RE: #c2

Thanks for the pointer - this does sounds quite promising.

Is there a way to quickly test this?  I tried adding -fno-delayed-template-parsing to compile_commands.json used by rewrite_to_chrome_style.exe, but (I guess expectedly, per  https://crbug.com/486571#c10 ) got back a warning: unknown argument ignored in clang-cl: '-fno-delayed-template-parsing'.

I guess another way to test this would be to try a similar fix for rewrite_to_chrome_style.exe, but I have a little bit of trouble figuring out how to hook it up:

1. There is clang::ast_matchers::internal::<anonymous>::MatchASTConsumer::HandleTranslationUnit that seems like a perfect place for duplicating the fix done by https://codereview.chromium.org/1140443005/patch/20001/30001 in tools/clang/blink_gc_plugin/BlinkGCPlugin.cpp.  The problem is that I don't see a way to grab a clang::CompilerInstance pointer from within MatchASTConsumer::HandleTranslationUnit (where I only have pointers to clang::ast_matchers::ASTMatchFinder and to clang::ASTContext - I looked at these 2 classes but they don't seem to offer an accessor for clang::CompilerInstance)

2. I guess I could try to modify RewriteToChromeStyle.cpp instead, which sees a CompilerInstance in SourceFileCallbacks, but I am not sure how to properly chain/glue together 2A) my hypothetical, new ASTConsumer and 2B) the old MatchASTConsumer.  Maybe I shouldn't worry about this too much, because MatchASTConsumer only needs forwarding of a single override - HandleTranslationUnit.  Hmmm... maybe this is what I should try next :-)
Cc: klimek@google.com
+klimek@ who might be interested in this bug around AST matchers
Cc: lukasza@chromium.org
Owner: ----
Status: Available (was: Started)
On second thought, I am not sure if the fix from  https://crbug.com/486571  would help here, because
1) here we are getting an assert when looking at AST node from a system header
2) the fix for the other bug explicitly tries to avoid processing of system headers (here: https://chromium.googlesource.com/chromium/src/+/06f6cd0653d33dc0e087cf3aede5df399ffc9db0/tools/clang/blink_gc_plugin/BlinkGCPluginConsumer.cpp#143)
klimek@, how much would you object to the idea of replacing the assert with a fallback:
   if (Parents.empty()) return false;
I guess having a unit/regression test would probably go a long way toward making this "fix" more acceptable for upstream clang.  FWIW, I am using this "fix" as a workaround to unblock myself and attempt to discover any other Windows-specific problems with running rewrite_to_chrome_style clang tool.
The assert has found lots of useful bugs that we fixed. I think it's a useful assert.
My understanding from thakis@ is that these represent real bugs in clang's AST representation.

For us to proceed, it's fine to patch out the check locally, but it's probably not something we want upstream.
Blocking: -674196
Status: WontFix (was: Available)
WontFix from us I think, unless someone wants to pick it up.

Sign in to add a comment