Disable recognition of "using" declarations at translation-unit level.

Currently CountDeclLevels uses the ASTs which have no distinction between
separate translation units.  If one .o file has a "using" declaration at
translation unit level, that "using" declaration will be in the same translation
unit as functions from other .o files in the same module.  This leads to
erroneous name conflicts as the CountDeclLevels-based function filtering logic
accepts too many fucntions.

In the future we will identify the translation units for top-level Decls more
reliably and restore that functionality.  There's a TODO to that effect in the
code.

llvm-svn: 260747
This commit is contained in:
Sean Callanan 2016-02-12 21:55:05 +00:00
parent 876330d53a
commit 8c05fb9fff
1 changed files with 9 additions and 0 deletions

View File

@ -9926,6 +9926,15 @@ ClangASTContext::CountDeclLevels (clang::DeclContext *frame_decl_ctx,
{ {
if (searched.find(it->second) != searched.end()) if (searched.find(it->second) != searched.end())
continue; continue;
// Currently DWARF has one shared translation unit for all Decls at top level, so this
// would erroneously find using statements anywhere. So don't look at the top-level
// translation unit.
// TODO fix this and add a testcase that depends on it.
if (llvm::isa<clang::TranslationUnitDecl>(it->second))
continue;
searched.insert(it->second); searched.insert(it->second);
symbol_file->ParseDeclsForContext(CompilerDeclContext(this, it->second)); symbol_file->ParseDeclsForContext(CompilerDeclContext(this, it->second));