VirtualBox

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

Last change on this file since 69734 was 69500, checked in by vboxsync, 7 years ago

*: scm --update-copyright-year

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