Skip to content

Commit 27e0557

Browse files
Fix failing test valist.c for windows (#457)
The type va_list is defined as a reference type on windows. This wasn't handled by 3C since references are typically only allowed in C++. By skipping past the reference type we are able to generate correct constraints for variable argument functions on windows.
1 parent 933e009 commit 27e0557

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

clang/lib/3C/ConstraintVariables.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,14 @@ PointerVariableConstraint::PointerVariableConstraint(
290290
InFunc ? (N == RETVAR ? VarAtom::V_Return : VarAtom::V_Param)
291291
: VarAtom::V_Other;
292292

293+
// Even though references don't exist in C, `va_list` is a typedef of
294+
// `__builtin_va_list &` on windows. In order to generate correct constraints
295+
// for var arg functions on windows, we need to strip the reference type.
296+
if (Ty->isLValueReferenceType()) {
297+
QTy = Ty->getPointeeType();
298+
Ty = QTy.getTypePtr();
299+
}
300+
293301
while (Ty->isPointerType() || Ty->isArrayType()) {
294302
// Is this a VarArg type?
295303
std::string TyName = tyToStr(Ty);

0 commit comments

Comments
 (0)