Skip to content

Commit b4b3f98

Browse files
committed
SR-11889: Fixed code review issues
1. Use Located in Convention structure
1 parent ea6a2dc commit b4b3f98

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

include/swift/AST/Attr.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "swift/Basic/Range.h"
2626
#include "swift/Basic/OptimizationMode.h"
2727
#include "swift/Basic/Version.h"
28+
#include "swift/Basic/Located.h"
2829
#include "swift/AST/Identifier.h"
2930
#include "swift/AST/AttrKind.h"
3031
#include "swift/AST/AutoDiff.h"
@@ -69,16 +70,13 @@ class TypeAttributes {
6970
struct Convention {
7071
StringRef Name = {};
7172
DeclNameRef WitnessMethodProtocol = {};
72-
StringRef ClangType = {};
73-
// Carry the source location for diagnostics.
74-
SourceLoc ClangTypeLoc = {};
75-
73+
Located<StringRef> ClangType = {};
7674
/// Convenience factory function to create a Swift convention.
7775
///
7876
/// Don't use this function if you are creating a C convention as you
7977
/// probably need a ClangType field as well.
8078
static Convention makeSwiftConvention(StringRef name) {
81-
return {name, DeclNameRef(), "", {}};
79+
return {name, DeclNameRef(), Located<StringRef>("", {})};
8280
}
8381
};
8482

lib/AST/Attr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ void TypeAttributes::getConventionArguments(SmallVectorImpl<char> &buf) const {
9292
stream << ": " << convention.WitnessMethodProtocol;
9393
return;
9494
}
95-
if (!convention.ClangType.empty())
96-
stream << ", cType: " << QuotedString(convention.ClangType);
95+
if (!convention.ClangType.Item.empty())
96+
stream << ", cType: " << QuotedString(convention.ClangType.Item);
9797
}
9898

9999
/// Given a name like "autoclosure", return the type attribute ID that

lib/AST/NameLookup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,8 +2402,8 @@ swift::getDirectlyInheritedNominalTypeDecls(
24022402
if (!req.getFirstType()->isEqual(protoSelfTy))
24032403
continue;
24042404

2405-
result.emplace_back(
2406-
loc, req.getSecondType()->castTo<ProtocolType>()->getDecl());
2405+
result.emplace_back(req.getSecondType()->castTo<ProtocolType>()->getDecl(),
2406+
loc);
24072407
}
24082408
return result;
24092409
}

lib/Parse/ParseDecl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2699,8 +2699,7 @@ bool Parser::parseConventionAttributeInternal(
26992699
return true;
27002700
}
27012701
if (auto ty = getStringLiteralIfNotInterpolated(Tok.getLoc(), "(C type)")) {
2702-
convention.ClangType = ty.getValue();
2703-
convention.ClangTypeLoc = Tok.getLoc();
2702+
convention.ClangType = { ty.getValue(), Tok.getLoc() };
27042703
}
27052704
consumeToken(tok::string_literal);
27062705
}

0 commit comments

Comments
 (0)