diff --git a/lib/Differentiator/VisitorBase.cpp b/lib/Differentiator/VisitorBase.cpp index 63ae3c369..db191134d 100644 --- a/lib/Differentiator/VisitorBase.cpp +++ b/lib/Differentiator/VisitorBase.cpp @@ -392,6 +392,9 @@ 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(); } @@ -399,6 +402,9 @@ namespace clad { 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(); }