-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move checks in CladFunction to compile-time #1090
Move checks in CladFunction to compile-time #1090
Conversation
5f143db
to
c15ec08
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
} | ||
: m_Function(f), m_Functor(functor), m_CUDAkernel(CUDAkernel) { | ||
#ifndef __CLAD_SO_LOADED | ||
static_assert(false, "clad doesn't appear to be loaded; make sure that " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: static assertion failed: clad doesn't appear to be loaded; make sure that you pass clad.so to clang. [clang-diagnostic-error]
static_assert(false, "clad doesn't appear to be loaded; make sure that "
^
#endif | ||
|
||
size_t length = GetLength(code); | ||
char* temp = (char*)malloc(length + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: do not manage memory manually; consider a container or a smart pointer [cppcoreguidelines-no-malloc]
char* temp = (char*)malloc(length + 1);
^
#endif | ||
|
||
size_t length = GetLength(code); | ||
char* temp = (char*)malloc(length + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]
char* temp = (char*)malloc(length + 1);
^
#endif | ||
|
||
size_t length = GetLength(code); | ||
char* temp = (char*)malloc(length + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: initializing non-owner 'char *' with a newly created 'gsl::owner<>' [cppcoreguidelines-owning-memory]
char* temp = (char*)malloc(length + 1);
^
size_t length = GetLength(code); | ||
char* temp = (char*)malloc(length + 1); | ||
m_Code = temp; | ||
while ((*temp++ = *code++)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]
while ((*temp++ = *code++))
^
size_t length = GetLength(code); | ||
char* temp = (char*)malloc(length + 1); | ||
m_Code = temp; | ||
while ((*temp++ = *code++)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]
while ((*temp++ = *code++))
^
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1090 +/- ##
==========================================
+ Coverage 94.26% 94.28% +0.02%
==========================================
Files 55 55
Lines 8445 8441 -4
==========================================
- Hits 7961 7959 -2
+ Misses 484 482 -2
... and 2 files with indirect coverage changes
|
1b944d2
to
d7a3d63
Compare
8484807
to
af905d1
Compare
af905d1
to
cc3518e
Compare
test/ForwardMode/ConstevalTest.C
Outdated
@@ -0,0 +1,58 @@ | |||
// RUN: %cladclang %s -I%S/../../include -std=c++23 -oConstevalTest.out | %filecheck %s | |||
// RUN: ./ConstevalTest.out | %filecheck_exec %s | |||
// XFAIL: * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the tests are marked with XFAIL? Can we make a test that makes sure this does not regress again into some runtime evaluation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes that would allow constexpr/consteval are not in this pr so I disabled them and we can enable them in that pr, or should I remove them from here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case we should not add the tests as part of this pr.
cc3518e
to
e86a47d
Compare
e86a47d
to
710b779
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
tools/ClangPlugin.cpp
Outdated
@@ -90,6 +90,12 @@ namespace clad { | |||
CGOpts.PassPlugins.push_back(CladSoPath.str()); | |||
} | |||
#endif // CLANG_VERSION_MAJOR > 8 | |||
|
|||
// Add define for CLAD_SO_LOADED, so that CladFunction::CladFunction() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Add define for CLAD_SO_LOADED, so that CladFunction::CladFunction() | |
// Add define for __CLAD_SO_LOADED, so that CladFunction::CladFunction() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make that change and put it in the right place in the commit history.
These asserts will only assert if clad has malfunctioned, which won't fix anything. Also there isn't a way to keep them while making the methods constexpr.
710b779
to
efa67b3
Compare
No description provided.