Skip to content

Commit 9d8f8dc

Browse files
committed
[clang][NFC] Use switch in LoopHintAttr::getValueString
1 parent 7d500b1 commit 9d8f8dc

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

clang/lib/AST/AttrImpl.cpp

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,38 @@ std::string LoopHintAttr::getValueString(const PrintingPolicy &Policy) const {
4141
std::string ValueName;
4242
llvm::raw_string_ostream OS(ValueName);
4343
OS << "(";
44-
if (state == Numeric)
44+
switch (state) {
45+
case Numeric:
4546
value->printPretty(OS, nullptr, Policy);
46-
else if (state == FixedWidth || state == ScalableWidth) {
47+
break;
48+
case FixedWidth:
4749
if (value) {
4850
value->printPretty(OS, nullptr, Policy);
49-
if (state == ScalableWidth)
50-
OS << ", scalable";
51-
} else if (state == ScalableWidth)
52-
OS << "scalable";
53-
else
51+
} else {
5452
OS << "fixed";
55-
} else if (state == Enable)
53+
}
54+
break;
55+
case ScalableWidth:
56+
if (value) {
57+
value->printPretty(OS, nullptr, Policy);
58+
OS << ", scalable";
59+
} else {
60+
OS << "scalable";
61+
}
62+
break;
63+
case Enable:
5664
OS << "enable";
57-
else if (state == Full)
65+
break;
66+
case Full:
5867
OS << "full";
59-
else if (state == AssumeSafety)
68+
break;
69+
case AssumeSafety:
6070
OS << "assume_safety";
61-
else
71+
break;
72+
case Disable:
6273
OS << "disable";
74+
break;
75+
}
6376
OS << ")";
6477
return ValueName;
6578
}
@@ -195,7 +208,7 @@ OMPDeclareTargetDeclAttr::getLocation(const ValueDecl *VD) {
195208
namespace clang {
196209
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo &TI);
197210
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo *TI);
198-
}
211+
} // namespace clang
199212

200213
void OMPDeclareVariantAttr::printPrettyPragma(
201214
raw_ostream &OS, const PrintingPolicy &Policy) const {

0 commit comments

Comments
 (0)