VirtualBox

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

Last change on this file since 57002 was 57002, checked in by vboxsync, 10 years ago

gccplugin: Use error_at instead of warning_at when there are too many or too few arguments. Implemented %M.

  • 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 57002 2015-07-18 23:44:13Z vboxsync $ */
2/** @file
3 * VBoxCompilerPlugIns - Types, Prototypes and Macros common to the VBox compiler plug-ins.
4 */
5
6/*
7 * Copyright (C) 2006-2015 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. 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#if defined(__GNUC__) && !defined(VBOX_COMPILER_PLUG_IN_AGNOSTIC)
44 gimple hStmt;
45 location_t hFmtLoc;
46#endif
47} VFMTCHKSTATE;
48/** Pointer to my checker state. */
49typedef VFMTCHKSTATE *PVFMTCHKSTATE;
50
51#define MYSTATE_FMT_FILE(a_pState) VFmtChkGetFmtLocFile(a_pState)
52#define MYSTATE_FMT_LINE(a_pState) VFmtChkGetFmtLocLine(a_pState)
53#define MYSTATE_FMT_COLUMN(a_pState) VFmtChkGetFmtLocColumn(a_pState)
54
55const char *VFmtChkGetFmtLocFile(PVFMTCHKSTATE pState);
56
57unsigned int VFmtChkGetFmtLocLine(PVFMTCHKSTATE pState);
58
59unsigned int VFmtChkGetFmtLocColumn(PVFMTCHKSTATE pState);
60
61/**
62 * Implements checking format string replacement (%M).
63 *
64 * Caller will have checked all that can be checked. This means that there is a
65 * string argument present, or it won't make the call.
66 *
67 * @param pState The format string checking state.
68 * @param pszPctM The position of the '%M'.
69 * @param iArg The next argument number.
70 */
71void VFmtChkHandleReplacementFormatString(PVFMTCHKSTATE pState, const char *pszPctM, unsigned iArg);
72
73/**
74 * Warning.
75 *
76 * @returns
77 * @param pState .
78 * @param pszLoc .
79 * @param pszFormat .
80 * @param ... .
81 */
82void VFmtChkWarnFmt(PVFMTCHKSTATE pState, const char *pszLoc, const char *pszFormat, ...);
83
84/**
85 * Error.
86 *
87 * @returns
88 * @param pState .
89 * @param pszLoc .
90 * @param pszFormat .
91 * @param ... .
92 */
93void VFmtChkErrFmt(PVFMTCHKSTATE pState, const char *pszLoc, const char *pszFormat, ...);
94
95/**
96 * Checks that @a iFmtArg isn't present or a valid final dummy argument.
97 *
98 * Will issue warning/error if there are more arguments at @a iFmtArg.
99 *
100 * @param pState The format string checking state.
101 * @param iArg The index of the end of arguments, this is
102 * relative to VFMTCHKSTATE::iArgs.
103 */
104void VFmtChkVerifyEndOfArgs(PVFMTCHKSTATE pState, unsigned iArg);
105
106bool VFmtChkRequirePresentArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
107
108bool VFmtChkRequireIntArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
109
110bool VFmtChkRequireStringArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
111
112bool VFmtChkRequireVaListPtrArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage);
113
114/* VBoxCompilerPlugInsCommon.cpp */
115void MyCheckFormatCString(PVFMTCHKSTATE pState, const char *pszFmt);
116
117
118#endif
119
Note: See TracBrowser for help on using the repository browser.

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