Skip to content

[clang][NFC] Use switch in LoopHintAttr::getValueString #147119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions clang/lib/AST/AttrImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,38 @@ std::string LoopHintAttr::getValueString(const PrintingPolicy &Policy) const {
std::string ValueName;
llvm::raw_string_ostream OS(ValueName);
OS << "(";
if (state == Numeric)
switch (state) {
case Numeric:
value->printPretty(OS, nullptr, Policy);
else if (state == FixedWidth || state == ScalableWidth) {
break;
case FixedWidth:
if (value) {
value->printPretty(OS, nullptr, Policy);
if (state == ScalableWidth)
OS << ", scalable";
} else if (state == ScalableWidth)
OS << "scalable";
else
} else {
OS << "fixed";
} else if (state == Enable)
}
break;
case ScalableWidth:
if (value) {
value->printPretty(OS, nullptr, Policy);
OS << ", scalable";
} else {
OS << "scalable";
}
break;
case Enable:
OS << "enable";
else if (state == Full)
break;
case Full:
OS << "full";
else if (state == AssumeSafety)
break;
case AssumeSafety:
OS << "assume_safety";
else
break;
case Disable:
OS << "disable";
break;
}
OS << ")";
return ValueName;
}
Expand Down Expand Up @@ -195,7 +208,7 @@ OMPDeclareTargetDeclAttr::getLocation(const ValueDecl *VD) {
namespace clang {
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo &TI);
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo *TI);
}
} // namespace clang

void OMPDeclareVariantAttr::printPrettyPragma(
raw_ostream &OS, const PrintingPolicy &Policy) const {
Expand Down