VirtualBox

source: vbox/trunk/src/bldprogs/VBoxCompilerPlugIns.h@ 106724

Last change on this file since 106724 was 106061, checked in by vboxsync, 2 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/* $Id: VBoxCompilerPlugIns.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VBoxCompilerPlugIns - Types, Prototypes and Macros common to the VBox compiler plug-ins.
4 */
5
6/*
7 * Copyright (C) 2006-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef VBOX_INCLUDED_SRC_bldprogs_VBoxCompilerPlugIns_h
29#define VBOX_INCLUDED_SRC_bldprogs_VBoxCompilerPlugIns_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <iprt/types.h>
35#include <stdio.h>
36
37
38/** @def dprintf
39 * Macro for debug printing using fprintf. Only active when DEBUG is defined.
40 */
41#ifdef DEBUG
42# define dprintf(...) do { fprintf(stderr, __VA_ARGS__); } while (0)
43#else
44# define dprintf(...) do { } while (0)
45#endif
46
47
48/**
49 * Checker state.
50 */
51typedef struct VFMTCHKSTATE
52{
53 long iFmt; /**< The format argument number from the attribute. */
54 long iArgs; /**< The arguments argument number from the attribute. */
55 bool fMaybeNull; /**< Set if in iprt_format_maybe_null mode. */
56 const char *pszFmt; /**< The format string being validated, if a constant. */
57
58#if defined(__GNUC__) && !defined(VBOX_COMPILER_PLUG_IN_AGNOSTIC)
59 /** @name GCC specifics
60 * @{ */
61# if RT_GNUC_PREREQ(6, 0)
62 gimple const *hStmt;
63# else
64 gimple hStmt;
65# endif
66 location_t hFmtLoc; /**< The statement or format-string location */
67 /** @} */
68#endif
69} VFMTCHKSTATE;
70/** Pointer to my checker state. */
71typedef VFMTCHKSTATE *PVFMTCHKSTATE;
72
73#define MYSTATE_FMT_FILE(a_pState) VFmtChkGetFmtLocFile(a_pState)
74#define MYSTATE_FMT_LINE(a_pState) VFmtChkGetFmtLocLine(a_pState)
75#define MYSTATE_FMT_COLUMN(a_pState) VFmtChkGetFmtLocColumn(a_pState)
76
77const char *VFmtChkGetFmtLocFile(PVFMTCHKSTATE pState);
78
79unsigned int VFmtChkGetFmtLocLine(PVFMTCHKSTATE pState);
80
81unsigned int VFmtChkGetFmtLocColumn(PVFMTCHKSTATE pState);
82
83/**
84 * Implements checking format string replacement (%M).
85 *
86 * Caller will have checked all that can be checked. This means that there is a
87 * string argument present, or it won't make the call.
88 *
89 * @param pState The format string checking state.
90 * @param pszPctM The position of the '%M'.
91 * @param iArg The next argument number.
92 */
93void VFmtChkHandleReplacementFormatString(PVFMTCHKSTATE pState, const char *pszPctM, unsigned iArg);
94
95/**
96 * Warning.
97 *
98 * @returns
99 * @param pState .
100 * @param pszLoc .
101 * @param pszFormat .
102 * @param ... .
103 */
104void VFmtChkWarnFmt(PVFMTCHKSTATE pState, const char *pszLoc, const char *pszFormat, ...);
105
106/**
107 * Error.
108 *
109 * @returns
110 * @param pState .
111 * @param pszLoc .
112 * @param pszFormat .
113 * @param ... .
114 */
115void VFmtChkErrFmt(PVFMTCHKSTATE pState, const char *pszLoc, const char *pszFormat, ...);
116
117/**
118 * Checks that @a iFmtArg isn't present or a valid final dummy argument.
119 *
120 * Will issue warning/error if there are more arguments at @a iFmtArg.
121 *
122 * @param pState The format string checking state.
123 * @param iArg The index of the end of arguments, this is
124 * relative to VFMTCHKSTATE::iArgs.
125 */
126void VFmtChkVerifyEndOfArgs(PVFMTCHKSTATE pState, unsigned iArg);
127
128bool VFmtChkRequirePresentArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
129
130bool VFmtChkRequireIntArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
131
132bool VFmtChkRequireStringArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
133
134bool VFmtChkRequireVaListPtrArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
135
136/* VBoxCompilerPlugInsCommon.cpp */
137void MyCheckFormatCString(PVFMTCHKSTATE pState, const char *pszFmt);
138
139
140#endif /* !VBOX_INCLUDED_SRC_bldprogs_VBoxCompilerPlugIns_h */
141
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette