forked from OSchip/llvm-project
[flang] Address review comments
Original-commit: flang-compiler/f18@b2a0503614 Reviewed-on: https://github.com/flang-compiler/f18/pull/774 Tree-same-pre-rewrite: false
This commit is contained in:
parent
5c35f3288a
commit
4ee37ac356
|
@ -76,7 +76,7 @@ template<typename... LAMBDAS> visitors(LAMBDAS... x)->visitors<LAMBDAS...>;
|
|||
|
||||
// For switch statements whose cases have return statements for
|
||||
// all possibilities. Clang emits warnings if the default: is
|
||||
// present, gcc emits warings if it is absent.
|
||||
// present, gcc emits warnings if it is absent.
|
||||
#if __clang__
|
||||
#define SWITCH_COVERS_ALL_CASES
|
||||
#else
|
||||
|
|
|
@ -121,10 +121,9 @@ template<> EncodedCharacter EncodeCharacter<Encoding::UTF_8>(char32_t ucs) {
|
|||
|
||||
EncodedCharacter EncodeCharacter(Encoding encoding, char32_t ucs) {
|
||||
switch (encoding) {
|
||||
case Encoding::LATIN_1: return EncodeCharacter<Encoding::LATIN_1>(ucs);
|
||||
case Encoding::UTF_8:
|
||||
return EncodeCharacter<Encoding::UTF_8>(ucs);
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
case Encoding::LATIN_1: return EncodeCharacter<Encoding::LATIN_1>(ucs);
|
||||
case Encoding::UTF_8: return EncodeCharacter<Encoding::UTF_8>(ucs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,11 +251,11 @@ template DecodedCharacter DecodeCharacter<Encoding::UTF_8>(
|
|||
DecodedCharacter DecodeCharacter(Encoding encoding, const char *cp,
|
||||
std::size_t bytes, bool backslashEscapes) {
|
||||
switch (encoding) {
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
case Encoding::LATIN_1:
|
||||
return DecodeCharacter<Encoding::LATIN_1>(cp, bytes, backslashEscapes);
|
||||
case Encoding::UTF_8:
|
||||
return DecodeCharacter<Encoding::UTF_8>(cp, bytes, backslashEscapes);
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ static void NormalizeCompilerDirectiveCommentMarker(TokenSequence &dir) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
CHECK(false && "compiler directive all blank");
|
||||
DIE("compiler directive all blank");
|
||||
}
|
||||
|
||||
void Prescanner::Prescan(ProvenanceRange range) {
|
||||
|
|
|
@ -111,6 +111,7 @@ template<template<typename> typename WRAPPER, typename WRAPPED>
|
|||
common::IfNoLvalue<MaybeExpr, WRAPPED> TypedWrapper(
|
||||
const DynamicType &dyType, WRAPPED &&x) {
|
||||
switch (dyType.category()) {
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
case TypeCategory::Integer:
|
||||
return WrapperHelper<TypeCategory::Integer, WRAPPER, WRAPPED>(
|
||||
dyType.kind(), std::move(x));
|
||||
|
@ -128,7 +129,6 @@ common::IfNoLvalue<MaybeExpr, WRAPPED> TypedWrapper(
|
|||
dyType.kind(), std::move(x));
|
||||
case TypeCategory::Derived:
|
||||
return AsGenericExpr(Expr<SomeDerived>{WRAPPER<SomeDerived>{std::move(x)}});
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -176,6 +176,7 @@ void GenericSpecInfo::Analyze(const parser::GenericSpec &x) {
|
|||
// parser::DefinedOperator::IntrinsicOperator -> GenericKind
|
||||
static GenericKind MapIntrinsicOperator(IntrinsicOperator op) {
|
||||
switch (op) {
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
case IntrinsicOperator::Power: return GenericKind::OpPower;
|
||||
case IntrinsicOperator::Multiply: return GenericKind::OpMultiply;
|
||||
case IntrinsicOperator::Divide: return GenericKind::OpDivide;
|
||||
|
@ -193,9 +194,7 @@ static GenericKind MapIntrinsicOperator(IntrinsicOperator op) {
|
|||
case IntrinsicOperator::OR: return GenericKind::OpOR;
|
||||
case IntrinsicOperator::XOR: return GenericKind::OpXOR;
|
||||
case IntrinsicOperator::EQV: return GenericKind::OpEQV;
|
||||
case IntrinsicOperator::NEQV:
|
||||
return GenericKind::OpNEQV;
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
case IntrinsicOperator::NEQV: return GenericKind::OpNEQV;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4805,6 +4805,7 @@ void ConstructVisitor::PopAssociation() {
|
|||
const DeclTypeSpec &ConstructVisitor::ToDeclTypeSpec(
|
||||
evaluate::DynamicType &&type) {
|
||||
switch (type.category()) {
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
case common::TypeCategory::Integer:
|
||||
case common::TypeCategory::Real:
|
||||
case common::TypeCategory::Complex:
|
||||
|
@ -4824,7 +4825,7 @@ const DeclTypeSpec &ConstructVisitor::ToDeclTypeSpec(
|
|||
|
||||
);
|
||||
}
|
||||
case common::TypeCategory::Character: CRASH_NO_CASE; SWITCH_COVERS_ALL_CASES
|
||||
case common::TypeCategory::Character: CRASH_NO_CASE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5718,6 +5719,7 @@ void ResolveNamesVisitor::AddSubpNames(const ProgramTree &node) {
|
|||
// Push a new scope for this node or return false on error.
|
||||
bool ResolveNamesVisitor::BeginScope(const ProgramTree &node) {
|
||||
switch (node.GetKind()) {
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
case ProgramTree::Kind::Program:
|
||||
PushScope(Scope::Kind::MainProgram,
|
||||
&MakeSymbol(node.name(), MainProgramDetails{}));
|
||||
|
@ -5730,7 +5732,6 @@ bool ResolveNamesVisitor::BeginScope(const ProgramTree &node) {
|
|||
case ProgramTree::Kind::Module: BeginModule(node.name(), false); return true;
|
||||
case ProgramTree::Kind::Submodule:
|
||||
return BeginSubmodule(node.name(), node.GetParentId());
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -212,12 +212,11 @@ bool Scope::CanImport(const SourceName &name) const {
|
|||
return false;
|
||||
}
|
||||
switch (GetImportKind()) {
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
case ImportKind::None: return false;
|
||||
case ImportKind::All:
|
||||
case ImportKind::Default: return true;
|
||||
case ImportKind::Only:
|
||||
return importNames_.count(name) > 0;
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
case ImportKind::Only: return importNames_.count(name) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -156,6 +156,7 @@ void ParamValue::SetExplicit(SomeIntExpr &&x) {
|
|||
|
||||
std::string ParamValue::AsFortran() const {
|
||||
switch (category_) {
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
case Category::Assumed: return "*";
|
||||
case Category::Deferred: return ":";
|
||||
case Category::Explicit:
|
||||
|
@ -166,7 +167,6 @@ std::string ParamValue::AsFortran() const {
|
|||
} else {
|
||||
return "";
|
||||
}
|
||||
SWITCH_COVERS_ALL_CASES
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue