Skip to content

Commit

Permalink
Always use valid location when generating operators (#1137)
Browse files Browse the repository at this point in the history
A valid location is required by the debug clang.

Partially addresses #428.
  • Loading branch information
PetroZarytskyi authored Nov 13, 2024
1 parent e494c10 commit 997c8f9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 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
2 changes: 0 additions & 2 deletions test/Arrays/ArrayInputsVectorForwardMode.C
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions test/ForwardMode/VectorMode.C
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions test/ForwardMode/VectorModeInterface.C
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down

0 comments on commit 997c8f9

Please sign in to comment.