Skip to content

Commit d1c7fa8

Browse files
authored
[CIR][NFC] Fix a build warning in CIRGenCall.cpp (llvm#137366)
We have been getting a warning about a default statement in a fully covered switch statement. This change fixes that by removing the default, updating all paths to return a value rather than depending on a local variable which is returned immediately after the switch, and adding an llvm_unreachable for non-enum values.
1 parent 0383e54 commit d1c7fa8

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

clang/lib/CIR/CodeGen/CIRGenCall.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &funcInfo,
110110
assert(!cir::MissingFeatures::opCallMustTail());
111111
assert(!cir::MissingFeatures::opCallReturn());
112112

113-
RValue ret;
114113
switch (retInfo.getKind()) {
115114
case cir::ABIArgInfo::Direct: {
116115
mlir::Type retCIRTy = convertType(retTy);
@@ -132,23 +131,22 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &funcInfo,
132131

133132
return RValue::get(results[0]);
134133
}
135-
default:
134+
case cir::TEK_Complex:
135+
case cir::TEK_Aggregate:
136136
cgm.errorNYI(loc,
137137
"unsupported evaluation kind of function call result");
138+
return getUndefRValue(retTy);
138139
}
139-
} else
140-
cgm.errorNYI(loc, "unsupported function call form");
141-
142-
break;
140+
llvm_unreachable("Invalid evaluation kind");
141+
}
142+
cgm.errorNYI(loc, "unsupported function call form");
143+
return getUndefRValue(retTy);
143144
}
144145
case cir::ABIArgInfo::Ignore:
145146
// If we are ignoring an argument that had a result, make sure to construct
146147
// the appropriate return value for our caller.
147-
ret = getUndefRValue(retTy);
148-
break;
149-
default:
150-
cgm.errorNYI(loc, "unsupported return value information");
148+
return getUndefRValue(retTy);
151149
}
152150

153-
return ret;
151+
llvm_unreachable("Invalid return info kind");
154152
}

0 commit comments

Comments
 (0)