diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-06-28 01:07:28 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-06-28 01:07:28 +0000 |
| commit | 0b70de15ac5c9eafae6122c2a53c5aef0d83af09 (patch) | |
| tree | 0eb7279cf5b3a33dc7eea7550b71d6d934e3e5bc /clang/lib/Serialization | |
| parent | ab70f58891eb33615c97f3bd73954335119730d8 (diff) | |
| download | bcm5719-llvm-0b70de15ac5c9eafae6122c2a53c5aef0d83af09.tar.gz bcm5719-llvm-0b70de15ac5c9eafae6122c2a53c5aef0d83af09.zip | |
[modules] Ensure that an in-class function definition is attached to the
declaration of the function that ends up in the primary definition of
the class.
... at least for class templates. This is necessary for us to be able to
track when an inline friend function has a definition that needs to be
(lazily) instantiated.
llvm-svn: 335805
Diffstat (limited to 'clang/lib/Serialization')
| -rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 982c4cbee88..9287ffd3d6e 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -9356,6 +9356,19 @@ void ASTReader::finishPendingActions() { PBEnd = PendingBodies.end(); PB != PBEnd; ++PB) { if (FunctionDecl *FD = dyn_cast<FunctionDecl>(PB->first)) { + // For a function defined inline within a class template, force the + // canonical definition to be the one inside the canonical definition of + // the template. This ensures that we instantiate from a correct view + // of the template. + // + // Sadly we can't do this more generally: we can't be sure that all + // copies of an arbitrary class definition will have the same members + // defined (eg, some member functions may not be instantiated, and some + // special members may or may not have been implicitly defined). + if (auto *RD = dyn_cast<CXXRecordDecl>(FD->getLexicalParent())) + if (RD->isDependentContext() && !RD->isThisDeclarationADefinition()) + continue; + // FIXME: Check for =delete/=default? // FIXME: Complain about ODR violations here? const FunctionDecl *Defn = nullptr; |

