diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 03:01:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 03:01:46 +0000 |
commit | f8fe689a81f906d1b91bb3220acde2a4ecb14c5b (patch) | |
tree | 26484e9d7e2c67806c2d1760196ff01aaa858e8c /src/bldprogs/VBoxCompilerPlugIns.h | |
parent | Initial commit. (diff) | |
download | virtualbox-f8fe689a81f906d1b91bb3220acde2a4ecb14c5b.tar.xz virtualbox-f8fe689a81f906d1b91bb3220acde2a4ecb14c5b.zip |
Adding upstream version 6.0.4-dfsg.upstream/6.0.4-dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/bldprogs/VBoxCompilerPlugIns.h')
-rw-r--r-- | src/bldprogs/VBoxCompilerPlugIns.h | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/src/bldprogs/VBoxCompilerPlugIns.h b/src/bldprogs/VBoxCompilerPlugIns.h new file mode 100644 index 00000000..6fc656b4 --- /dev/null +++ b/src/bldprogs/VBoxCompilerPlugIns.h @@ -0,0 +1,127 @@ +/* $Id: VBoxCompilerPlugIns.h $ */ +/** @file + * VBoxCompilerPlugIns - Types, Prototypes and Macros common to the VBox compiler plug-ins. + */ + +/* + * Copyright (C) 2006-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#ifndef VBOX_INCLUDED_SRC_bldprogs_VBoxCompilerPlugIns_h +#define VBOX_INCLUDED_SRC_bldprogs_VBoxCompilerPlugIns_h +#ifndef RT_WITHOUT_PRAGMA_ONCE +# pragma once +#endif + +#include <iprt/types.h> +#include <stdio.h> + + +/** @def dprintf + * Macro for debug printing using fprintf. Only active when DEBUG is defined. + */ +#ifdef DEBUG +# define dprintf(...) do { fprintf(stderr, __VA_ARGS__); } while (0) +#else +# define dprintf(...) do { } while (0) +#endif + + +/** + * Checker state. + */ +typedef struct VFMTCHKSTATE +{ + long iFmt; + long iArgs; + const char *pszFmt; + bool fMaybeNull; +#if defined(__GNUC__) && !defined(VBOX_COMPILER_PLUG_IN_AGNOSTIC) +# if RT_GNUC_PREREQ(6, 0) + gimple const *hStmt; +# else + gimple hStmt; +# endif + location_t hFmtLoc; +#endif +} VFMTCHKSTATE; +/** Pointer to my checker state. */ +typedef VFMTCHKSTATE *PVFMTCHKSTATE; + +#define MYSTATE_FMT_FILE(a_pState) VFmtChkGetFmtLocFile(a_pState) +#define MYSTATE_FMT_LINE(a_pState) VFmtChkGetFmtLocLine(a_pState) +#define MYSTATE_FMT_COLUMN(a_pState) VFmtChkGetFmtLocColumn(a_pState) + +const char *VFmtChkGetFmtLocFile(PVFMTCHKSTATE pState); + +unsigned int VFmtChkGetFmtLocLine(PVFMTCHKSTATE pState); + +unsigned int VFmtChkGetFmtLocColumn(PVFMTCHKSTATE pState); + +/** + * Implements checking format string replacement (%M). + * + * Caller will have checked all that can be checked. This means that there is a + * string argument present, or it won't make the call. + * + * @param pState The format string checking state. + * @param pszPctM The position of the '%M'. + * @param iArg The next argument number. + */ +void VFmtChkHandleReplacementFormatString(PVFMTCHKSTATE pState, const char *pszPctM, unsigned iArg); + +/** + * Warning. + * + * @returns + * @param pState . + * @param pszLoc . + * @param pszFormat . + * @param ... . + */ +void VFmtChkWarnFmt(PVFMTCHKSTATE pState, const char *pszLoc, const char *pszFormat, ...); + +/** + * Error. + * + * @returns + * @param pState . + * @param pszLoc . + * @param pszFormat . + * @param ... . + */ +void VFmtChkErrFmt(PVFMTCHKSTATE pState, const char *pszLoc, const char *pszFormat, ...); + +/** + * Checks that @a iFmtArg isn't present or a valid final dummy argument. + * + * Will issue warning/error if there are more arguments at @a iFmtArg. + * + * @param pState The format string checking state. + * @param iArg The index of the end of arguments, this is + * relative to VFMTCHKSTATE::iArgs. + */ +void VFmtChkVerifyEndOfArgs(PVFMTCHKSTATE pState, unsigned iArg); + +bool VFmtChkRequirePresentArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage); + +bool VFmtChkRequireIntArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage); + +bool VFmtChkRequireStringArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage); + +bool VFmtChkRequireVaListPtrArg(PVFMTCHKSTATE pState, const char *pszLoc, unsigned iArg, const char *pszMessage); + +/* VBoxCompilerPlugInsCommon.cpp */ +void MyCheckFormatCString(PVFMTCHKSTATE pState, const char *pszFmt); + + +#endif /* !VBOX_INCLUDED_SRC_bldprogs_VBoxCompilerPlugIns_h */ + |