1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/* $Id: VBoxCompilerPlugIns.h $ */
/** @file
* VBoxCompilerPlugIns - Types, Prototypes and Macros common to the VBox compiler plug-ins.
*/
/*
* Copyright (C) 2006-2020 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef VBOX_INCLUDED_SRC_bldprogs_VBoxCompilerPlugIns_h
#define VBOX_INCLUDED_SRC_bldprogs_VBoxCompilerPlugIns_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif
#include <iprt/types.h>
#include <stdio.h>
/** @def dprintf
* Macro for debug printing using fprintf. Only active when DEBUG is defined.
*/
#ifdef DEBUG
# define dprintf(...) do { fprintf(stderr, __VA_ARGS__); } while (0)
#else
# define dprintf(...) do { } while (0)
#endif
/**
* Checker state.
*/
typedef struct VFMTCHKSTATE
{
long iFmt;
long iArgs;
const char *pszFmt;
bool fMaybeNull;
#if defined(__GNUC__) && !defined(VBOX_COMPILER_PLUG_IN_AGNOSTIC)
# if RT_GNUC_PREREQ(6, 0)
gimple const *hStmt;
# else
gimple hStmt;
# endif
location_t hFmtLoc;
#endif
} VFMTCHKSTATE;
/** Pointer to my checker state. */
typedef VFMTCHKSTATE *PVFMTCHKSTATE;
#define MYSTATE_FMT_FILE(a_pState) VFmtChkGetFmtLocFile(a_pState)
#define MYSTATE_FMT_LINE(a_pState) VFmtChkGetFmtLocLine(a_pState)
#define MYSTATE_FMT_COLUMN(a_pState) VFmtChkGetFmtLocColumn(a_pState)
const char *VFmtChkGetFmtLocFile(PVFMTCHKSTATE pState);
unsigned int VFmtChkGetFmtLocLine(PVFMTCHKSTATE pState);
unsigned int VFmtChkGetFmtLocColumn(PVFMTCHKSTATE pState);
/**
* Implements checking format string replacement (%M).
*
* Caller will have checked all that can be checked. This means that there is a
* string argument present, or it won't make the call.
*
* @param pState The format string checking state.
* @param pszPctM The position of the '%M'.
* @param iArg The next argument number.
*/
void VFmtChkHandleReplacementFormatString(PVFMTCHKSTATE pState, const char *pszPctM, unsigned iArg);
/**
* Warning.
*
* @returns
* @param pState .
* @param pszLoc .
* @param pszFormat .
* @param ... .
*/
void VFmtChkWarnFmt(PVFMTCHKSTATE pState, const char *pszLoc, const char *pszFormat, ...);
/**
* Error.
*
* @returns
* @param pState .
* @param pszLoc .
* @param pszFormat .
* @param ... .
*/
void VFmtChkErrFmt(PVFMTCHKSTATE pState, const char *pszLoc, const char *pszFormat, ...);
/**
* Checks that @a iFmtArg isn't present or a valid final dummy argument.
*
* Will issue warning/error if there are more arguments at @a iFmtArg.
*
* @param pState The format string checking state.
* @param iArg The index of the end of arguments, this is
* relative to VFMTCHKSTATE::iArgs.
*/
void VFmtChkVerifyEndOfArgs(PVFMTCHKSTATE pState, unsigned iArg);
bool VFmtChkRequirePresentArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
bool VFmtChkRequireIntArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
bool VFmtChkRequireStringArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
bool VFmtChkRequireVaListPtrArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
/* VBoxCompilerPlugInsCommon.cpp */
void MyCheckFormatCString(PVFMTCHKSTATE pState, const char *pszFmt);
#endif /* !VBOX_INCLUDED_SRC_bldprogs_VBoxCompilerPlugIns_h */
|