Add ability to import std module into expression parser to improve C++ debugging

Authored by teemperor on Mar 12 2019, 10:09 AM.


Add ability to import std module into expression parser to improve C++ debugging

This patch is the MVP version of importing the std module into the expression parser to improve C++ debugging.

What happens in this patch is that we inject a @import std into our expression source code. We also
modify our internal Clang instance for parsing this expression to work with modules and debug info
at the same time (which is the main change in terms of LOC). We implicitly build the std module on the first use. The
C++ include paths for building are extracted from the debug info, which means that this currently only
works if the program is compiled with -glldb -fmodules and uses the std module. The C include paths
are currently specified by LLDB.

I enabled the tests currently only for libc++ and Linux because I could test this locally. I'll enable the tests
for other platforms once this has landed and doesn't break any bots (and I implemented the platform-specific
C include paths for them).

With this patch we can now:

  • Build a libc++ as a module and import it into the expression parser.
  • Read from the module while also referencing declarations from the debug info. E.g. std::abs(local_variable).

What doesn't work (yet):

  • Merging debug info and C++ module declarations. E.g. std::vector<CustomClass> doesn't work.
  • Pretty much anything that involves the ASTImporter and templated code. As the ASTImporter is used for saving the result declaration, this means that we can't

call yet any function that returns a non-trivial type.

  • Use libstdc++ for this, as it requires multiple include paths and Clang only emits one include path per module. Also libstdc++ doesn't support Clang modules without patches.

Reviewers: aprantl, jingham, shafik, friss, davide, serge-sans-paille

Reviewed By: aprantl

Subscribers: labath, mgorny, abidh, jdoerfert, lldb-commits

Tags: #c_modules_in_lldb, #lldb

Differential Revision: https://reviews.llvm.org/D58125

llvm-svn: 355939