clang-import-test has until now been only able to report top-level entities. This is clearly insufficient; we should be able to look inside structs and namespaces also.
This patch adds new test cases for a variety of lookups inside existing entities, and adds the functionality necessary to make most of these testcases work.
One testcase is known to fail because of ASTImporter limitations when importing templates; this will be addressed separately.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
A few stylistic issues inline.
It also wouldn't hurt to document what is being tested, either in the clang-import-test sources or in the input files. Otherwise this looks fine. More tests are always great!
tools/clang-import-test/clang-import-test.cpp | ||
---|---|---|
213 | Sort of an irrelevant nitpick, but we don't typically use curly braces on single statements. | |
228 | -> // Couldn't find the name, so we have to give up. |
• Applied Adrian's suggestion to move comments before the line they apply to.
• Got to 100% coverage by changing a test and making an assert for something I couldn't make happen in a test.
I did not take Adrian's suggestion to remove braces around a single-statement if because (as far as I can tell) the LLVM coding standard is silent on the topic and I prefer to have the braces there.
Hello Sean,
It is good to have the ability of recursive lookup. But for me (and I'm sorry), the code becomes very hard to understand: I need to track if the Decl/DC is in the source AST or in the AST being imported, if it was imported or if was in the AST before across lambdas and calls. Can we make this more clear?
tools/clang-import-test/clang-import-test.cpp | ||
---|---|---|
201 | Can we make the usage of qualified and non-qualified casts consistent? Usually, casts are used as unqualified. | |
301 | I guess we can use SmallVectors here too. | |
306 | Nit: to make the code cleaner, we can extract this std::none_of to a separate function like IsFoundAsForward(). Nested lambdas are harder to read. | |
336 | The loop: Decls.reserve(DeclsToReport.size()); for (Candidate &C : DeclsToReport) Decls.push_back(cast<NamedDecl>(C.second->Import(C.first))); will look a bit nicer here. What do you think? |
• Removed namespace qualification of cast across the board.
• Standardized on SmallVector
• Factored out the filtering of forward declarations
• Fixed a loop as requested.
• Made a Origin<> wrapper for arbitrary AST objects that makes it clear where they live, so importation and searching gets a little clearer.
• Broke all the ASTImporter and ExternalASTSource subclassing logic into its own source file, with its API defined in AST/ExternalASTMerger.h.
• Cleaned up the API for LLDB's consumption: now rather than a CompilerInstance a client just has to provide an ASTContext and a FileManager (just like when setting up an ASTImporter). This allows e.g. DWARF to be a valid source.
Added the ExternalASTMerger implementation/interface, which I hadn't svn added before generating the last diff.
Can we make the usage of qualified and non-qualified casts consistent? Usually, casts are used as unqualified.