-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang][AST] Pass ProfileArguments by value in findSpecialization{Impl,Locally} #139489
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
[clang][AST] Pass ProfileArguments by value in findSpecialization{Impl,Locally} #139489
Conversation
…l,Locally} The arguments passed are lightweight (an ArrayRef and a pointer), and findSpecializationImpl passes them to multiple functions, making it a potential hazard to pass them by rvalue reference (even though no one was in fact moving them).
@llvm/pr-subscribers-clang Author: Nathan Ridge (HighCommander4) ChangesThe arguments passed are lightweight (an ArrayRef and a pointer), and findSpecializationImpl passes them to multiple functions, making it a potential hazard to pass them by rvalue reference (even though no one was in fact moving them). Full diff: https://github.com/llvm/llvm-project/pull/139489.diff 2 Files Affected:
diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h
index a8100b642e04c..80c97681d9163 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -781,16 +781,15 @@ class RedeclarableTemplateDecl : public TemplateDecl,
bool loadLazySpecializationsImpl(llvm::ArrayRef<TemplateArgument> Args,
TemplateParameterList *TPL = nullptr) const;
- template <class EntryType, typename ...ProfileArguments>
- typename SpecEntryTraits<EntryType>::DeclType*
+ template <class EntryType, typename... ProfileArguments>
+ typename SpecEntryTraits<EntryType>::DeclType *
findSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
- void *&InsertPos, ProfileArguments &&...ProfileArgs);
+ void *&InsertPos, ProfileArguments... ProfileArgs);
template <class EntryType, typename... ProfileArguments>
typename SpecEntryTraits<EntryType>::DeclType *
findSpecializationLocally(llvm::FoldingSetVector<EntryType> &Specs,
- void *&InsertPos,
- ProfileArguments &&...ProfileArgs);
+ void *&InsertPos, ProfileArguments... ProfileArgs);
template <class Derived, class EntryType>
void addSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index d058831b9f6bf..6857eef87de38 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -382,12 +382,11 @@ template <class EntryType, typename... ProfileArguments>
typename RedeclarableTemplateDecl::SpecEntryTraits<EntryType>::DeclType *
RedeclarableTemplateDecl::findSpecializationLocally(
llvm::FoldingSetVector<EntryType> &Specs, void *&InsertPos,
- ProfileArguments &&...ProfileArgs) {
+ ProfileArguments... ProfileArgs) {
using SETraits = RedeclarableTemplateDecl::SpecEntryTraits<EntryType>;
llvm::FoldingSetNodeID ID;
- EntryType::Profile(ID, std::forward<ProfileArguments>(ProfileArgs)...,
- getASTContext());
+ EntryType::Profile(ID, ProfileArgs..., getASTContext());
EntryType *Entry = Specs.FindNodeOrInsertPos(ID, InsertPos);
return Entry ? SETraits::getDecl(Entry)->getMostRecentDecl() : nullptr;
}
@@ -396,18 +395,15 @@ template <class EntryType, typename... ProfileArguments>
typename RedeclarableTemplateDecl::SpecEntryTraits<EntryType>::DeclType *
RedeclarableTemplateDecl::findSpecializationImpl(
llvm::FoldingSetVector<EntryType> &Specs, void *&InsertPos,
- ProfileArguments &&...ProfileArgs) {
+ ProfileArguments... ProfileArgs) {
- if (auto *Found = findSpecializationLocally(
- Specs, InsertPos, std::forward<ProfileArguments>(ProfileArgs)...))
+ if (auto *Found = findSpecializationLocally(Specs, InsertPos, ProfileArgs...))
return Found;
- if (!loadLazySpecializationsImpl(
- std::forward<ProfileArguments>(ProfileArgs)...))
+ if (!loadLazySpecializationsImpl(ProfileArgs...))
return nullptr;
- return findSpecializationLocally(
- Specs, InsertPos, std::forward<ProfileArguments>(ProfileArgs)...);
+ return findSpecializationLocally(Specs, InsertPos, ProfileArgs...);
}
template<class Derived, class EntryType>
|
(This came up during #139019 as a potential diagnosis, but it does not fix the crash. As mentioned, no one was in fact moving from the arguments, so passing them by rvalue reference and forwarding them multiple times in the same function was just poor style rather than an actual bug.) |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/18/builds/15844 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/64/builds/3526 Here is the relevant piece of the build log for the reference
|
The arguments passed are lightweight (an ArrayRef and a pointer), and findSpecializationImpl passes them to multiple functions, making it a potential hazard to pass them by rvalue reference (even though no one was in fact moving them).