From 17ce5f42e668be469a0cba9422f1422bd246ab45 Mon Sep 17 00:00:00 2001 From: Jeroen Ketema Date: Fri, 20 Jun 2025 13:44:14 +0200 Subject: [PATCH] C++: Update expected test results after extractor changes --- .../floats/float128/usertypes.ql | 7 +++-- .../library-tests/ir/ir/PrintAST.expected | 30 +++++++++---------- .../library-tests/ir/ir/aliased_ir.expected | 2 +- .../test/library-tests/ir/ir/raw_ir.expected | 2 +- .../WrongTypeFormatArguments.expected | 2 ++ .../Microsoft/printf1.h | 4 +-- .../WrongTypeFormatArguments.expected | 2 ++ .../Microsoft_no_wchar/printf1.h | 4 +-- 8 files changed, 30 insertions(+), 23 deletions(-) diff --git a/cpp/ql/test/library-tests/floats/float128/usertypes.ql b/cpp/ql/test/library-tests/floats/float128/usertypes.ql index d3677562532a..2b85c9519abf 100644 --- a/cpp/ql/test/library-tests/floats/float128/usertypes.ql +++ b/cpp/ql/test/library-tests/floats/float128/usertypes.ql @@ -2,6 +2,9 @@ import cpp from UserType t, Type related where - related = t.(Class).getABaseClass() or - related = t.(TypedefType).getUnderlyingType() + ( + related = t.(Class).getABaseClass() or + related = t.(TypedefType).getUnderlyingType() + ) and + exists(t.getFile()) select t, related diff --git a/cpp/ql/test/library-tests/ir/ir/PrintAST.expected b/cpp/ql/test/library-tests/ir/ir/PrintAST.expected index d3ef1de1e13a..7a50fbe51de1 100644 --- a/cpp/ql/test/library-tests/ir/ir/PrintAST.expected +++ b/cpp/ql/test/library-tests/ir/ir/PrintAST.expected @@ -10807,22 +10807,22 @@ ir.cpp: # 885| Type = [FunctionPointerType] ..(*)(..) # 885| ValueCategory = prvalue # 886| getStmt(2): [ReturnStmt] return ... -# 888| [TopLevelFunction] void VAListUsage(int, __va_list_tag[1]) +# 888| [TopLevelFunction] void VAListUsage(int, __builtin_va_list) # 888| : # 888| getParameter(0): [Parameter] x # 888| Type = [IntType] int # 888| getParameter(1): [Parameter] args -# 888| Type = [ArrayType] __va_list_tag[1] +# 888| Type = [BuiltInVarArgsList,CTypedefType] __builtin_va_list # 888| getEntryPoint(): [BlockStmt] { ... } # 889| getStmt(0): [DeclStmt] declaration # 889| getDeclarationEntry(0): [VariableDeclarationEntry] definition of args2 -# 889| Type = [ArrayType] __va_list_tag[1] +# 889| Type = [BuiltInVarArgsList,CTypedefType] __builtin_va_list # 890| getStmt(1): [ExprStmt] ExprStmt # 890| getExpr(): [BuiltInVarArgCopy] __builtin_va_copy # 890| Type = [VoidType] void # 890| ValueCategory = prvalue # 890| getDestinationVAList(): [VariableAccess] args2 -# 890| Type = [ArrayType] __va_list_tag[1] +# 890| Type = [BuiltInVarArgsList,CTypedefType] __builtin_va_list # 890| ValueCategory = lvalue # 890| getSourceVAList(): [VariableAccess] args # 890| Type = [PointerType] __va_list_tag * @@ -10859,7 +10859,7 @@ ir.cpp: # 893| Type = [VoidType] void # 893| ValueCategory = prvalue # 893| getVAList(): [VariableAccess] args2 -# 893| Type = [ArrayType] __va_list_tag[1] +# 893| Type = [BuiltInVarArgsList,CTypedefType] __builtin_va_list # 893| ValueCategory = lvalue # 893| getVAList().getFullyConverted(): [ArrayToPointerConversion] array to pointer conversion # 893| Type = [PointerType] __va_list_tag * @@ -10872,13 +10872,13 @@ ir.cpp: # 896| getEntryPoint(): [BlockStmt] { ... } # 897| getStmt(0): [DeclStmt] declaration # 897| getDeclarationEntry(0): [VariableDeclarationEntry] definition of args -# 897| Type = [ArrayType] __va_list_tag[1] +# 897| Type = [BuiltInVarArgsList,CTypedefType] __builtin_va_list # 899| getStmt(1): [ExprStmt] ExprStmt # 899| getExpr(): [BuiltInVarArgsStart] __builtin_va_start # 899| Type = [VoidType] void # 899| ValueCategory = prvalue # 899| getVAList(): [VariableAccess] args -# 899| Type = [ArrayType] __va_list_tag[1] +# 899| Type = [BuiltInVarArgsList,CTypedefType] __builtin_va_list # 899| ValueCategory = lvalue # 899| getLastNamedParameter(): [VariableAccess] x # 899| Type = [IntType] int @@ -10888,16 +10888,16 @@ ir.cpp: # 899| ValueCategory = prvalue # 900| getStmt(2): [DeclStmt] declaration # 900| getDeclarationEntry(0): [VariableDeclarationEntry] definition of args2 -# 900| Type = [ArrayType] __va_list_tag[1] +# 900| Type = [BuiltInVarArgsList,CTypedefType] __builtin_va_list # 901| getStmt(3): [ExprStmt] ExprStmt # 901| getExpr(): [BuiltInVarArgCopy] __builtin_va_copy # 901| Type = [VoidType] void # 901| ValueCategory = prvalue # 901| getDestinationVAList(): [VariableAccess] args2 -# 901| Type = [ArrayType] __va_list_tag[1] +# 901| Type = [BuiltInVarArgsList,CTypedefType] __builtin_va_list # 901| ValueCategory = lvalue # 901| getSourceVAList(): [VariableAccess] args -# 901| Type = [ArrayType] __va_list_tag[1] +# 901| Type = [BuiltInVarArgsList,CTypedefType] __builtin_va_list # 901| ValueCategory = lvalue # 901| getDestinationVAList().getFullyConverted(): [ArrayToPointerConversion] array to pointer conversion # 901| Type = [PointerType] __va_list_tag * @@ -10913,7 +10913,7 @@ ir.cpp: # 902| Type = [DoubleType] double # 902| ValueCategory = prvalue(load) # 902| getVAList(): [VariableAccess] args -# 902| Type = [ArrayType] __va_list_tag[1] +# 902| Type = [BuiltInVarArgsList,CTypedefType] __builtin_va_list # 902| ValueCategory = lvalue # 902| getVAList().getFullyConverted(): [ArrayToPointerConversion] array to pointer conversion # 902| Type = [PointerType] __va_list_tag * @@ -10926,7 +10926,7 @@ ir.cpp: # 903| Type = [IntType] int # 903| ValueCategory = prvalue(load) # 903| getVAList(): [VariableAccess] args -# 903| Type = [ArrayType] __va_list_tag[1] +# 903| Type = [BuiltInVarArgsList,CTypedefType] __builtin_va_list # 903| ValueCategory = lvalue # 903| getVAList().getFullyConverted(): [ArrayToPointerConversion] array to pointer conversion # 903| Type = [PointerType] __va_list_tag * @@ -10940,7 +10940,7 @@ ir.cpp: # 904| Type = [VoidType] void # 904| ValueCategory = prvalue # 904| getVAList(): [VariableAccess] args -# 904| Type = [ArrayType] __va_list_tag[1] +# 904| Type = [BuiltInVarArgsList,CTypedefType] __builtin_va_list # 904| ValueCategory = lvalue # 904| getVAList().getFullyConverted(): [ArrayToPointerConversion] array to pointer conversion # 904| Type = [PointerType] __va_list_tag * @@ -10953,7 +10953,7 @@ ir.cpp: # 905| Type = [IntType] int # 905| ValueCategory = prvalue(load) # 905| getArgument(1): [VariableAccess] args2 -# 905| Type = [ArrayType] __va_list_tag[1] +# 905| Type = [BuiltInVarArgsList,CTypedefType] __builtin_va_list # 905| ValueCategory = lvalue # 905| getArgument(1).getFullyConverted(): [ArrayToPointerConversion] array to pointer conversion # 905| Type = [PointerType] __va_list_tag * @@ -10963,7 +10963,7 @@ ir.cpp: # 906| Type = [VoidType] void # 906| ValueCategory = prvalue # 906| getVAList(): [VariableAccess] args2 -# 906| Type = [ArrayType] __va_list_tag[1] +# 906| Type = [BuiltInVarArgsList,CTypedefType] __builtin_va_list # 906| ValueCategory = lvalue # 906| getVAList().getFullyConverted(): [ArrayToPointerConversion] array to pointer conversion # 906| Type = [PointerType] __va_list_tag * diff --git a/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected b/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected index c6f2bb1639e2..e258fd81f3ef 100644 --- a/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected +++ b/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected @@ -8614,7 +8614,7 @@ ir.cpp: # 883| v883_13(void) = AliasedUse : m883_3 # 883| v883_14(void) = ExitFunction : -# 888| void VAListUsage(int, __va_list_tag[1]) +# 888| void VAListUsage(int, __builtin_va_list) # 888| Block 0 # 888| v888_1(void) = EnterFunction : # 888| m888_2(unknown) = AliasedDefinition : diff --git a/cpp/ql/test/library-tests/ir/ir/raw_ir.expected b/cpp/ql/test/library-tests/ir/ir/raw_ir.expected index f594062a0a54..97d7e7c43b48 100644 --- a/cpp/ql/test/library-tests/ir/ir/raw_ir.expected +++ b/cpp/ql/test/library-tests/ir/ir/raw_ir.expected @@ -7955,7 +7955,7 @@ ir.cpp: # 883| v883_12(void) = AliasedUse : ~m? # 883| v883_13(void) = ExitFunction : -# 888| void VAListUsage(int, __va_list_tag[1]) +# 888| void VAListUsage(int, __builtin_va_list) # 888| Block 0 # 888| v888_1(void) = EnterFunction : # 888| mu888_2(unknown) = AliasedDefinition : diff --git a/cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft/WrongTypeFormatArguments.expected b/cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft/WrongTypeFormatArguments.expected index 8a05434fde65..6e17cecc33b9 100644 --- a/cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft/WrongTypeFormatArguments.expected +++ b/cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft/WrongTypeFormatArguments.expected @@ -10,6 +10,8 @@ | printf1.h:44:18:44:20 | ull | This format specifier for type 'int' does not match the argument type 'unsigned long long'. | | printf1.h:45:18:45:20 | ull | This format specifier for type 'unsigned int' does not match the argument type 'unsigned long long'. | | printf1.h:46:18:46:20 | ull | This format specifier for type 'unsigned int' does not match the argument type 'unsigned long long'. | +| printf1.h:62:19:62:20 | ul | This format specifier for type 'size_t' does not match the argument type 'unsigned long'. | +| printf1.h:68:19:68:21 | sst | This format specifier for type 'size_t' does not match the argument type 'long'. | | printf1.h:71:19:71:20 | st | This format specifier for type 'ssize_t' does not match the argument type 'unsigned long long'. | | printf1.h:72:19:72:20 | ST | This format specifier for type 'ssize_t' does not match the argument type 'unsigned long long'. | | printf1.h:73:19:73:22 | c_st | This format specifier for type 'ssize_t' does not match the argument type 'unsigned long long'. | diff --git a/cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft/printf1.h b/cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft/printf1.h index e2d4f50fc1f3..2fb361d485c5 100644 --- a/cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft/printf1.h +++ b/cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft/printf1.h @@ -59,13 +59,13 @@ void g() const SIZE_T C_ST = sizeof(st); ssize_t sst; - printf("%zu", ul); // ok (dubious, e.g. on 64-bit Windows `long` is 4 bytes but `size_t` is 8) + printf("%zu", ul); // not ok printf("%zu", st); // ok printf("%zu", ST); // ok printf("%zu", c_st); // ok printf("%zu", C_ST); // ok printf("%zu", sizeof(ul)); // ok - printf("%zu", sst); // not ok [NOT DETECTED] + printf("%zu", sst); // not ok printf("%zd", ul); // not ok [NOT DETECTED] printf("%zd", st); // not ok diff --git a/cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft_no_wchar/WrongTypeFormatArguments.expected b/cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft_no_wchar/WrongTypeFormatArguments.expected index f50708f9eb4c..0958cba59e72 100644 --- a/cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft_no_wchar/WrongTypeFormatArguments.expected +++ b/cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft_no_wchar/WrongTypeFormatArguments.expected @@ -10,6 +10,8 @@ | printf1.h:44:18:44:20 | ull | This format specifier for type 'int' does not match the argument type 'unsigned long long'. | | printf1.h:45:18:45:20 | ull | This format specifier for type 'unsigned int' does not match the argument type 'unsigned long long'. | | printf1.h:46:18:46:20 | ull | This format specifier for type 'unsigned int' does not match the argument type 'unsigned long long'. | +| printf1.h:62:19:62:20 | ul | This format specifier for type 'size_t' does not match the argument type 'unsigned long'. | +| printf1.h:68:19:68:21 | sst | This format specifier for type 'size_t' does not match the argument type 'long'. | | printf1.h:71:19:71:20 | st | This format specifier for type 'ssize_t' does not match the argument type 'unsigned long long'. | | printf1.h:72:19:72:20 | ST | This format specifier for type 'ssize_t' does not match the argument type 'unsigned long long'. | | printf1.h:73:19:73:22 | c_st | This format specifier for type 'ssize_t' does not match the argument type 'unsigned long long'. | diff --git a/cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft_no_wchar/printf1.h b/cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft_no_wchar/printf1.h index 223ffc6a2128..8222cfa67b25 100644 --- a/cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft_no_wchar/printf1.h +++ b/cpp/ql/test/query-tests/Likely Bugs/Format/WrongTypeFormatArguments/Microsoft_no_wchar/printf1.h @@ -59,13 +59,13 @@ void g() const SIZE_T C_ST = sizeof(st); ssize_t sst; - printf("%zu", ul); // ok (dubious, e.g. on 64-bit Windows `long` is 4 bytes but `size_t` is 8) + printf("%zu", ul); // not ok printf("%zu", st); // ok printf("%zu", ST); // ok printf("%zu", c_st); // ok printf("%zu", C_ST); // ok printf("%zu", sizeof(ul)); // ok - printf("%zu", sst); // not ok [NOT DETECTED] + printf("%zu", sst); // not ok printf("%zd", ul); // not ok [NOT DETECTED] printf("%zd", st); // not ok