C++: Add formatAttribute test.

This commit is contained in:
Geoffrey White
2022-10-21 16:13:34 +01:00
parent 1376385abb
commit c8bf0d03a5
5 changed files with 29 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
typedef void *va_list;
int myPrintf(const char *format, ...) __attribute__((format(printf, 1, 2)));
int mySprintf(char *buffer, const char *format, ...) __attribute__((format(__printf__, 2, 3)));
int myVprintf(const char *format, va_list arg) __attribute__((format(printf, 1, 0)));

View File

@@ -0,0 +1,2 @@
| AttributeFormattingFunction.cpp:4:5:4:12 | myPrintf | 0 | char | wchar_t | wchar_t |
| AttributeFormattingFunction.cpp:5:5:5:13 | mySprintf | 1 | char | wchar_t | wchar_t |

View File

@@ -0,0 +1,10 @@
import cpp
from AttributeFormattingFunction f
select
f,
f.getFormatParameterIndex(),
concat(f.getDefaultCharType().toString(), ", "),
concat(f.getWideCharType().toString(), ", "),
concat(f.getNonDefaultCharType().toString(), ", ")

View File

@@ -0,0 +1,3 @@
| AttributeFormattingFunction.cpp:4:54:4:59 | format | printf | 0 | 1 |
| AttributeFormattingFunction.cpp:5:69:5:74 | format | __printf__ | 1 | 2 |
| AttributeFormattingFunction.cpp:6:63:6:68 | format | printf | 0 | |

View File

@@ -0,0 +1,8 @@
import cpp
from FormatAttribute fa
select
fa,
fa.getArchetype(),
concat(fa.getFormatIndex().toString(), ", "),
concat(fa.getFirstFormatArgIndex().toString(), ", ")