Skip to content

Commit

Permalink
Swap clang version guards to default to modern llvm/clang
Browse files Browse the repository at this point in the history
This should allow SALT to be built with GCC
  • Loading branch information
zbeekman committed Jan 28, 2025
1 parent 8bc46ca commit c5f1c60
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/instrumentor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,16 +529,16 @@ class FindReturnVisitor : public RecursiveASTVisitor<FindReturnVisitor>
{
for (SourceRange lambda : lambda_locs)
{
#if __clang_major__ > 9
if (lambda.fullyContains(ret->getSourceRange()))
{
#else
#if __clang_major__ < 10
SourceLocation lambda_begin = lambda.getBegin();
SourceLocation lambda_end = lambda.getEnd();
SourceLocation ret_begin = ret->getSourceRange().getBegin();
SourceLocation ret_end = ret->getSourceRange().getEnd();
if (lambda_begin <= ret_begin && ret_end <= lambda_end)
{
#else
if (lambda.fullyContains(ret->getSourceRange()))
{
#endif
// ignore lambdas
return true;
Expand Down Expand Up @@ -596,10 +596,8 @@ class FindReturnVisitor : public RecursiveASTVisitor<FindReturnVisitor>
if (encl_function->getReturnType()->isClassType())
{
CXXRecordDecl *decl = encl_function->getReturnType()->getAsCXXRecordDecl();
#if __clang_major__ > 10
if (!(decl->hasSimpleCopyAssignment() || decl->hasTrivialCopyAssignment()))
{
#else // borrow logic of llvm 10 DeclCXX.cpp for setting DefaultedCopyAssignmentIsDeleted
#if __clang_major__ < 11
// borrow logic of llvm 10 DeclCXX.cpp for setting DefaultedCopyAssignmentIsDeleted
bool DefaultedCopyAssignmentIsDeleted = false;
if (const auto *Field = dyn_cast<FieldDecl>(decl))
{
Expand Down Expand Up @@ -633,6 +631,9 @@ class FindReturnVisitor : public RecursiveASTVisitor<FindReturnVisitor>
if (!((!decl->hasUserDeclaredCopyAssignment() && !DefaultedCopyAssignmentIsDeleted) ||
decl->hasTrivialCopyAssignment()))
{
#else
if (!(decl->hasSimpleCopyAssignment() || decl->hasTrivialCopyAssignment()))
{
#endif
needs_move = true;
}
Expand Down Expand Up @@ -734,10 +735,8 @@ class FindFunctionVisitor : public RecursiveASTVisitor<FindFunctionVisitor>
if (func->getReturnType()->isClassType())
{
CXXRecordDecl *decl = func->getReturnType()->getAsCXXRecordDecl();
#if __clang_major__ > 10
if (!(decl->hasSimpleCopyAssignment() || decl->hasTrivialCopyAssignment()))
{
#else // borrow logic of llvm 10 DeclCXX.cpp for setting DefaultedCopyAssignmentIsDeleted
#if __clang_major__ < 11
// borrow logic of llvm 10 DeclCXX.cpp for setting DefaultedCopyAssignmentIsDeleted
bool DefaultedCopyAssignmentIsDeleted = false;
if (const auto *Field = dyn_cast<FieldDecl>(decl))
{
Expand Down Expand Up @@ -771,6 +770,9 @@ class FindFunctionVisitor : public RecursiveASTVisitor<FindFunctionVisitor>
if (!((!decl->hasUserDeclaredCopyAssignment() && !DefaultedCopyAssignmentIsDeleted) ||
decl->hasTrivialCopyAssignment()))
{
#else
if (!(decl->hasSimpleCopyAssignment() || decl->hasTrivialCopyAssignment()))
{
#endif
needs_move = true;
}
Expand Down

0 comments on commit c5f1c60

Please sign in to comment.