@@ -35,61 +35,69 @@ class DeclNameLoc {
3535
3636 // / Source location information.
3737 // /
38- // / If \c NumArgumentLabels == 0, this is the SourceLoc for the base name.
39- // / Otherwise, it points to an array of SourceLocs, which contains:
38+ // / If \c NumArgumentLabels == 0 and \c !HasModuleSelectorLoc, this is the
39+ // / SourceLoc for the base name. Otherwise, it points to an array of
40+ // / SourceLocs, which contains:
4041 // / * The base name location
42+ // / * The module selector location
4143 // / * The left parentheses location
4244 // / * The right parentheses location
4345 // / * The locations of each of the argument labels.
4446 const void *LocationInfo;
4547
4648 // / The number of argument labels stored in the name.
47- unsigned NumArgumentLabels;
49+ uint32_t NumArgumentLabels;
50+ bool HasModuleSelectorLoc;
4851
4952 enum {
5053 BaseNameIndex = 0 ,
51- LParenIndex = 1 ,
52- RParenIndex = 2 ,
53- FirstArgumentLabelIndex = 3 ,
54+ ModuleSelectorIndex = 1 ,
55+ LParenIndex = 2 ,
56+ RParenIndex = 3 ,
57+ FirstArgumentLabelIndex = 4 ,
5458 };
5559
5660 // / Retrieve a pointer to either the only source location that was
5761 // / stored or to the array of source locations that was stored.
5862 SourceLoc const * getSourceLocs () const {
59- if (NumArgumentLabels == 0 )
63+ if (NumArgumentLabels == 0 && !HasModuleSelectorLoc)
6064 return reinterpret_cast <SourceLoc const *>(&LocationInfo);
6165
6266 return reinterpret_cast <SourceLoc const *>(LocationInfo);
6367 }
6468
65- DeclNameLoc (const void *LocationInfo, unsigned NumArgumentLabels)
66- : LocationInfo(LocationInfo), NumArgumentLabels(NumArgumentLabels) {}
69+ DeclNameLoc (const void *LocationInfo, unsigned NumArgumentLabels,
70+ bool HasModuleSelectorLoc)
71+ : LocationInfo(LocationInfo), NumArgumentLabels(NumArgumentLabels),
72+ HasModuleSelectorLoc (HasModuleSelectorLoc) {}
6773
6874public:
6975 // / Create an invalid declaration name location.
70- DeclNameLoc () : DeclNameLoc(nullptr , 0 ) {}
76+ DeclNameLoc () : DeclNameLoc(nullptr , 0 , false ) {}
7177
7278 // / Create declaration name location information for a base name.
7379 explicit DeclNameLoc (SourceLoc baseNameLoc)
74- : DeclNameLoc(baseNameLoc.getOpaquePointerValue(), 0) {}
80+ : DeclNameLoc(baseNameLoc.getOpaquePointerValue(), 0, false ) {}
7581
7682 explicit DeclNameLoc (ASTContext &ctx, SourceLoc moduleSelectorLoc,
7783 SourceLoc baseNameLoc)
78- : DeclNameLoc(baseNameLoc) { }
84+ : DeclNameLoc(ctx, moduleSelectorLoc, baseNameLoc,
85+ SourceLoc (), {}, SourceLoc()) { }
7986
8087 // / Create declaration name location information for a compound
8188 // / name.
8289 DeclNameLoc (ASTContext &ctx, SourceLoc baseNameLoc,
8390 SourceLoc lParenLoc,
8491 ArrayRef<SourceLoc> argumentLabelLocs,
85- SourceLoc rParenLoc);
92+ SourceLoc rParenLoc)
93+ : DeclNameLoc(ctx, SourceLoc(), baseNameLoc,
94+ lParenLoc, argumentLabelLocs, rParenLoc) { }
8695
8796 DeclNameLoc (ASTContext &ctx, SourceLoc moduleSelectorLoc,
8897 SourceLoc baseNameLoc,
8998 SourceLoc lParenLoc,
9099 ArrayRef<SourceLoc> argumentLabelLocs,
91- SourceLoc rParenLoc)
92- : DeclNameLoc(ctx, baseNameLoc, lParenLoc, argumentLabelLocs, rParenLoc) { }
100+ SourceLoc rParenLoc);
93101
94102 // / Whether the location information is valid.
95103 bool isValid () const { return getBaseNameLoc ().isValid (); }
@@ -125,11 +133,12 @@ class DeclNameLoc {
125133 }
126134
127135 SourceLoc getModuleSelectorLoc () const {
128- return SourceLoc ();
136+ if (!HasModuleSelectorLoc) return SourceLoc ();
137+ return getSourceLocs ()[ModuleSelectorIndex];
129138 }
130139
131140 SourceLoc getStartLoc () const {
132- return getBaseNameLoc ();
141+ return HasModuleSelectorLoc ? getModuleSelectorLoc () : getBaseNameLoc ();
133142 }
134143
135144 SourceLoc getEndLoc () const {
@@ -138,9 +147,7 @@ class DeclNameLoc {
138147
139148 // / Retrieve the complete source range for this declaration name.
140149 SourceRange getSourceRange () const {
141- if (NumArgumentLabels == 0 ) return getBaseNameLoc ();
142-
143- return SourceRange (getBaseNameLoc (), getRParenLoc ());
150+ return SourceRange (getStartLoc (), getEndLoc ());
144151 }
145152};
146153
0 commit comments