From d32855846d1d1ef16eea5e2ba752a7c61cab7b42 Mon Sep 17 00:00:00 2001 From: "petro.zarytskyi" Date: Sat, 18 Nov 2023 15:35:37 +0200 Subject: [PATCH] Do not assign VarData to `this` in static methods. --- lib/Differentiator/TBRAnalyzer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Differentiator/TBRAnalyzer.cpp b/lib/Differentiator/TBRAnalyzer.cpp index 3b1612e8b..833a8a450 100644 --- a/lib/Differentiator/TBRAnalyzer.cpp +++ b/lib/Differentiator/TBRAnalyzer.cpp @@ -327,11 +327,12 @@ void TBRAnalyzer::Analyze(const FunctionDecl* FD) { curBlockID = entry->getBlockID(); blockData[curBlockID] = std::unique_ptr(new VarsData()); - /// If we are analysing a method, add a VarData for 'this' pointer + /// If we are analysing a non-static method, add a VarData for 'this' pointer /// (it is represented with nullptr). - if (isa(FD)) { + const auto* MD = dyn_cast(FD); + if (MD && !MD->isStatic()) { const Type* recordType = - dyn_cast(FD->getParent())->getTypeForDecl(); + MD->getParent()->getTypeForDecl(); getCurBlockVarsData()[nullptr] = VarData(QualType::getFromOpaquePtr(recordType)); }