-
Notifications
You must be signed in to change notification settings - Fork 122
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
Delay the differentiation process until the end of TU. #766
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef CLAD_DIFFERENTIATOR_SINS_H | ||
#define CLAD_DIFFERENTIATOR_SINS_H | ||
|
||
#include <type_traits> | ||
|
||
/// Standard-protected facility allowing access into private members in C++. | ||
/// Use with caution! | ||
// NOLINTBEGIN(cppcoreguidelines-macro-usage) | ||
vgvassilev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#define CONCATE_(X, Y) X##Y | ||
vgvassilev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#define CONCATE(X, Y) CONCATE_(X, Y) | ||
vgvassilev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#define ALLOW_ACCESS(CLASS, MEMBER, ...) \ | ||
vgvassilev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
template <typename Only, __VA_ARGS__ CLASS::*Member> \ | ||
struct CONCATE(MEMBER, __LINE__) { \ | ||
friend __VA_ARGS__ CLASS::*Access(Only*) { return Member; } \ | ||
vgvassilev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; \ | ||
template <typename> struct Only_##MEMBER; \ | ||
template <> struct Only_##MEMBER<CLASS> { \ | ||
friend __VA_ARGS__ CLASS::*Access(Only_##MEMBER<CLASS>*); \ | ||
}; \ | ||
template struct CONCATE(MEMBER, \ | ||
__LINE__)<Only_##MEMBER<CLASS>, &CLASS::MEMBER> | ||
|
||
#define ACCESS(OBJECT, MEMBER) \ | ||
vgvassilev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(OBJECT).*Access((Only_##MEMBER< \ | ||
std::remove_reference<decltype(OBJECT)>::type>*)nullptr) | ||
|
||
// NOLINTEND(cppcoreguidelines-macro-usage) | ||
|
||
#endif // CLAD_DIFFERENTIATOR_SINS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// RUN: %cladclang %s -I%S/../../include -oClangConsumers.out \ | ||
// RUN: -fms-compatibility -DMS_COMPAT -std=c++14 -fmodules \ | ||
// RUN: -Xclang -print-stats 2>&1 | FileCheck %s | ||
// CHECK-NOT: {{.*error|warning|note:.*}} | ||
// | ||
// RUN: clang -xc -Xclang -add-plugin -Xclang clad -Xclang -load \ | ||
// RUN: -Xclang %cladlib %s -I%S/../../include -oClangConsumers.out \ | ||
// RUN: -Xclang -debug-info-kind=limited -Xclang -triple -Xclang bpf-linux-gnu \ | ||
// RUN: -S -emit-llvm -Xclang -target-cpu -Xclang generic \ | ||
// RUN: -Xclang -print-stats 2>&1 | \ | ||
// RUN: FileCheck -check-prefix=CHECK_C %s | ||
// CHECK_C-NOT: {{.*error|warning|note:.*}} | ||
// XFAIL: clang-7, clang-8, clang-9, target={{i586.*}}, target=arm64-apple-{{.*}} | ||
// | ||
// RUN: clang -xobjective-c -Xclang -add-plugin -Xclang clad -Xclang -load \ | ||
// RUN: -Xclang %cladlib %s -I%S/../../include -oClangConsumers.out \ | ||
// RUN: -Xclang -print-stats 2>&1 | \ | ||
// RUN: FileCheck -check-prefix=CHECK_OBJC %s | ||
// CHECK_OBJC-NOT: {{.*error|warning|note:.*}} | ||
|
||
#ifdef __cplusplus | ||
|
||
#pragma clang module build N | ||
module N {} | ||
#pragma clang module contents | ||
#pragma clang module begin N | ||
struct f { void operator()() const {} }; | ||
template <typename T> auto vtemplate = f{}; | ||
#pragma clang module end | ||
#pragma clang module endbuild | ||
|
||
#pragma clang module import N | ||
|
||
#ifdef MS_COMPAT | ||
class __single_inheritance IncSingle; | ||
#endif // MS_COMPAT | ||
|
||
struct V { virtual int f(); }; | ||
int V::f() { return 1; } | ||
template <typename T> T f() { return T(); } | ||
int i = f<int>(); | ||
|
||
// Check if shouldSkipFunctionBody is called. | ||
// RUN: %cladclang -I%S/../../include -fsyntax-only -fmodules \ | ||
// RUN: -Xclang -code-completion-at=%s:%(line-1):1 %s -o - | \ | ||
// RUN: FileCheck -check-prefix=CHECK-CODECOMP %s | ||
// CHECK-CODECOMP: COMPLETION | ||
|
||
// CHECK: HandleImplicitImportDecl | ||
// CHECK: AssignInheritanceModel | ||
// CHECK: HandleTopLevelDecl | ||
// CHECK: HandleCXXImplicitFunctionInstantiation | ||
// CHECK: HandleInterestingDecl | ||
// CHECK: HandleVTable | ||
// CHECK: HandleCXXStaticMemberVarInstantiation | ||
|
||
#endif // __cplusplus | ||
|
||
#ifdef __STDC_VERSION__ // C mode | ||
int i; | ||
|
||
extern char ch; | ||
int test(void) { return ch; } | ||
char ch = 1; | ||
|
||
// CHECK_C: CompleteTentativeDefinition | ||
// CHECK_C: CompleteExternalDeclaration | ||
#endif // __STDC_VERSION__ | ||
|
||
#ifdef __OBJC__ | ||
@interface I | ||
void f(); | ||
@end | ||
// CHECK_OBJC: HandleTopLevelDeclInObjCContainer | ||
#endif // __OBJC__ | ||
|
||
int main() { | ||
#ifdef __cplusplus | ||
vtemplate<int>(); | ||
#endif // __cplusplus | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I am not particularly happy with this commit, however, this is the only way to make progress here. I believe the demo fails due to the fact we schedule the hessians recursively. This seems hard to debug because it happens on clang release builds and clad for runtime11, runtime10, and in some cases runtime9.
More information: https://github.com/vgvassilev/clad/actions/runs/8216311966
Perhaps once we fix the way we order diff plans the issue will go away.