VirtualBox

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

Last change on this file since 64114 was 62537, checked in by vboxsync, 8 years ago

(C) 2016

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/* $Id: VBoxCompilerPlugIns.h 62537 2016-07-22 19:32:06Z vboxsync $ */
2/** @file
3 * VBoxCompilerPlugIns - Types, Prototypes and Macros common to the VBox compiler plug-ins.
4 */
5
6/*
7 * Copyright (C) 2006-2016 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 gimple hStmt;
46 location_t hFmtLoc;
47#endif
48} VFMTCHKSTATE;
49/** Pointer to my checker state. */
50typedef VFMTCHKSTATE *PVFMTCHKSTATE;
51
52#define MYSTATE_FMT_FILE(a_pState) VFmtChkGetFmtLocFile(a_pState)
53#define MYSTATE_FMT_LINE(a_pState) VFmtChkGetFmtLocLine(a_pState)
54#define MYSTATE_FMT_COLUMN(a_pState) VFmtChkGetFmtLocColumn(a_pState)
55
56const char *VFmtChkGetFmtLocFile(PVFMTCHKSTATE pState);
57
58unsigned int VFmtChkGetFmtLocLine(PVFMTCHKSTATE pState);
59
60unsigned int VFmtChkGetFmtLocColumn(PVFMTCHKSTATE pState);
61
62/**
63 * Implements checking format string replacement (%M).
64 *
65 * Caller will have checked all that can be checked. This means that there is a
66 * string argument present, or it won't make the call.
67 *
68 * @param pState The format string checking state.
69 * @param pszPctM The position of the '%M'.
70 * @param iArg The next argument number.
71 */
72void VFmtChkHandleReplacementFormatString(PVFMTCHKSTATE pState, const char *pszPctM, unsigned iArg);
73
74/**
75 * Warning.
76 *
77 * @returns
78 * @param pState .
79 * @param pszLoc .
80 * @param pszFormat .
81 * @param ... .
82 */
83void VFmtChkWarnFmt(PVFMTCHKSTATE pState, const char *pszLoc, const char *pszFormat, ...);
84
85/**
86 * Error.
87 *
88 * @returns
89 * @param pState .
90 * @param pszLoc .
91 * @param pszFormat .
92 * @param ... .
93 */
94void VFmtChkErrFmt(PVFMTCHKSTATE pState, const char *pszLoc, const char *pszFormat, ...);
95
96/**
97 * Checks that @a iFmtArg isn't present or a valid final dummy argument.
98 *
99 * Will issue warning/error if there are more arguments at @a iFmtArg.
100 *
101 * @param pState The format string checking state.
102 * @param iArg The index of the end of arguments, this is
103 * relative to VFMTCHKSTATE::iArgs.
104 */
105void VFmtChkVerifyEndOfArgs(PVFMTCHKSTATE pState, unsigned iArg);
106
107bool VFmtChkRequirePresentArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
108
109bool VFmtChkRequireIntArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
110
111bool VFmtChkRequireStringArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
112
113bool VFmtChkRequireVaListPtrArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
114
115/* VBoxCompilerPlugInsCommon.cpp */
116void MyCheckFormatCString(PVFMTCHKSTATE pState, const char *pszFmt);
117
118
119#endif
120
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