return getBody(Definition);
}
- /// isThisDeclarationADefinition - Returns whether this specific
- /// declaration of the function is also a definition. This does not
- /// determine whether the function has been defined (e.g., in a
- /// previous definition); for that information, use isDefined. Note
- /// that this returns false for a defaulted function unless that function
- /// has been implicitly defined (possibly as deleted).
+ /// Returns whether this specific declaration of the function is also a
+ /// definition that does not contain uninstantiated body.
+ ///
+ /// This does not determine whether the function has been defined (e.g., in a
+ /// previous definition); for that information, use isDefined.
+ ///
bool isThisDeclarationADefinition() const {
- return IsDeleted || Body || IsLateTemplateParsed;
+ return IsDeleted || IsDefaulted || Body || IsLateTemplateParsed ||
+ hasDefiningAttr();
}
/// doesThisDeclarationHaveABody - Returns whether this specific
bool FunctionDecl::isDefined(const FunctionDecl *&Definition) const {
for (auto I : redecls()) {
- if (I->IsDeleted || I->IsDefaulted || I->Body || I->IsLateTemplateParsed ||
- I->hasDefiningAttr()) {
- Definition = I->IsDeleted ? I->getCanonicalDecl() : I;
+ if (I->isThisDeclarationADefinition()) {
+ Definition = I;
return true;
}
}
};
struct DefaultDelete {
- DefaultDelete() = default; // expected-note {{previous declaration is here}}
+ DefaultDelete() = default; // expected-note {{previous definition is here}}
DefaultDelete() = delete; // expected-error {{constructor cannot be redeclared}}
- ~DefaultDelete() = default; // expected-note {{previous declaration is here}}
+ ~DefaultDelete() = default; // expected-note {{previous definition is here}}
~DefaultDelete() = delete; // expected-error {{destructor cannot be redeclared}}
- DefaultDelete &operator=(const DefaultDelete &) = default; // expected-note {{previous declaration is here}}
+ DefaultDelete &operator=(const DefaultDelete &) = default; // expected-note {{previous definition is here}}
DefaultDelete &operator=(const DefaultDelete &) = delete; // expected-error {{class member cannot be redeclared}}
};