Skip to content

Commit 8ebf408

Browse files
authored
[NFC][flang] Reorder const and RT_API_ATTRS.
Clean-up to keep the type qualifier next to the type. Reviewers: klausler Reviewed By: klausler Pull Request: #85180
1 parent 037a32a commit 8ebf408

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

flang/include/flang/ISO_Fortran_binding.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ namespace cfi_internal {
127127
// because a struct cannot be empty.
128128
extern "C++" template <typename T> struct FlexibleArray : T {
129129
RT_API_ATTRS T &operator[](int index) { return *(this + index); }
130-
const RT_API_ATTRS T &operator[](int index) const { return *(this + index); }
130+
RT_API_ATTRS const T &operator[](int index) const { return *(this + index); }
131131
RT_API_ATTRS operator T *() { return this; }
132132
RT_API_ATTRS operator const T *() const { return this; }
133133
};

flang/include/flang/Runtime/descriptor.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class DescriptorAddendum {
102102
: derivedType_{dt}, len_{0} {}
103103
RT_API_ATTRS DescriptorAddendum &operator=(const DescriptorAddendum &);
104104

105-
const RT_API_ATTRS typeInfo::DerivedType *derivedType() const {
105+
RT_API_ATTRS const typeInfo::DerivedType *derivedType() const {
106106
return derivedType_;
107107
}
108108
RT_API_ATTRS DescriptorAddendum &set_derivedType(
@@ -204,7 +204,7 @@ class Descriptor {
204204
ISO::CFI_attribute_t attribute = CFI_attribute_other);
205205

206206
RT_API_ATTRS ISO::CFI_cdesc_t &raw() { return raw_; }
207-
const RT_API_ATTRS ISO::CFI_cdesc_t &raw() const { return raw_; }
207+
RT_API_ATTRS const ISO::CFI_cdesc_t &raw() const { return raw_; }
208208
RT_API_ATTRS std::size_t ElementBytes() const { return raw_.elem_len; }
209209
RT_API_ATTRS int rank() const { return raw_.rank; }
210210
RT_API_ATTRS TypeCode type() const { return TypeCode{raw_.type}; }
@@ -225,7 +225,7 @@ class Descriptor {
225225
RT_API_ATTRS Dimension &GetDimension(int dim) {
226226
return *reinterpret_cast<Dimension *>(&raw_.dim[dim]);
227227
}
228-
const RT_API_ATTRS Dimension &GetDimension(int dim) const {
228+
RT_API_ATTRS const Dimension &GetDimension(int dim) const {
229229
return *reinterpret_cast<const Dimension *>(&raw_.dim[dim]);
230230
}
231231

@@ -345,7 +345,7 @@ class Descriptor {
345345
return nullptr;
346346
}
347347
}
348-
const RT_API_ATTRS DescriptorAddendum *Addendum() const {
348+
RT_API_ATTRS const DescriptorAddendum *Addendum() const {
349349
if (raw_.f18Addendum != 0) {
350350
return reinterpret_cast<const DescriptorAddendum *>(
351351
&GetDimension(rank()));
@@ -448,7 +448,7 @@ class alignas(Descriptor) StaticDescriptor {
448448
RT_API_ATTRS Descriptor &descriptor() {
449449
return *reinterpret_cast<Descriptor *>(storage_);
450450
}
451-
const RT_API_ATTRS Descriptor &descriptor() const {
451+
RT_API_ATTRS const Descriptor &descriptor() const {
452452
return *reinterpret_cast<const Descriptor *>(storage_);
453453
}
454454

flang/runtime/derived-api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ inline RT_API_ATTRS bool CompareDerivedType(
9595
return a == b || CompareDerivedTypeNames(a->name(), b->name());
9696
}
9797

98-
static const RT_API_ATTRS typeInfo::DerivedType *GetDerivedType(
98+
static RT_API_ATTRS const typeInfo::DerivedType *GetDerivedType(
9999
const Descriptor &desc) {
100100
if (const DescriptorAddendum * addendum{desc.Addendum()}) {
101101
if (const auto *derived{addendum->derivedType()}) {

flang/runtime/type-info.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,25 @@ class Component {
5858
Automatic = 4
5959
};
6060

61-
const RT_API_ATTRS Descriptor &name() const { return name_.descriptor(); }
61+
RT_API_ATTRS const Descriptor &name() const { return name_.descriptor(); }
6262
RT_API_ATTRS Genre genre() const { return genre_; }
6363
RT_API_ATTRS TypeCategory category() const {
6464
return static_cast<TypeCategory>(category_);
6565
}
6666
RT_API_ATTRS int kind() const { return kind_; }
6767
RT_API_ATTRS int rank() const { return rank_; }
6868
RT_API_ATTRS std::uint64_t offset() const { return offset_; }
69-
const RT_API_ATTRS Value &characterLen() const { return characterLen_; }
70-
const RT_API_ATTRS DerivedType *derivedType() const {
69+
RT_API_ATTRS const Value &characterLen() const { return characterLen_; }
70+
RT_API_ATTRS const DerivedType *derivedType() const {
7171
return derivedType_.descriptor().OffsetElement<const DerivedType>();
7272
}
73-
const RT_API_ATTRS Value *lenValue() const {
73+
RT_API_ATTRS const Value *lenValue() const {
7474
return lenValue_.descriptor().OffsetElement<const Value>();
7575
}
76-
const RT_API_ATTRS Value *bounds() const {
76+
RT_API_ATTRS const Value *bounds() const {
7777
return bounds_.descriptor().OffsetElement<const Value>();
7878
}
79-
const RT_API_ATTRS char *initialization() const { return initialization_; }
79+
RT_API_ATTRS const char *initialization() const { return initialization_; }
8080

8181
RT_API_ATTRS std::size_t GetElementByteSize(const Descriptor &) const;
8282
RT_API_ATTRS std::size_t GetElements(const Descriptor &) const;
@@ -205,27 +205,27 @@ class DerivedType {
205205
public:
206206
~DerivedType(); // never defined
207207

208-
const RT_API_ATTRS Descriptor &binding() const {
208+
RT_API_ATTRS const Descriptor &binding() const {
209209
return binding_.descriptor();
210210
}
211-
const RT_API_ATTRS Descriptor &name() const { return name_.descriptor(); }
211+
RT_API_ATTRS const Descriptor &name() const { return name_.descriptor(); }
212212
RT_API_ATTRS std::uint64_t sizeInBytes() const { return sizeInBytes_; }
213-
const RT_API_ATTRS Descriptor &uninstatiated() const {
213+
RT_API_ATTRS const Descriptor &uninstatiated() const {
214214
return uninstantiated_.descriptor();
215215
}
216-
const RT_API_ATTRS Descriptor &kindParameter() const {
216+
RT_API_ATTRS const Descriptor &kindParameter() const {
217217
return kindParameter_.descriptor();
218218
}
219-
const RT_API_ATTRS Descriptor &lenParameterKind() const {
219+
RT_API_ATTRS const Descriptor &lenParameterKind() const {
220220
return lenParameterKind_.descriptor();
221221
}
222-
const RT_API_ATTRS Descriptor &component() const {
222+
RT_API_ATTRS const Descriptor &component() const {
223223
return component_.descriptor();
224224
}
225-
const RT_API_ATTRS Descriptor &procPtr() const {
225+
RT_API_ATTRS const Descriptor &procPtr() const {
226226
return procPtr_.descriptor();
227227
}
228-
const RT_API_ATTRS Descriptor &special() const {
228+
RT_API_ATTRS const Descriptor &special() const {
229229
return special_.descriptor();
230230
}
231231
RT_API_ATTRS bool hasParent() const { return hasParent_; }
@@ -241,14 +241,14 @@ class DerivedType {
241241
return lenParameterKind().Elements();
242242
}
243243

244-
const RT_API_ATTRS DerivedType *GetParentType() const;
244+
RT_API_ATTRS const DerivedType *GetParentType() const;
245245

246246
// Finds a data component by name in this derived type or its ancestors.
247-
const RT_API_ATTRS Component *FindDataComponent(
247+
RT_API_ATTRS const Component *FindDataComponent(
248248
const char *name, std::size_t nameLen) const;
249249

250250
// O(1) look-up of special procedure bindings
251-
const RT_API_ATTRS SpecialBinding *FindSpecialBinding(
251+
RT_API_ATTRS const SpecialBinding *FindSpecialBinding(
252252
SpecialBinding::Which which) const {
253253
auto bitIndex{static_cast<std::uint32_t>(which)};
254254
auto bit{std::uint32_t{1} << bitIndex};

0 commit comments

Comments
 (0)