2012-10-18 19:05:02 +00:00
|
|
|
//===--- MultiplexExternalSemaSource.cpp ---------------------------------===//
|
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-10-18 19:05:02 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the event dispatching to the subscribed clients.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "clang/Sema/MultiplexExternalSemaSource.h"
|
|
|
|
#include "clang/Sema/Lookup.h"
|
|
|
|
|
|
|
|
using namespace clang;
|
|
|
|
|
2019-12-15 16:09:20 +01:00
|
|
|
char MultiplexExternalSemaSource::ID;
|
|
|
|
|
2022-09-01 16:31:23 -05:00
|
|
|
/// Constructs a new multiplexing external sema source and appends the
|
2012-10-18 19:05:02 +00:00
|
|
|
/// given element to it.
|
|
|
|
///
|
2022-09-01 16:31:23 -05:00
|
|
|
MultiplexExternalSemaSource::MultiplexExternalSemaSource(
|
|
|
|
ExternalSemaSource *S1, ExternalSemaSource *S2) {
|
|
|
|
S1->Retain();
|
|
|
|
S2->Retain();
|
|
|
|
Sources.push_back(S1);
|
|
|
|
Sources.push_back(S2);
|
2012-10-18 19:05:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// pin the vtable here.
|
2022-09-01 16:31:23 -05:00
|
|
|
MultiplexExternalSemaSource::~MultiplexExternalSemaSource() {
|
|
|
|
for (auto *S : Sources)
|
|
|
|
S->Release();
|
|
|
|
}
|
2012-10-18 19:05:02 +00:00
|
|
|
|
2022-09-01 16:31:23 -05:00
|
|
|
/// Appends new source to the source list.
|
2012-10-18 19:05:02 +00:00
|
|
|
///
|
|
|
|
///\param[in] source - An ExternalSemaSource.
|
|
|
|
///
|
2022-09-01 16:31:23 -05:00
|
|
|
void MultiplexExternalSemaSource::AddSource(ExternalSemaSource *Source) {
|
|
|
|
Source->Retain();
|
|
|
|
Sources.push_back(Source);
|
2012-10-18 19:05:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ExternalASTSource.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
Decl *MultiplexExternalSemaSource::GetExternalDecl(uint32_t ID) {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
if (Decl *Result = Sources[i]->GetExternalDecl(ID))
|
|
|
|
return Result;
|
2014-05-26 06:22:03 +00:00
|
|
|
return nullptr;
|
If a declaration is loaded, and then a module import adds a redeclaration, then
ensure that querying the first declaration for its most recent declaration
checks for redeclarations from the imported module.
This works as follows:
* The 'most recent' pointer on a canonical declaration grows a pointer to the
external AST source and a generation number (space- and time-optimized for
the case where there is no external source).
* Each time the 'most recent' pointer is queried, if it has an external source,
we check whether it's up to date, and update it if not.
* The ancillary data stored on the canonical declaration is allocated lazily
to avoid filling it in for declarations that end up being non-canonical.
We'll still perform a redundant (ASTContext) allocation if someone asks for
the most recent declaration from a decl before setPreviousDecl is called,
but such cases are probably all bugs, and are now easy to find.
Some finessing is still in order here -- in particular, we use a very general
mechanism for handling the DefinitionData pointer on CXXRecordData, and a more
targeted approach would be more compact.
Also, the MayHaveOutOfDateDef mechanism should now be expunged, since it was
addressing only a corner of the full problem space here. That's not covered
by this patch.
Early performance benchmarks show that this makes no measurable difference to
Clang performance without modules enabled (and fixes a major correctness issue
with modules enabled). I'll revert if a full performance comparison shows any
problems.
llvm-svn: 209046
2014-05-16 23:01:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::CompleteRedeclChain(const Decl *D) {
|
|
|
|
for (size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->CompleteRedeclChain(D);
|
2012-10-18 19:05:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Selector MultiplexExternalSemaSource::GetExternalSelector(uint32_t ID) {
|
|
|
|
Selector Sel;
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i) {
|
|
|
|
Sel = Sources[i]->GetExternalSelector(ID);
|
|
|
|
if (!Sel.isNull())
|
|
|
|
return Sel;
|
|
|
|
}
|
|
|
|
return Sel;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t MultiplexExternalSemaSource::GetNumExternalSelectors() {
|
|
|
|
uint32_t total = 0;
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
total += Sources[i]->GetNumExternalSelectors();
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
|
|
|
Stmt *MultiplexExternalSemaSource::GetExternalDeclStmt(uint64_t Offset) {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
if (Stmt *Result = Sources[i]->GetExternalDeclStmt(Offset))
|
|
|
|
return Result;
|
2014-05-26 06:22:03 +00:00
|
|
|
return nullptr;
|
2012-10-18 19:05:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CXXBaseSpecifier *MultiplexExternalSemaSource::GetExternalCXXBaseSpecifiers(
|
|
|
|
uint64_t Offset){
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
if (CXXBaseSpecifier *R = Sources[i]->GetExternalCXXBaseSpecifiers(Offset))
|
|
|
|
return R;
|
2014-05-26 06:22:03 +00:00
|
|
|
return nullptr;
|
2012-10-18 19:05:02 +00:00
|
|
|
}
|
|
|
|
|
2015-03-24 06:36:48 +00:00
|
|
|
CXXCtorInitializer **
|
|
|
|
MultiplexExternalSemaSource::GetExternalCXXCtorInitializers(uint64_t Offset) {
|
|
|
|
for (auto *S : Sources)
|
|
|
|
if (auto *R = S->GetExternalCXXCtorInitializers(Offset))
|
|
|
|
return R;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-01-30 05:00:26 +00:00
|
|
|
ExternalASTSource::ExtKind
|
2017-04-11 21:13:37 +00:00
|
|
|
MultiplexExternalSemaSource::hasExternalDefinitions(const Decl *D) {
|
2017-01-30 05:00:26 +00:00
|
|
|
for (const auto &S : Sources)
|
2017-04-11 21:13:37 +00:00
|
|
|
if (auto EK = S->hasExternalDefinitions(D))
|
2017-01-30 05:00:26 +00:00
|
|
|
if (EK != EK_ReplyHazy)
|
|
|
|
return EK;
|
|
|
|
return EK_ReplyHazy;
|
|
|
|
}
|
|
|
|
|
2013-02-07 03:30:24 +00:00
|
|
|
bool MultiplexExternalSemaSource::
|
2012-10-18 19:05:02 +00:00
|
|
|
FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) {
|
2013-02-07 03:30:24 +00:00
|
|
|
bool AnyDeclsFound = false;
|
|
|
|
for (size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
AnyDeclsFound |= Sources[i]->FindExternalVisibleDeclsByName(DC, Name);
|
|
|
|
return AnyDeclsFound;
|
2012-10-18 19:05:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::completeVisibleDeclsMap(const DeclContext *DC){
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->completeVisibleDeclsMap(DC);
|
|
|
|
}
|
|
|
|
|
2015-08-05 22:41:45 +00:00
|
|
|
void MultiplexExternalSemaSource::FindExternalLexicalDecls(
|
|
|
|
const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
|
|
|
|
SmallVectorImpl<Decl *> &Result) {
|
2012-10-18 19:05:02 +00:00
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
2015-08-05 22:41:45 +00:00
|
|
|
Sources[i]->FindExternalLexicalDecls(DC, IsKindWeWant, Result);
|
2012-10-18 19:05:02 +00:00
|
|
|
}
|
|
|
|
|
2018-07-30 19:24:48 +00:00
|
|
|
void MultiplexExternalSemaSource::FindFileRegionDecls(FileID File,
|
2012-10-18 19:05:02 +00:00
|
|
|
unsigned Offset,
|
|
|
|
unsigned Length,
|
|
|
|
SmallVectorImpl<Decl *> &Decls){
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->FindFileRegionDecls(File, Offset, Length, Decls);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::CompleteType(TagDecl *Tag) {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->CompleteType(Tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::CompleteType(ObjCInterfaceDecl *Class) {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->CompleteType(Class);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::ReadComments() {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->ReadComments();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::StartedDeserializing() {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->StartedDeserializing();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::FinishedDeserializing() {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->FinishedDeserializing();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::StartTranslationUnit(ASTConsumer *Consumer) {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->StartTranslationUnit(Consumer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::PrintStats() {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->PrintStats();
|
|
|
|
}
|
|
|
|
|
2018-01-22 15:27:25 +00:00
|
|
|
Module *MultiplexExternalSemaSource::getModule(unsigned ID) {
|
|
|
|
for (size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
if (auto M = Sources[i]->getModule(ID))
|
|
|
|
return M;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2012-10-18 19:05:02 +00:00
|
|
|
bool MultiplexExternalSemaSource::layoutRecordType(const RecordDecl *Record,
|
2018-07-30 19:24:48 +00:00
|
|
|
uint64_t &Size,
|
2012-10-18 19:05:02 +00:00
|
|
|
uint64_t &Alignment,
|
|
|
|
llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
|
|
|
|
llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
|
|
|
|
llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets){
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
2018-07-30 19:24:48 +00:00
|
|
|
if (Sources[i]->layoutRecordType(Record, Size, Alignment, FieldOffsets,
|
2012-10-18 19:05:02 +00:00
|
|
|
BaseOffsets, VirtualBaseOffsets))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::
|
|
|
|
getMemoryBufferSizes(MemoryBufferSizes &sizes) const {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->getMemoryBufferSizes(sizes);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ExternalSemaSource.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::InitializeSema(Sema &S) {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->InitializeSema(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::ForgetSema() {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->ForgetSema();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::ReadMethodPool(Selector Sel) {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->ReadMethodPool(Sel);
|
|
|
|
}
|
|
|
|
|
2016-04-29 19:04:05 +00:00
|
|
|
void MultiplexExternalSemaSource::updateOutOfDateSelector(Selector Sel) {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->updateOutOfDateSelector(Sel);
|
|
|
|
}
|
|
|
|
|
2012-10-18 19:05:02 +00:00
|
|
|
void MultiplexExternalSemaSource::ReadKnownNamespaces(
|
|
|
|
SmallVectorImpl<NamespaceDecl*> &Namespaces){
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->ReadKnownNamespaces(Namespaces);
|
|
|
|
}
|
2013-01-26 00:35:08 +00:00
|
|
|
|
2013-02-01 08:13:20 +00:00
|
|
|
void MultiplexExternalSemaSource::ReadUndefinedButUsed(
|
2016-03-25 21:49:43 +00:00
|
|
|
llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {
|
2013-01-26 00:35:08 +00:00
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
2013-02-01 08:13:20 +00:00
|
|
|
Sources[i]->ReadUndefinedButUsed(Undefined);
|
2013-01-26 00:35:08 +00:00
|
|
|
}
|
2015-05-18 19:59:11 +00:00
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::ReadMismatchingDeleteExpressions(
|
|
|
|
llvm::MapVector<FieldDecl *,
|
|
|
|
llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &
|
|
|
|
Exprs) {
|
|
|
|
for (auto &Source : Sources)
|
|
|
|
Source->ReadMismatchingDeleteExpressions(Exprs);
|
|
|
|
}
|
|
|
|
|
2018-07-30 19:24:48 +00:00
|
|
|
bool MultiplexExternalSemaSource::LookupUnqualified(LookupResult &R, Scope *S){
|
2012-10-18 19:05:02 +00:00
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->LookupUnqualified(R, S);
|
2018-07-30 19:24:48 +00:00
|
|
|
|
2012-10-18 19:05:02 +00:00
|
|
|
return !R.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::ReadTentativeDefinitions(
|
|
|
|
SmallVectorImpl<VarDecl*> &TentativeDefs) {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->ReadTentativeDefinitions(TentativeDefs);
|
|
|
|
}
|
2018-07-30 19:24:48 +00:00
|
|
|
|
2012-10-18 19:05:02 +00:00
|
|
|
void MultiplexExternalSemaSource::ReadUnusedFileScopedDecls(
|
|
|
|
SmallVectorImpl<const DeclaratorDecl*> &Decls) {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->ReadUnusedFileScopedDecls(Decls);
|
|
|
|
}
|
2018-07-30 19:24:48 +00:00
|
|
|
|
2012-10-18 19:05:02 +00:00
|
|
|
void MultiplexExternalSemaSource::ReadDelegatingConstructors(
|
|
|
|
SmallVectorImpl<CXXConstructorDecl*> &Decls) {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->ReadDelegatingConstructors(Decls);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::ReadExtVectorDecls(
|
|
|
|
SmallVectorImpl<TypedefNameDecl*> &Decls) {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->ReadExtVectorDecls(Decls);
|
|
|
|
}
|
|
|
|
|
2020-02-26 10:57:39 -05:00
|
|
|
void MultiplexExternalSemaSource::ReadDeclsToCheckForDeferredDiags(
|
2021-05-03 15:43:39 -07:00
|
|
|
llvm::SmallSetVector<Decl *, 4> &Decls) {
|
2020-02-26 10:57:39 -05:00
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->ReadDeclsToCheckForDeferredDiags(Decls);
|
|
|
|
}
|
|
|
|
|
Add -Wunused-local-typedef, a warning that finds unused local typedefs.
The warning warns on TypedefNameDecls -- typedefs and C++11 using aliases --
that are !isReferenced(). Since the isReferenced() bit on TypedefNameDecls
wasn't used for anything before this warning it wasn't always set correctly,
so this patch also adds a few missing MarkAnyDeclReferenced() calls in
various places for TypedefNameDecls.
This is made a bit complicated due to local typedefs possibly being used only
after their local scope has closed. Consider:
template <class T>
void template_fun(T t) {
typename T::Foo s3foo; // YYY
(void)s3foo;
}
void template_fun_user() {
struct Local {
typedef int Foo; // XXX
} p;
template_fun(p);
}
Here the typedef in XXX is only used at end-of-translation unit, when YYY in
template_fun() gets instantiated. To handle this, typedefs that are unused when
their scope exits are added to a set of potentially unused typedefs, and that
set gets checked at end-of-TU. Typedefs that are still unused at that point then
get warned on. There's also serialization code for this set, so that the
warning works with precompiled headers and modules. For modules, the warning
is emitted when the module is built, for precompiled headers each time the
header gets used.
Finally, consider a function using C++14 auto return types to return a local
type defined in a header:
auto f() {
struct S { typedef int a; };
return S();
}
Here, the typedef escapes its local scope and could be used by only some
translation units including the header. To not warn on this, add a
RecursiveASTVisitor that marks all delcs on local types returned from auto
functions as referenced. (Except if it's a function with internal linkage, or
the decls are private and the local type has no friends -- in these cases, it
_is_ safe to warn.)
Several of the included testcases (most of the interesting ones) were provided
by Richard Smith.
(gcc's spelling -Wunused-local-typedefs is supported as an alias for this
warning.)
llvm-svn: 217298
2014-09-06 01:25:55 +00:00
|
|
|
void MultiplexExternalSemaSource::ReadUnusedLocalTypedefNameCandidates(
|
|
|
|
llvm::SmallSetVector<const TypedefNameDecl *, 4> &Decls) {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->ReadUnusedLocalTypedefNameCandidates(Decls);
|
|
|
|
}
|
|
|
|
|
2012-10-18 19:05:02 +00:00
|
|
|
void MultiplexExternalSemaSource::ReadReferencedSelectors(
|
|
|
|
SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->ReadReferencedSelectors(Sels);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::ReadWeakUndeclaredIdentifiers(
|
|
|
|
SmallVectorImpl<std::pair<IdentifierInfo*, WeakInfo> > &WI) {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->ReadWeakUndeclaredIdentifiers(WI);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::ReadUsedVTables(
|
|
|
|
SmallVectorImpl<ExternalVTableUse> &VTables) {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->ReadUsedVTables(VTables);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::ReadPendingInstantiations(
|
|
|
|
SmallVectorImpl<std::pair<ValueDecl*,
|
|
|
|
SourceLocation> > &Pending) {
|
|
|
|
for(size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->ReadPendingInstantiations(Pending);
|
|
|
|
}
|
2013-08-07 21:41:30 +00:00
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::ReadLateParsedTemplates(
|
2016-10-10 16:26:08 +00:00
|
|
|
llvm::MapVector<const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
|
|
|
|
&LPTMap) {
|
2013-08-07 21:41:30 +00:00
|
|
|
for (size_t i = 0; i < Sources.size(); ++i)
|
|
|
|
Sources[i]->ReadLateParsedTemplates(LPTMap);
|
|
|
|
}
|
2013-08-12 19:54:38 +00:00
|
|
|
|
|
|
|
TypoCorrection MultiplexExternalSemaSource::CorrectTypo(
|
|
|
|
const DeclarationNameInfo &Typo,
|
|
|
|
int LookupKind, Scope *S, CXXScopeSpec *SS,
|
|
|
|
CorrectionCandidateCallback &CCC,
|
|
|
|
DeclContext *MemberContext,
|
|
|
|
bool EnteringContext,
|
|
|
|
const ObjCObjectPointerType *OPT) {
|
|
|
|
for (size_t I = 0, E = Sources.size(); I < E; ++I) {
|
|
|
|
if (TypoCorrection C = Sources[I]->CorrectTypo(Typo, LookupKind, S, SS, CCC,
|
|
|
|
MemberContext,
|
|
|
|
EnteringContext, OPT))
|
|
|
|
return C;
|
|
|
|
}
|
|
|
|
return TypoCorrection();
|
|
|
|
}
|
2013-08-12 22:11:14 +00:00
|
|
|
|
|
|
|
bool MultiplexExternalSemaSource::MaybeDiagnoseMissingCompleteType(
|
|
|
|
SourceLocation Loc, QualType T) {
|
|
|
|
for (size_t I = 0, E = Sources.size(); I < E; ++I) {
|
|
|
|
if (Sources[I]->MaybeDiagnoseMissingCompleteType(Loc, T))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
PR60985: Fix merging of lambda closure types across modules.
Previously, distinct lambdas would get merged, and multiple definitions
of the same lambda would not get merged, because we attempted to
identify lambdas by their ordinal position within their lexical
DeclContext. This failed for lambdas within namespace-scope variables
and within variable templates, where the lexical position in the context
containing the variable didn't uniquely identify the lambda.
In this patch, we instead identify lambda closure types by index within
their context declaration, which does uniquely identify them in a way
that's consistent across modules.
This change causes a deserialization cycle between the type of a
variable with deduced type and a lambda appearing as the initializer of
the variable -- reading the variable's type requires reading and merging
the lambda, and reading the lambda requires reading and merging the
variable. This is addressed by deferring loading the deduced type of a
variable until after we finish recursive deserialization.
This also exposes a pre-existing subtle issue where loading a
variable declaration would trigger immediate loading of its initializer,
which could recursively refer back to properties of the variable. This
particularly causes problems if the initializer contains a
lambda-expression, but can be problematic in general. That is addressed
by switching to lazily loading the initializers of variables rather than
always loading them with the variable declaration. As well as fixing a
deserialization cycle, that should improve laziness of deserialization
in general.
LambdaDefinitionData had 63 spare bits in it, presumably caused by an
off-by-one-error in some previous change. This change claims 32 of those bits
as a counter for the lambda within its context. We could probably move the
numbering to separate storage, like we do for the device-side mangling number,
to optimize the likely-common case where all three numbers (host-side mangling
number, device-side mangling number, and index within the context declaration)
are zero, but that's not done in this change.
Fixes #60985.
Reviewed By: #clang-language-wg, aaron.ballman
Differential Revision: https://reviews.llvm.org/D145737
2023-03-30 14:21:31 -07:00
|
|
|
|
|
|
|
void MultiplexExternalSemaSource::AssignedLambdaNumbering(
|
|
|
|
const CXXRecordDecl *Lambda) {
|
|
|
|
for (auto *Source : Sources)
|
|
|
|
Source->AssignedLambdaNumbering(Lambda);
|
|
|
|
}
|