Skip to content

Commit a8ee905

Browse files
authored
---
yaml --- r: 348663 b: refs/heads/master c: 2585d6c h: refs/heads/master i: 348661: 62b9b2e 348659: fc70c7b 348655: 1c15f47
1 parent c7f69de commit a8ee905

File tree

27 files changed

+351
-263
lines changed

27 files changed

+351
-263
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: e6b3fd4bcd7fab62e94127d80f0bfde70d2ff32d
2+
refs/heads/master: 2585d6c78c12392bb362bd74748b143295772387
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/AST/ASTTypeIDZone.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ SWIFT_TYPEID_NAMED(Decl *, Decl)
2828
SWIFT_TYPEID_NAMED(GenericParamList *, GenericParamList)
2929
SWIFT_TYPEID_NAMED(GenericSignature *, GenericSignature)
3030
SWIFT_TYPEID_NAMED(GenericTypeParamType *, GenericTypeParamType)
31+
SWIFT_TYPEID_NAMED(InfixOperatorDecl *, InfixOperatorDecl)
3132
SWIFT_TYPEID_NAMED(IterableDeclContext *, IterableDeclContext)
3233
SWIFT_TYPEID_NAMED(ModuleDecl *, ModuleDecl)
3334
SWIFT_TYPEID_NAMED(NominalTypeDecl *, NominalTypeDecl)
3435
SWIFT_TYPEID_NAMED(OperatorDecl *, OperatorDecl)
3536
SWIFT_TYPEID_NAMED(Optional<PropertyWrapperMutability>,
3637
PropertyWrapperMutability)
38+
SWIFT_TYPEID_NAMED(PrecedenceGroupDecl *, PrecedenceGroupDecl)
3739
SWIFT_TYPEID_NAMED(ProtocolDecl *, ProtocolDecl)
3840
SWIFT_TYPEID_NAMED(TypeAliasDecl *, TypeAliasDecl)
3941
SWIFT_TYPEID_NAMED(ValueDecl *, ValueDecl)

trunk/include/swift/AST/ASTTypeIDs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ class Decl;
2626
class GenericParamList;
2727
class GenericSignature;
2828
class GenericTypeParamType;
29+
class InfixOperatorDecl;
2930
class IterableDeclContext;
3031
class ModuleDecl;
3132
class NominalTypeDecl;
3233
class OperatorDecl;
34+
class PrecedenceGroupDecl;
3335
struct PropertyWrapperBackingPropertyInfo;
3436
struct PropertyWrapperTypeInfo;
3537
enum class CtorInitializerKind;

trunk/include/swift/AST/Decl.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6909,7 +6909,6 @@ class OperatorDecl : public Decl {
69096909
/// \endcode
69106910
class InfixOperatorDecl : public OperatorDecl {
69116911
SourceLoc ColonLoc;
6912-
PrecedenceGroupDecl *PrecedenceGroup = nullptr;
69136912

69146913
public:
69156914
InfixOperatorDecl(DeclContext *DC, SourceLoc operatorLoc, Identifier name,
@@ -6920,14 +6919,6 @@ class InfixOperatorDecl : public OperatorDecl {
69206919
identifiers, identifierLocs),
69216920
ColonLoc(colonLoc) {}
69226921

6923-
InfixOperatorDecl(DeclContext *DC, SourceLoc operatorLoc, Identifier name,
6924-
SourceLoc nameLoc, SourceLoc colonLoc,
6925-
PrecedenceGroupDecl *precedenceGroup,
6926-
ArrayRef<NominalTypeDecl *> designatedNominalTypes)
6927-
: OperatorDecl(DeclKind::InfixOperator, DC, operatorLoc, name, nameLoc,
6928-
designatedNominalTypes),
6929-
ColonLoc(colonLoc), PrecedenceGroup(precedenceGroup) {}
6930-
69316922
SourceLoc getEndLoc() const {
69326923
auto identifierLocs = getIdentifierLocs();
69336924
if (identifierLocs.empty())
@@ -6942,10 +6933,7 @@ class InfixOperatorDecl : public OperatorDecl {
69426933

69436934
SourceLoc getColonLoc() const { return ColonLoc; }
69446935

6945-
PrecedenceGroupDecl *getPrecedenceGroup() const { return PrecedenceGroup; }
6946-
void setPrecedenceGroup(PrecedenceGroupDecl *PGD) {
6947-
PrecedenceGroup = PGD;
6948-
}
6936+
PrecedenceGroupDecl *getPrecedenceGroup() const;
69496937

69506938
/// True if this decl's attributes conflict with those declared by another
69516939
/// operator.

trunk/include/swift/AST/NameLookupRequests.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "swift/AST/SimpleRequest.h"
2020
#include "swift/AST/ASTTypeIDs.h"
2121
#include "swift/Basic/Statistic.h"
22+
#include "llvm/ADT/Hashing.h"
2223
#include "llvm/ADT/TinyPtrVector.h"
2324

2425
namespace swift {
@@ -273,6 +274,56 @@ class GenericParamListRequest :
273274
void cacheResult(GenericParamList *value) const;
274275
};
275276

277+
struct PrecedenceGroupDescriptor {
278+
DeclContext *dc;
279+
Identifier ident;
280+
SourceLoc nameLoc;
281+
282+
SourceLoc getLoc() const;
283+
284+
friend llvm::hash_code hash_value(const PrecedenceGroupDescriptor &owner) {
285+
return hash_combine(llvm::hash_value(owner.dc),
286+
llvm::hash_value(owner.ident.getAsOpaquePointer()),
287+
llvm::hash_value(owner.nameLoc.getOpaquePointerValue()));
288+
}
289+
290+
friend bool operator==(const PrecedenceGroupDescriptor &lhs,
291+
const PrecedenceGroupDescriptor &rhs) {
292+
return lhs.dc == rhs.dc &&
293+
lhs.ident == rhs.ident &&
294+
lhs.nameLoc == rhs.nameLoc;
295+
}
296+
297+
friend bool operator!=(const PrecedenceGroupDescriptor &lhs,
298+
const PrecedenceGroupDescriptor &rhs) {
299+
return !(lhs == rhs);
300+
}
301+
};
302+
303+
void simple_display(llvm::raw_ostream &out, const PrecedenceGroupDescriptor &d);
304+
305+
class LookupPrecedenceGroupRequest
306+
: public SimpleRequest<LookupPrecedenceGroupRequest,
307+
PrecedenceGroupDecl *(PrecedenceGroupDescriptor),
308+
CacheKind::Cached> {
309+
public:
310+
using SimpleRequest::SimpleRequest;
311+
312+
private:
313+
friend SimpleRequest;
314+
315+
// Evaluation.
316+
llvm::Expected<PrecedenceGroupDecl *>
317+
evaluate(Evaluator &evaluator, PrecedenceGroupDescriptor descriptor) const;
318+
319+
public:
320+
// Source location
321+
SourceLoc getNearestLoc() const;
322+
323+
// Separate caching.
324+
bool isCached() const { return true; }
325+
};
326+
276327
#define SWIFT_TYPEID_ZONE NameLookup
277328
#define SWIFT_TYPEID_HEADER "swift/AST/NameLookupTypeIDZone.def"
278329
#include "swift/Basic/DefineTypeIDZone.h"

trunk/include/swift/AST/NameLookupTypeIDZone.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ SWIFT_REQUEST(NameLookup, InheritedDeclsReferencedRequest,
3030
DirectlyReferencedTypeDecls(
3131
llvm::PointerUnion<TypeDecl *, ExtensionDecl *>, unsigned),
3232
Uncached, HasNearestLocation)
33+
SWIFT_REQUEST(NameLookup, LookupPrecedenceGroupRequest,
34+
PrecedenceGroupDecl *(DeclContext *, Identifier, SourceLoc),
35+
Cached, NoLocationInfo)
3336
SWIFT_REQUEST(NameLookup, SelfBoundsFromWhereClauseRequest,
3437
SelfBounds(llvm::PointerUnion<TypeDecl *, ExtensionDecl *>),
3538
Uncached, NoLocationInfo)

trunk/include/swift/AST/TypeCheckRequests.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class AbstractStorageDecl;
3333
class AccessorDecl;
3434
enum class AccessorKind;
3535
class GenericParamList;
36+
class PrecedenceGroupDecl;
3637
struct PropertyWrapperBackingPropertyInfo;
3738
struct PropertyWrapperMutability;
3839
class RequirementRepr;
@@ -1209,6 +1210,25 @@ class UnderlyingTypeRequest :
12091210
void cacheResult(Type value) const;
12101211
};
12111212

1213+
class OperatorPrecedenceGroupRequest
1214+
: public SimpleRequest<OperatorPrecedenceGroupRequest,
1215+
PrecedenceGroupDecl *(InfixOperatorDecl *),
1216+
CacheKind::Cached> {
1217+
public:
1218+
using SimpleRequest::SimpleRequest;
1219+
1220+
private:
1221+
friend SimpleRequest;
1222+
1223+
// Evaluation.
1224+
llvm::Expected<PrecedenceGroupDecl *>
1225+
evaluate(Evaluator &evaluator, InfixOperatorDecl *PGD) const;
1226+
1227+
public:
1228+
// Separate caching.
1229+
bool isCached() const { return true; }
1230+
};
1231+
12121232
// Allow AnyValue to compare two Type values, even though Type doesn't
12131233
// support ==.
12141234
template<>

trunk/include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ SWIFT_REQUEST(TypeChecker, MangleLocalTypeDeclRequest,
8585
SWIFT_REQUEST(TypeChecker, OpaqueReadOwnershipRequest,
8686
OpaqueReadOwnership(AbstractStorageDecl *), SeparatelyCached,
8787
NoLocationInfo)
88+
SWIFT_REQUEST(TypeChecker, OperatorPrecedenceGroupRequest,
89+
PrecedenceGroupDecl *(PrecedenceGroupDecl *),
90+
Cached, NoLocationInfo)
8891
SWIFT_REQUEST(TypeChecker, OverriddenDeclsRequest,
8992
llvm::TinyPtrVector<ValueDecl *>(ValueDecl *), SeparatelyCached,
9093
NoLocationInfo)

trunk/lib/AST/Decl.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7471,6 +7471,28 @@ PrecedenceGroupDecl::PrecedenceGroupDecl(DeclContext *dc,
74717471
lowerThan.size() * sizeof(Relation));
74727472
}
74737473

7474+
llvm::Expected<PrecedenceGroupDecl *> LookupPrecedenceGroupRequest::evaluate(
7475+
Evaluator &eval, PrecedenceGroupDescriptor descriptor) const {
7476+
auto *dc = descriptor.dc;
7477+
PrecedenceGroupDecl *group = nullptr;
7478+
if (auto sf = dc->getParentSourceFile()) {
7479+
bool cascading = dc->isCascadingContextForLookup(false);
7480+
group = sf->lookupPrecedenceGroup(descriptor.ident, cascading,
7481+
descriptor.nameLoc);
7482+
} else {
7483+
group = dc->getParentModule()->lookupPrecedenceGroup(descriptor.ident,
7484+
descriptor.nameLoc);
7485+
}
7486+
return group;
7487+
}
7488+
7489+
PrecedenceGroupDecl *InfixOperatorDecl::getPrecedenceGroup() const {
7490+
return evaluateOrDefault(
7491+
getASTContext().evaluator,
7492+
OperatorPrecedenceGroupRequest{const_cast<InfixOperatorDecl *>(this)},
7493+
nullptr);
7494+
}
7495+
74747496
bool FuncDecl::isDeferBody() const {
74757497
return getName() == getASTContext().getIdentifier("$defer");
74767498
}

trunk/lib/AST/NameLookupRequests.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,25 @@ void GenericParamListRequest::cacheResult(GenericParamList *params) const {
127127
}
128128

129129

130+
//----------------------------------------------------------------------------//
131+
// LookupPrecedenceGroupRequest computation.
132+
//----------------------------------------------------------------------------//
133+
134+
SourceLoc LookupPrecedenceGroupRequest::getNearestLoc() const {
135+
auto &desc = std::get<0>(getStorage());
136+
return desc.getLoc();
137+
}
138+
139+
SourceLoc PrecedenceGroupDescriptor::getLoc() const {
140+
return nameLoc;
141+
}
142+
143+
void swift::simple_display(llvm::raw_ostream &out,
144+
const PrecedenceGroupDescriptor &desc) {
145+
out << "precedence group " << desc.ident << " at ";
146+
desc.nameLoc.print(out, desc.dc->getASTContext().SourceMgr);
147+
}
148+
130149
// Define request evaluation functions for each of the name lookup requests.
131150
static AbstractRequestFunction *nameLookupRequestFunctions[] = {
132151
#define SWIFT_REQUEST(Zone, Name, Sig, Caching, LocOptions) \

trunk/lib/AST/TypeCheckRequests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ void GenericSignatureRequest::cacheResult(GenericSignature *value) const {
827827
}
828828

829829
//----------------------------------------------------------------------------//
830-
// GenericSignatureRequest computation.
830+
// InferredGenericSignatureRequest computation.
831831
//----------------------------------------------------------------------------//
832832

833833
void InferredGenericSignatureRequest::noteCycleStep(DiagnosticEngine &d) const {

trunk/lib/ClangImporter/ClangAdapter.cpp

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -578,33 +578,9 @@ bool importer::isNSNotificationGlobal(const clang::NamedDecl *decl) {
578578
}
579579

580580
bool importer::hasNativeSwiftDecl(const clang::Decl *decl) {
581-
for (auto annotation : decl->specific_attrs<clang::AnnotateAttr>()) {
582-
if (annotation->getAnnotation() == SWIFT_NATIVE_ANNOTATION_STRING) {
581+
if (auto *attr = decl->getAttr<clang::ExternalSourceSymbolAttr>())
582+
if (attr->getGeneratedDeclaration() && attr->getLanguage() == "Swift")
583583
return true;
584-
}
585-
}
586-
587-
if (auto *category = dyn_cast<clang::ObjCCategoryDecl>(decl)) {
588-
clang::SourceLocation categoryNameLoc = category->getCategoryNameLoc();
589-
if (categoryNameLoc.isMacroID()) {
590-
// Climb up to the top-most macro invocation.
591-
clang::ASTContext &clangCtx = category->getASTContext();
592-
clang::SourceManager &SM = clangCtx.getSourceManager();
593-
594-
clang::SourceLocation macroCaller =
595-
SM.getImmediateMacroCallerLoc(categoryNameLoc);
596-
while (macroCaller.isMacroID()) {
597-
categoryNameLoc = macroCaller;
598-
macroCaller = SM.getImmediateMacroCallerLoc(categoryNameLoc);
599-
}
600-
601-
StringRef macroName = clang::Lexer::getImmediateMacroName(
602-
categoryNameLoc, SM, clangCtx.getLangOpts());
603-
if (macroName == "SWIFT_EXTENSION")
604-
return true;
605-
}
606-
}
607-
608584
return false;
609585
}
610586

trunk/lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -527,19 +527,6 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
527527
if (!triple.isOSDarwin())
528528
invocationArgStrs.insert(invocationArgStrs.end(),
529529
{"-fobjc-runtime=ios-7.0"});
530-
531-
// Define macros that Swift bridging headers use.
532-
invocationArgStrs.insert(invocationArgStrs.end(), {
533-
"-DSWIFT_CLASS_EXTRA=__attribute__((__annotate__("
534-
"\"" SWIFT_NATIVE_ANNOTATION_STRING "\")))",
535-
"-DSWIFT_PROTOCOL_EXTRA=__attribute__((__annotate__("
536-
"\"" SWIFT_NATIVE_ANNOTATION_STRING "\")))",
537-
"-DSWIFT_EXTENSION_EXTRA=__attribute__((__annotate__("
538-
"\"" SWIFT_NATIVE_ANNOTATION_STRING "\")))",
539-
"-DSWIFT_ENUM_EXTRA=__attribute__((__annotate__("
540-
"\"" SWIFT_NATIVE_ANNOTATION_STRING "\")))",
541-
});
542-
543530
} else {
544531
bool EnableCXXInterop = LangOpts.EnableCXXInterop;
545532
invocationArgStrs.insert(invocationArgStrs.end(),
@@ -583,6 +570,10 @@ getNormalInvocationArguments(std::vector<std::string> &invocationArgStrs,
583570

584571
// Request new APIs from UIKit.
585572
"-DSWIFT_SDK_OVERLAY_UIKIT_EPOCH=2",
573+
574+
// Backwards compatibility for headers that were checking this instead of
575+
// '__swift__'.
576+
"-DSWIFT_CLASS_EXTRA=",
586577
});
587578

588579
// Get the version of this compiler and pass it to C/Objective-C

trunk/lib/ClangImporter/ImporterImpl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,6 @@ enum class SpecialMethodKind {
220220
NSDictionarySubscriptGetter
221221
};
222222

223-
#define SWIFT_NATIVE_ANNOTATION_STRING "__swift native"
224-
225223
#define SWIFT_PROTOCOL_SUFFIX "Protocol"
226224
#define SWIFT_CFTYPE_SUFFIX "Ref"
227225

trunk/lib/Sema/CSApply.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7342,7 +7342,7 @@ bool swift::exprNeedsParensInsideFollowingOperator(
73427342
TypeChecker &TC, DeclContext *DC, Expr *expr,
73437343
PrecedenceGroupDecl *followingPG) {
73447344
if (expr->isInfixOperator()) {
7345-
auto exprPG = TC.lookupPrecedenceGroupForInfixOperator(DC, expr);
7345+
auto exprPG = TypeChecker::lookupPrecedenceGroupForInfixOperator(DC, expr);
73467346
if (!exprPG) return true;
73477347

73487348
return TC.Context.associateInfixOperators(exprPG, followingPG)
@@ -7376,7 +7376,8 @@ bool swift::exprNeedsParensOutsideFollowingOperator(
73767376
return false;
73777377

73787378
if (parent->isInfixOperator()) {
7379-
auto parentPG = TC.lookupPrecedenceGroupForInfixOperator(DC, parent);
7379+
auto parentPG = TypeChecker::lookupPrecedenceGroupForInfixOperator(DC,
7380+
parent);
73807381
if (!parentPG) return true;
73817382

73827383
// If the index is 0, this is on the LHS of the parent.
@@ -7395,20 +7396,19 @@ bool swift::exprNeedsParensOutsideFollowingOperator(
73957396
bool swift::exprNeedsParensBeforeAddingNilCoalescing(TypeChecker &TC,
73967397
DeclContext *DC,
73977398
Expr *expr) {
7398-
auto asPG =
7399-
TC.lookupPrecedenceGroup(DC, DC->getASTContext().Id_NilCoalescingPrecedence,
7400-
SourceLoc());
7401-
if (!asPG) return true;
7399+
auto asPG = TypeChecker::lookupPrecedenceGroup(
7400+
DC, DC->getASTContext().Id_NilCoalescingPrecedence, SourceLoc());
7401+
if (!asPG)
7402+
return true;
74027403
return exprNeedsParensInsideFollowingOperator(TC, DC, expr, asPG);
74037404
}
74047405

74057406
bool swift::exprNeedsParensAfterAddingNilCoalescing(TypeChecker &TC,
74067407
DeclContext *DC,
74077408
Expr *expr,
74087409
Expr *rootExpr) {
7409-
auto asPG =
7410-
TC.lookupPrecedenceGroup(DC, DC->getASTContext().Id_NilCoalescingPrecedence,
7411-
SourceLoc());
7410+
auto asPG = TypeChecker::lookupPrecedenceGroup(
7411+
DC, DC->getASTContext().Id_NilCoalescingPrecedence, SourceLoc());
74127412
if (!asPG) return true;
74137413
return exprNeedsParensOutsideFollowingOperator(TC, DC, expr, rootExpr, asPG);
74147414
}

trunk/lib/Sema/CSDiagnostics.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ class MissingExplicitConversionFailure final : public ContextualFailure {
794794
auto *DC = getDC();
795795
auto &TC = getTypeChecker();
796796

797-
auto asPG = TC.lookupPrecedenceGroup(
797+
auto asPG = TypeChecker::lookupPrecedenceGroup(
798798
DC, DC->getASTContext().Id_CastingPrecedence, SourceLoc());
799799
if (!asPG)
800800
return true;
@@ -805,7 +805,7 @@ class MissingExplicitConversionFailure final : public ContextualFailure {
805805
auto *DC = getDC();
806806
auto &TC = getTypeChecker();
807807

808-
auto asPG = TC.lookupPrecedenceGroup(
808+
auto asPG = TypeChecker::lookupPrecedenceGroup(
809809
DC, DC->getASTContext().Id_CastingPrecedence, SourceLoc());
810810
if (!asPG)
811811
return true;

0 commit comments

Comments
 (0)