Fix regression introduced by r279164: only pass definitions as the PatternDef
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 23 Aug 2016 19:41:39 +0000 (19:41 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 23 Aug 2016 19:41:39 +0000 (19:41 +0000)
commit6f4e2e038d5e72f8860512502c2ba72882eb0f75
treead99b28220111579f6866e80c0212880df45c468
parentfd49c73f116d3748e2d4f768128ac33247d375a3
Fix regression introduced by r279164: only pass definitions as the PatternDef
to DiagnoseUninstantiableTemplate, teach hasVisibleDefinition to correctly
determine whether a function definition is visible, and mark both the function
and the template as visible when merging function template definitions to
provide hasVisibleDefinition with the relevant information.

The change to always pass the right declaration as the PatternDef to
DiagnoseUninstantiableTemplate also caused those checks to happen before other
diagnostics in InstantiateFunctionDefinition, giving worse diagnostics for the
same situations, so I sunk the relevant diagnostics into
DiagnoseUninstantiableTemplate. Those parts of this patch are based on changes
in reviews.llvm.org/D23492 by Vassil Vassilev.

This reinstates r279486, reverted in r279500, with a fix to
DiagnoseUninstantiableTemplate to only mark uninstantiable explicit
instantiation declarations as invalid if we actually diagnosed them. (When we
trigger an explicit instantiation of a class member from an explicit
instantiation declaration for the class, it's OK if there is no corresponding
definition and we certainly don't want to mark the member invalid in that
case.) This previously caused a build failure during bootstrap.

llvm-svn: 279557
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Sema/SemaType.cpp
clang/test/Modules/Inputs/merge-template-pattern-visibility/a.h
clang/test/Modules/Inputs/merge-template-pattern-visibility/b.h
clang/test/Modules/merge-template-pattern-visibility.cpp