Skip to content

Commit

Permalink
[flang][NFC] rename IsKindParameterizedDerivedType and fix comment typos
Browse files Browse the repository at this point in the history
Following post-review feedback on https://reviews.llvm.org/D120804 and
https://reviews.llvm.org/D120801 about type descriptor changes, fix typos in
comments and rename IsKindParameterizedDerivedType to
IsDerivedTypeWithKindParameter. Remove a useless `;`.

Reviewed By: clementval, PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D121470
  • Loading branch information
jeanPerier committed Mar 11, 2022
1 parent 0bc845f commit f2da8f5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions flang/include/flang/Optimizer/CodeGen/CodeGen.h
Expand Up @@ -38,12 +38,12 @@ std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>> createFirTargetRewritePass(
/// FIR to LLVM translation pass options.
struct FIRToLLVMPassOptions {
// Do not fail when type descriptors are not found when translating
// operations that uses them at the LLVM level like fir.embox. Instead,
// operations that use them at the LLVM level like fir.embox. Instead,
// just use a null pointer.
// This is useful to test translating programs manually written where a
// frontend did not generate type descriptor data structures. However, note
// that this programs would crash at runtime if the derived type descriptors
// are required by the runtime, so this only an option to help debugging.
// that such programs would crash at runtime if the derived type descriptors
// are required by the runtime, so this is only an option to help debugging.
bool ignoreMissingTypeDescriptors = false;
};

Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Semantics/scope.h
Expand Up @@ -104,7 +104,7 @@ class Scope {
bool IsParameterizedDerivedTypeInstantiation() const {
return kind_ == Kind::DerivedType && !symbol_;
}
bool IsKindParameterizedDerivedType() const;
bool IsDerivedTypeWithKindParameter() const;
Symbol *symbol() { return symbol_; }
const Symbol *symbol() const { return symbol_; }
SemanticsContext &context() const { return context_; }
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/compute-offsets.cpp
Expand Up @@ -68,7 +68,7 @@ void ComputeOffsetsHelper::Compute(Scope &scope) {
for (Scope &child : scope.children()) {
ComputeOffsets(context_, child);
}
if (scope.symbol() && scope.IsKindParameterizedDerivedType()) {
if (scope.symbol() && scope.IsDerivedTypeWithKindParameter()) {
return; // only process instantiations of kind parameterized derived types
}
if (scope.alignment().has_value()) {
Expand Down
5 changes: 2 additions & 3 deletions flang/lib/Semantics/runtime-type-info.cpp
Expand Up @@ -352,7 +352,6 @@ static std::optional<std::string> GetSuffixIfTypeKindParameters(
*suffix += "."s + std::to_string(*instantiatedValue);
} else {
suffix = "."s + std::to_string(*instantiatedValue);
;
}
}
}
Expand All @@ -369,7 +368,7 @@ const Symbol *RuntimeTableBuilder::DescribeType(Scope &dtScope) {
return info;
}
const DerivedTypeSpec *derivedTypeSpec{dtScope.derivedTypeSpec()};
if (!derivedTypeSpec && !dtScope.IsKindParameterizedDerivedType() &&
if (!derivedTypeSpec && !dtScope.IsDerivedTypeWithKindParameter() &&
dtScope.symbol()) {
// This derived type was declared (obviously, there's a Scope) but never
// used in this compilation (no instantiated DerivedTypeSpec points here).
Expand Down Expand Up @@ -433,7 +432,7 @@ const Symbol *RuntimeTableBuilder::DescribeType(Scope &dtScope) {
AddValue(dtValues, derivedTypeSchema_, "name"s,
SaveNameAsPointerTarget(scope, typeName));
bool isPDTdefinitionWithKindParameters{
!derivedTypeSpec && dtScope.IsKindParameterizedDerivedType()};
!derivedTypeSpec && dtScope.IsDerivedTypeWithKindParameter()};
if (!isPDTdefinitionWithKindParameters) {
auto sizeInBytes{static_cast<common::ConstantSubscript>(dtScope.size())};
if (auto alignment{dtScope.alignment().value_or(0)}) {
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Semantics/scope.cpp
Expand Up @@ -374,12 +374,12 @@ bool Scope::IsParameterizedDerivedType() const {
return false;
}

bool Scope::IsKindParameterizedDerivedType() const {
bool Scope::IsDerivedTypeWithKindParameter() const {
if (!IsDerivedType()) {
return false;
}
if (const Scope * parent{GetDerivedTypeParent()}) {
if (parent->IsKindParameterizedDerivedType()) {
if (parent->IsDerivedTypeWithKindParameter()) {
return true;
}
}
Expand Down

0 comments on commit f2da8f5

Please sign in to comment.