-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[C++20][Modules] Fix crash/compiler error due broken AST links #123648
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
Merged
dmpolukhin
merged 8 commits into
llvm:main
from
dmpolukhin:assert-not-instantiated-in-scope-cxx-modules5
Jan 23, 2025
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e5cd06d
[C++20][Modules] Fix crash/compiler error due broken AST links
dmpolukhin 0125479
Add -Werror=uninitialized to add compilation error in builds without …
dmpolukhin 127e2fb
Extract check into template function.
dmpolukhin 21d8956
Fix typo
dmpolukhin 34cca28
Add a release note
dmpolukhin 7c1f46d
Reverted to verified version + NFC
dmpolukhin 5977b98
Improved comments and add nullptr check
dmpolukhin 030ce75
Merge branch 'main' into assert-not-instantiated-in-scope-cxx-modules5
dmpolukhin 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 hidden or 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
92 changes: 92 additions & 0 deletions
92
clang/test/Headers/crash-instantiated-in-scope-cxx-modules5.cpp
This file contains hidden or 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,92 @@ | ||
// RUN: rm -fR %t | ||
// RUN: split-file %s %t | ||
// RUN: cd %t | ||
// RUN: %clang_cc1 -verify -std=c++20 -xc++ -emit-module module.cppmap -fmodule-name=mock_resolver -o mock_resolver.pcm | ||
// RUN: %clang_cc1 -verify -std=c++20 -xc++ -emit-module module.cppmap -fmodule-name=sql_internal -o sql_internal.pcm | ||
// RUN: %clang_cc1 -verify -std=c++20 -xc++ -fmodule-file=mock_resolver.pcm -fmodule-file=sql_internal.pcm main.cc -o main.o | ||
|
||
//--- module.cppmap | ||
module "mock_resolver" { | ||
export * | ||
module "mock_resolver.h" { | ||
export * | ||
header "mock_resolver.h" | ||
} | ||
} | ||
|
||
module "sql_internal" { | ||
export * | ||
module "sql_transform_builder.h" { | ||
export * | ||
header "sql_transform_builder.h" | ||
} | ||
} | ||
|
||
//--- set_bits2.h | ||
// expected-no-diagnostics | ||
#pragma once | ||
|
||
template <typename T> | ||
void fwd(const T& x) {} | ||
|
||
namespace vox::bitset { | ||
|
||
template <typename TFunc> | ||
void ForEachSetBit2(const TFunc&) { | ||
fwd([](int) { | ||
const int bit_index_base = 0; | ||
(void)[&](int) { | ||
int v = bit_index_base; | ||
}; | ||
}); | ||
} | ||
|
||
} // namespace vox::bitset | ||
|
||
//--- sql_transform_builder.h | ||
// expected-no-diagnostics | ||
#pragma once | ||
|
||
#include "set_bits2.h" | ||
|
||
class QualifyingSet3 { | ||
public: | ||
void GetIndexes() const { | ||
vox::bitset::ForEachSetBit2([]() {}); | ||
} | ||
}; | ||
|
||
template <typename T> | ||
void DoTransform() { | ||
vox::bitset::ForEachSetBit2([]() {}); | ||
} | ||
|
||
//--- mock_resolver.h | ||
// expected-no-diagnostics | ||
#pragma once | ||
#include "set_bits2.h" | ||
|
||
class QualifyingSet2 { | ||
public: | ||
void GetIndexes() const { | ||
vox::bitset::ForEachSetBit2([]() {}); | ||
} | ||
}; | ||
|
||
//--- main.cc | ||
// expected-no-diagnostics | ||
#include "sql_transform_builder.h" | ||
|
||
template <typename Callable> | ||
void get(const Callable& fn) { | ||
fwd<Callable>(fn); | ||
} | ||
|
||
namespace { | ||
|
||
void test() { | ||
get([]() {}); | ||
DoTransform<int>(); | ||
} | ||
|
||
} // namespace |
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.
Uh oh!
There was an error while loading. Please reload this page.