From 997c8f9fcf94ae9708ecbac916fc032c6357f8ab Mon Sep 17 00:00:00 2001 From: PetroZarytskyi <119341518+PetroZarytskyi@users.noreply.github.com> Date: Wed, 13 Nov 2024 18:51:11 +0100 Subject: [PATCH] Always use valid location when generating operators (#1137) A valid location is required by the debug clang. Partially addresses #428. --- lib/Differentiator/VisitorBase.cpp | 6 ++++++ test/Arrays/ArrayInputsVectorForwardMode.C | 2 -- test/ForwardMode/VectorMode.C | 2 -- test/ForwardMode/VectorModeInterface.C | 2 -- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Differentiator/VisitorBase.cpp b/lib/Differentiator/VisitorBase.cpp index e8fce3628..0e6453625 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(); } diff --git a/test/Arrays/ArrayInputsVectorForwardMode.C b/test/Arrays/ArrayInputsVectorForwardMode.C index af913241a..4068d91e6 100644 --- a/test/Arrays/ArrayInputsVectorForwardMode.C +++ b/test/Arrays/ArrayInputsVectorForwardMode.C @@ -1,8 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oArrayInputsVectorForwardMode.out 2>&1 | %filecheck %s // RUN: ./ArrayInputsVectorForwardMode.out | %filecheck_exec %s -// XFAIL: asserts - #include "clad/Differentiator/Differentiator.h" double multiply(const double *arr) { diff --git a/test/ForwardMode/VectorMode.C b/test/ForwardMode/VectorMode.C index 544b98fad..4978eff71 100644 --- a/test/ForwardMode/VectorMode.C +++ b/test/ForwardMode/VectorMode.C @@ -1,8 +1,6 @@ // RUN: %cladclang %s -I%S/../../include -oVectorMode.out 2>&1 | %filecheck %s // RUN: ./VectorMode.out | %filecheck_exec %s -// XFAIL: asserts - #include "clad/Differentiator/Differentiator.h" double f1(double x, double y) { diff --git a/test/ForwardMode/VectorModeInterface.C b/test/ForwardMode/VectorModeInterface.C index 923756db7..7163073ab 100644 --- a/test/ForwardMode/VectorModeInterface.C +++ b/test/ForwardMode/VectorModeInterface.C @@ -1,7 +1,5 @@ // RUN: %cladclang %s -I%S/../../include -fsyntax-only -Xclang -verify 2>&1 | %filecheck %s -// XFAIL: asserts - #include "clad/Differentiator/Differentiator.h" double f1(double x, double y) {