[cfe-users] RecursiveASTVisitor won't visit all declarations in the AST

2019-01-31 Thread Teodor Dermendzhiev via cfe-users
Hi all,
I am having problems walking through the syntax tree of a simple header file. 
With llvm 4.0.1 everything works as expected but after upgrading to 7.0.0 I 
notice that just a small number of all declarations in the AST are being 
visited.


Running a simple ASTFrontendAction (like the one from this article - 
https://clang.llvm.org/docs/RAVFrontendAction.html ) in HandleTranslationUnit() 
-


virtual void HandleTranslationUnit(ASTContext &Context) {
Decl* tu = Context.getTranslationUnitDecl();
Visitor.TraverseDecl(tu);
}

when I dump the *tu* variable I get a lot smaller dump with 7.0.0. After 
investigating further I updated TraverseDeclContextHelper() method in order to 
print the size of decls() container for every DeclContext we visit:

template 
bool RecursiveASTVisitor::TraverseDeclContextHelper(DeclContext *DC) {
  if (!DC)
return true;

  int childSize = 0; // my code

  for (auto *Child : DC->decls()) {
childSize++; // my code
if (!canIgnoreChildDeclWhileTraversingDeclContext(Child))
TRY_TO(TraverseDecl(Child));
  }

  std::cout << DC->getDeclKindName() << ": " << childSize << " child 
declarations" << "\n"; //my code

  return true;
}

With llvm 4.0.0 I get:
TranslationUnit: 20526 child declarations

while with 7.0.0:
TranslationUnit: 486 child declarations

I created a sample project that illustrates this behavior - 
https://github.com/tdermendjiev/clang-samples .

Any help tackling this issue is appreciated. Thank you.

Best wishes,
Teodor Dermendzhiev

___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] why is lldb unable to debug any gcc -O$n compiled code, what can be done about it

2019-01-31 Thread Jason Vas Dias via cfe-users
Good day -
  I have to use a MacOSX 10.14.3 (mojave) laptop for work,
  and am having issues adjusting after having used mostly
  Linux and UNIX over the past 20 years.

  Chief among them is the inability to debug any code I build -
  which usually is optimized in some way with a -O[0-3] gcc
  flag. I use mainly MacPorts' GCC 8.2.0 .

  With any -O optimization flag given to gcc / g++ ,
  { -O , -O1, -O2, -O3 ...}, and any '-g' flag (-g , -g3)
  any attempt to examine data in a debugged process
  with lldb results in the lldb error :
" (lldb) p any_symbol
Warning: hit breakpoint while running function, skipping commands and
conditions to prevent recursion.warning: could not execute support
code to read Objective-C class data in the process. This may reduce
the quality of type information available.
Process 19062 exited with status = 0 (0x)
error: Couldn't materialize: couldn't get the value of any_symbol:
extracting data from value failed
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression
"

  If  ALL  code in the process is compiled without ANY -O flags,
  then lldb is able to set breakpoints and examine data OK.
  But this is a very unrealistic - most code should be and is
  compiled with optimizations.  Optimized code is very
  different than non-optimized - an optimized version
  of a program is a different program .  I need to be
  able to debug core dumps from other users, and
  since they invariably contain optimized code, lldb
  is of no use for this purpose.

  So, I am trying to set up a Linux VM to do most of
  my development on,  purely because of this issue -
  the MacOSX laptop is effectively useless to me
  because of this issue.

  GDB also may have some issues with debugging
  heavily optimized code, it may get things wrong
  sometimes for -O3 compiled code, but it least
  it gets much farther than lldb , which cannot
  get off the ground at all with an optimized process.

  Is there any workaround for this issue / any
  special debugging format I could use to
  get lldb on MacOSX to be able to debug
  optimized code ?

  Any advice much appreciated.

Thanks & Best Regards,
Jason Vas Dias
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users