Set the "implicitly inline" bit on a method as soon as we see a definition
within the class. Teach IR gen to look for function definitions in record
lexical contexts when deciding whether to emit a function whose address
was taken. Fixes PR8789.
llvm-svn: 121833
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 3506456..17a1a1ba 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3735,6 +3735,12 @@
NewFD->setAccess(AS_public);
}
+ if (isa<CXXMethodDecl>(NewFD) && DC == CurContext && IsFunctionDefinition) {
+ // A method is implicitly inline if it's defined in its class
+ // definition.
+ NewFD->setImplicitlyInline();
+ }
+
if (SC == SC_Static && isa<CXXMethodDecl>(NewFD) &&
!CurContext->isRecord()) {
// C++ [class.static]p1: