forked from OSchip/llvm-project
[analyzer][NFCi] Mark CallEvent::getOriginExpr virtual, some cleanup
Previously we just shadowed the original implementation with a virtual declaration - which is really bugprone in a long run. This patch marks `CallEvent::getOriginExpr` virtual to let subclasses override it's behavior. At the same time, I checked all virtual functions of this class hierarchy to make sure we don't suffer from this elsewhere. Removes redundant declarations of `virtual` if `override` is already present. In theory, this patch is a functional change, but no tests were broken. I suspect that there were no meaningful changes in behavior in the subclasses compared to the shadowed `CallEvent::getOriginExpr`. That being said, I had a hard time coming up with unit-tests covering this. Motivation: https://reviews.llvm.org/D74735#2370909 Reviewed By: NoQ Differential Revision: https://reviews.llvm.org/D90754
This commit is contained in:
parent
7efe07a12b
commit
aa0dc1c3b8
|
@ -225,7 +225,7 @@ public:
|
|||
|
||||
/// Returns the expression whose value will be the result of this call.
|
||||
/// May be null.
|
||||
const Expr *getOriginExpr() const {
|
||||
virtual const Expr *getOriginExpr() const {
|
||||
return Origin.dyn_cast<const Expr *>();
|
||||
}
|
||||
|
||||
|
@ -530,7 +530,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
virtual const CallExpr *getOriginExpr() const {
|
||||
const CallExpr *getOriginExpr() const override {
|
||||
return cast<CallExpr>(AnyFunctionCall::getOriginExpr());
|
||||
}
|
||||
|
||||
|
@ -543,9 +543,7 @@ public:
|
|||
}
|
||||
|
||||
Kind getKind() const override { return CE_Function; }
|
||||
virtual StringRef getKindAsString() const override {
|
||||
return "SimpleFunctionCall";
|
||||
}
|
||||
StringRef getKindAsString() const override { return "SimpleFunctionCall"; }
|
||||
|
||||
static bool classof(const CallEvent *CA) {
|
||||
return CA->getKind() == CE_Function;
|
||||
|
@ -570,7 +568,7 @@ protected:
|
|||
RegionAndSymbolInvalidationTraits *ETraits) const override;
|
||||
|
||||
public:
|
||||
virtual const CallExpr *getOriginExpr() const {
|
||||
const CallExpr *getOriginExpr() const override {
|
||||
return cast<CallExpr>(CallEvent::getOriginExpr());
|
||||
}
|
||||
|
||||
|
@ -653,7 +651,7 @@ public:
|
|||
ArrayRef<ParmVarDecl *> parameters() const override;
|
||||
|
||||
Kind getKind() const override { return CE_Block; }
|
||||
virtual StringRef getKindAsString() const override { return "BlockCall"; }
|
||||
StringRef getKindAsString() const override { return "BlockCall"; }
|
||||
|
||||
static bool classof(const CallEvent *CA) { return CA->getKind() == CE_Block; }
|
||||
};
|
||||
|
@ -708,7 +706,7 @@ protected:
|
|||
void cloneTo(void *Dest) const override { new (Dest) CXXMemberCall(*this); }
|
||||
|
||||
public:
|
||||
virtual const CXXMemberCallExpr *getOriginExpr() const {
|
||||
const CXXMemberCallExpr *getOriginExpr() const override {
|
||||
return cast<CXXMemberCallExpr>(CXXInstanceCall::getOriginExpr());
|
||||
}
|
||||
|
||||
|
@ -727,7 +725,7 @@ public:
|
|||
RuntimeDefinition getRuntimeDefinition() const override;
|
||||
|
||||
Kind getKind() const override { return CE_CXXMember; }
|
||||
virtual StringRef getKindAsString() const override { return "CXXMemberCall"; }
|
||||
StringRef getKindAsString() const override { return "CXXMemberCall"; }
|
||||
|
||||
static bool classof(const CallEvent *CA) {
|
||||
return CA->getKind() == CE_CXXMember;
|
||||
|
@ -752,7 +750,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
virtual const CXXOperatorCallExpr *getOriginExpr() const {
|
||||
const CXXOperatorCallExpr *getOriginExpr() const override {
|
||||
return cast<CXXOperatorCallExpr>(CXXInstanceCall::getOriginExpr());
|
||||
}
|
||||
|
||||
|
@ -767,9 +765,7 @@ public:
|
|||
const Expr *getCXXThisExpr() const override;
|
||||
|
||||
Kind getKind() const override { return CE_CXXMemberOperator; }
|
||||
virtual StringRef getKindAsString() const override {
|
||||
return "CXXMemberOperatorCall";
|
||||
}
|
||||
StringRef getKindAsString() const override { return "CXXMemberOperatorCall"; }
|
||||
|
||||
static bool classof(const CallEvent *CA) {
|
||||
return CA->getKind() == CE_CXXMemberOperator;
|
||||
|
@ -838,9 +834,7 @@ public:
|
|||
}
|
||||
|
||||
Kind getKind() const override { return CE_CXXDestructor; }
|
||||
virtual StringRef getKindAsString() const override {
|
||||
return "CXXDestructorCall";
|
||||
}
|
||||
StringRef getKindAsString() const override { return "CXXDestructorCall"; }
|
||||
|
||||
static bool classof(const CallEvent *CA) {
|
||||
return CA->getKind() == CE_CXXDestructor;
|
||||
|
@ -898,7 +892,7 @@ protected:
|
|||
void cloneTo(void *Dest) const override { new (Dest) CXXConstructorCall(*this); }
|
||||
|
||||
public:
|
||||
virtual const CXXConstructExpr *getOriginExpr() const {
|
||||
const CXXConstructExpr *getOriginExpr() const override {
|
||||
return cast<CXXConstructExpr>(AnyFunctionCall::getOriginExpr());
|
||||
}
|
||||
|
||||
|
@ -913,9 +907,7 @@ public:
|
|||
}
|
||||
|
||||
Kind getKind() const override { return CE_CXXConstructor; }
|
||||
virtual StringRef getKindAsString() const override {
|
||||
return "CXXConstructorCall";
|
||||
}
|
||||
StringRef getKindAsString() const override { return "CXXConstructorCall"; }
|
||||
|
||||
static bool classof(const CallEvent *CA) {
|
||||
return CA->getKind() == CE_CXXConstructor;
|
||||
|
@ -959,7 +951,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
virtual const CXXInheritedCtorInitExpr *getOriginExpr() const {
|
||||
const CXXInheritedCtorInitExpr *getOriginExpr() const override {
|
||||
return cast<CXXInheritedCtorInitExpr>(AnyFunctionCall::getOriginExpr());
|
||||
}
|
||||
|
||||
|
@ -986,14 +978,14 @@ public:
|
|||
return getInheritingConstructor()->getArg(Index);
|
||||
}
|
||||
|
||||
virtual SVal getArgSVal(unsigned Index) const override {
|
||||
SVal getArgSVal(unsigned Index) const override {
|
||||
return getState()->getSVal(
|
||||
getArgExpr(Index),
|
||||
getInheritingStackFrame()->getParent()->getStackFrame());
|
||||
}
|
||||
|
||||
Kind getKind() const override { return CE_CXXInheritedConstructor; }
|
||||
virtual StringRef getKindAsString() const override {
|
||||
StringRef getKindAsString() const override {
|
||||
return "CXXInheritedConstructorCall";
|
||||
}
|
||||
|
||||
|
@ -1017,7 +1009,7 @@ protected:
|
|||
void cloneTo(void *Dest) const override { new (Dest) CXXAllocatorCall(*this); }
|
||||
|
||||
public:
|
||||
virtual const CXXNewExpr *getOriginExpr() const {
|
||||
const CXXNewExpr *getOriginExpr() const override {
|
||||
return cast<CXXNewExpr>(AnyFunctionCall::getOriginExpr());
|
||||
}
|
||||
|
||||
|
@ -1058,9 +1050,7 @@ public:
|
|||
}
|
||||
|
||||
Kind getKind() const override { return CE_CXXAllocator; }
|
||||
virtual StringRef getKindAsString() const override {
|
||||
return "CXXAllocatorCall";
|
||||
}
|
||||
StringRef getKindAsString() const override { return "CXXAllocatorCall"; }
|
||||
|
||||
static bool classof(const CallEvent *CE) {
|
||||
return CE->getKind() == CE_CXXAllocator;
|
||||
|
@ -1091,7 +1081,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
virtual const CXXDeleteExpr *getOriginExpr() const {
|
||||
const CXXDeleteExpr *getOriginExpr() const override {
|
||||
return cast<CXXDeleteExpr>(AnyFunctionCall::getOriginExpr());
|
||||
}
|
||||
|
||||
|
@ -1107,9 +1097,7 @@ public:
|
|||
}
|
||||
|
||||
Kind getKind() const override { return CE_CXXDeallocator; }
|
||||
virtual StringRef getKindAsString() const override {
|
||||
return "CXXDeallocatorCall";
|
||||
}
|
||||
StringRef getKindAsString() const override { return "CXXDeallocatorCall"; }
|
||||
|
||||
static bool classof(const CallEvent *CE) {
|
||||
return CE->getKind() == CE_CXXDeallocator;
|
||||
|
@ -1153,7 +1141,7 @@ protected:
|
|||
Selector Sel) const;
|
||||
|
||||
public:
|
||||
virtual const ObjCMessageExpr *getOriginExpr() const {
|
||||
const ObjCMessageExpr *getOriginExpr() const override {
|
||||
return cast<ObjCMessageExpr>(CallEvent::getOriginExpr());
|
||||
}
|
||||
|
||||
|
@ -1230,9 +1218,7 @@ public:
|
|||
ArrayRef<ParmVarDecl*> parameters() const override;
|
||||
|
||||
Kind getKind() const override { return CE_ObjCMessage; }
|
||||
virtual StringRef getKindAsString() const override {
|
||||
return "ObjCMethodCall";
|
||||
}
|
||||
StringRef getKindAsString() const override { return "ObjCMethodCall"; }
|
||||
|
||||
static bool classof(const CallEvent *CA) {
|
||||
return CA->getKind() == CE_ObjCMessage;
|
||||
|
|
Loading…
Reference in New Issue