Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Missing swift-3.0 cherry picks for swift-clang #16

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/Sema/SemaDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7798,6 +7798,12 @@ bool Sema::CheckUsingShadowDecl(UsingDecl *Using, NamedDecl *Orig,
for (LookupResult::iterator I = Previous.begin(), E = Previous.end();
I != E; ++I) {
NamedDecl *D = (*I)->getUnderlyingDecl();
// We can have UsingDecls in our Previous results because we use the same
// LookupResult for checking whether the UsingDecl itself is a valid
// redeclaration.
if (isa<UsingDecl>(D))
continue;

if (IsEquivalentForUsingDecl(Context, D, Target)) {
if (UsingShadowDecl *Shadow = dyn_cast<UsingShadowDecl>(*I))
PrevShadow = Shadow;
Expand Down
11 changes: 7 additions & 4 deletions lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1365,10 +1365,13 @@ Sema::CreateGenericSelectionExpr(SourceLocation KeyLoc,

// Decay and strip qualifiers for the controlling expression type, and handle
// placeholder type replacement. See committee discussion from WG14 DR423.
ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr);
if (R.isInvalid())
return ExprError();
ControllingExpr = R.get();
{
EnterExpressionEvaluationContext Unevaluated(*this, Sema::Unevaluated);
ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr);
if (R.isInvalid())
return ExprError();
ControllingExpr = R.get();
}

// The controlling expression is an unevaluated operand, so side effects are
// likely unintended.
Expand Down
5 changes: 4 additions & 1 deletion lib/Sema/SemaExprMember.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1100,14 +1100,17 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
// declaration corresponding to the supplied template arguments
// (while emitting diagnostics as necessary) that will be referenced
// by this expression.
assert((!TemplateArgs || isa<VarTemplateDecl>(MemberDecl)) &&
"How did we get template arguments here sans a variable template");
if (isa<VarTemplateDecl>(MemberDecl)) {
MemberDecl = getVarTemplateSpecialization(
*this, cast<VarTemplateDecl>(MemberDecl), TemplateArgs,
R.getLookupNameInfo(), TemplateKWLoc);
if (!MemberDecl)
return ExprError();
}
return BuildDeclarationNameExpr(SS, R.getLookupNameInfo(), MemberDecl);
return BuildDeclarationNameExpr(SS, R.getLookupNameInfo(), MemberDecl,
FoundDecl, TemplateArgs);
}
SourceLocation Loc = R.getNameLoc();
if (SS.getRange().isValid())
Expand Down
22 changes: 11 additions & 11 deletions lib/Serialization/ASTWriterDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ namespace clang {
return None;
}

template<typename Decl>
void AddTemplateSpecializations(Decl *D) {
template<typename DeclTy>
void AddTemplateSpecializations(DeclTy *D) {
auto *Common = D->getCommonPtr();

// If we have any lazy specializations, and the external AST source is
Expand All @@ -204,8 +204,6 @@ namespace clang {
assert(!Common->LazySpecializations);
}

auto &Specializations = Common->Specializations;
auto &&PartialSpecializations = getPartialSpecializations(Common);
ArrayRef<DeclID> LazySpecializations;
if (auto *LS = Common->LazySpecializations)
LazySpecializations = llvm::makeArrayRef(LS + 1, LS[0]);
Expand All @@ -214,13 +212,15 @@ namespace clang {
unsigned I = Record.size();
Record.push_back(0);

for (auto &Entry : Specializations) {
auto *D = getSpecializationDecl(Entry);
assert(D->isCanonicalDecl() && "non-canonical decl in set");
AddFirstDeclFromEachModule(D, /*IncludeLocal*/true);
}
for (auto &Entry : PartialSpecializations) {
auto *D = getSpecializationDecl(Entry);
// AddFirstDeclFromEachModule might trigger deserialization, invalidating
// *Specializations iterators.
llvm::SmallVector<const Decl*, 16> Specs;
for (auto &Entry : Common->Specializations)
Specs.push_back(getSpecializationDecl(Entry));
for (auto &Entry : getPartialSpecializations(Common))
Specs.push_back(getSpecializationDecl(Entry));

for (auto *D : Specs) {
assert(D->isCanonicalDecl() && "non-canonical decl in set");
AddFirstDeclFromEachModule(D, /*IncludeLocal*/true);
}
Expand Down
4 changes: 4 additions & 0 deletions test/Sema/generic-selection.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ void foo(int n) {

const int i = 12;
int a9[_Generic(i, int: 1, default: 2) == 1 ? 1 : -1];

// This is expected to not trigger any diagnostics because the controlling
// expression is not evaluated.
(void)_Generic(*(int *)0, int: 1);
}
23 changes: 23 additions & 0 deletions test/SemaCXX/using-decl-1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,26 @@ struct B : A {
enum { X = sizeof(field) };
};
}

namespace tag_vs_var {
namespace N {
struct X {};

struct Y {};
int Y;

int Z;
}
using N::X;
using N::Y;
using N::Z;

namespace N {
int X;

struct Z {};
}
using N::X;
using N::Y;
using N::Z;
}