Skip to content

Commit

Permalink
Always use valid location when generating operators
Browse files Browse the repository at this point in the history
  • Loading branch information
PetroZarytskyi committed Oct 23, 2024
1 parent 4a1749d commit 70fcedc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Differentiator/VisitorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,19 @@ namespace clad {
SourceLocation OpLoc) {
if (!E)
return nullptr;
// Debug clang requires the location to be valid
if (!OpLoc.isValid())
OpLoc = utils::GetValidSLoc(m_Sema);
return m_Sema.BuildUnaryOp(nullptr, OpLoc, OpCode, E).get();
}

Expr* VisitorBase::BuildOp(clang::BinaryOperatorKind OpCode, Expr* L, Expr* R,
SourceLocation OpLoc) {
if (!L || !R)
return nullptr;
// Debug clang requires the location to be valid
if (!OpLoc.isValid())
OpLoc = utils::GetValidSLoc(m_Sema);
return m_Sema.BuildBinOp(nullptr, OpLoc, OpCode, L, R).get();
}

Expand Down

0 comments on commit 70fcedc

Please sign in to comment.