VirtualBox

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

Last change on this file since 98619 was 98103, checked in by vboxsync, 23 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.3 KB
Line 
1/* $Id: VBoxCompilerPlugIns.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBoxCompilerPlugIns - Types, Prototypes and Macros common to the VBox compiler plug-ins.
4 */
5
6/*
7 * Copyright (C) 2006-2023 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;
54 long iArgs;
55 const char *pszFmt;
56 bool fMaybeNull;
57#if defined(__GNUC__) && !defined(VBOX_COMPILER_PLUG_IN_AGNOSTIC)
58# if RT_GNUC_PREREQ(6, 0)
59 gimple const *hStmt;
60# else
61 gimple hStmt;
62# endif
63 location_t hFmtLoc;
64#endif
65} VFMTCHKSTATE;
66/** Pointer to my checker state. */
67typedef VFMTCHKSTATE *PVFMTCHKSTATE;
68
69#define MYSTATE_FMT_FILE(a_pState) VFmtChkGetFmtLocFile(a_pState)
70#define MYSTATE_FMT_LINE(a_pState) VFmtChkGetFmtLocLine(a_pState)
71#define MYSTATE_FMT_COLUMN(a_pState) VFmtChkGetFmtLocColumn(a_pState)
72
73const char *VFmtChkGetFmtLocFile(PVFMTCHKSTATE pState);
74
75unsigned int VFmtChkGetFmtLocLine(PVFMTCHKSTATE pState);
76
77unsigned int VFmtChkGetFmtLocColumn(PVFMTCHKSTATE pState);
78
79/**
80 * Implements checking format string replacement (%M).
81 *
82 * Caller will have checked all that can be checked. This means that there is a
83 * string argument present, or it won't make the call.
84 *
85 * @param pState The format string checking state.
86 * @param pszPctM The position of the '%M'.
87 * @param iArg The next argument number.
88 */
89void VFmtChkHandleReplacementFormatString(PVFMTCHKSTATE pState, const char *pszPctM, unsigned iArg);
90
91/**
92 * Warning.
93 *
94 * @returns
95 * @param pState .
96 * @param pszLoc .
97 * @param pszFormat .
98 * @param ... .
99 */
100void VFmtChkWarnFmt(PVFMTCHKSTATE pState, const char *pszLoc, const char *pszFormat, ...);
101
102/**
103 * Error.
104 *
105 * @returns
106 * @param pState .
107 * @param pszLoc .
108 * @param pszFormat .
109 * @param ... .
110 */
111void VFmtChkErrFmt(PVFMTCHKSTATE pState, const char *pszLoc, const char *pszFormat, ...);
112
113/**
114 * Checks that @a iFmtArg isn't present or a valid final dummy argument.
115 *
116 * Will issue warning/error if there are more arguments at @a iFmtArg.
117 *
118 * @param pState The format string checking state.
119 * @param iArg The index of the end of arguments, this is
120 * relative to VFMTCHKSTATE::iArgs.
121 */
122void VFmtChkVerifyEndOfArgs(PVFMTCHKSTATE pState, unsigned iArg);
123
124bool VFmtChkRequirePresentArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
125
126bool VFmtChkRequireIntArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
127
128bool VFmtChkRequireStringArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
129
130bool VFmtChkRequireVaListPtrArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
131
132/* VBoxCompilerPlugInsCommon.cpp */
133void MyCheckFormatCString(PVFMTCHKSTATE pState, const char *pszFmt);
134
135
136#endif /* !VBOX_INCLUDED_SRC_bldprogs_VBoxCompilerPlugIns_h */
137
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