cprover
c_preprocess.cpp File Reference
#include "c_preprocess.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <util/c_types.h>
#include <util/config.h>
#include <util/message.h>
#include <util/tempfile.h>
#include <util/unicode.h>
#include <util/arith_tools.h>
#include <util/std_types.h>
#include <util/prefix.h>
Include dependency graph for c_preprocess.cpp:

Go to the source code of this file.

Macros

#define GCC_DEFINES_16
 
#define GCC_DEFINES_32
 
#define GCC_DEFINES_LP64
 
#define GCC_DEFINES_LLP64
 

Functions

static std::string type_max (const typet &src)
 produce a string with the maximum value of a given type More...
 
static std::string shell_quote (const std::string &src)
 quote a string for bash and CMD More...
 
static void error_parse_line (const std::string &line, bool warning_only, messaget &message)
 
static void error_parse (std::istream &errors, bool warning_only, messaget &message)
 
bool c_preprocess (std::istream &instream, std::ostream &outstream, message_handlert &message_handler)
 ANSI-C preprocessing. More...
 
static bool is_dot_i_file (const std::string &path)
 ANSI-C preprocessing. More...
 
bool c_preprocess_codewarrior (const std::string &, std::ostream &, message_handlert &)
 ANSI-C preprocessing. More...
 
bool c_preprocess_arm (const std::string &file, std::ostream &outstream, message_handlert &message_handler)
 ANSI-C preprocessing. More...
 
bool c_preprocess_gcc_clang (const std::string &file, std::ostream &outstream, message_handlert &message_handler, configt::ansi_ct::preprocessort preprocessor)
 ANSI-C preprocessing. More...
 
bool c_preprocess_none (const std::string &file, std::ostream &outstream, message_handlert &message_handler)
 ANSI-C preprocessing. More...
 
bool c_preprocess_visual_studio (const std::string &file, std::ostream &outstream, message_handlert &message_handler)
 ANSI-C preprocessing. More...
 
bool c_preprocess (const std::string &path, std::ostream &outstream, message_handlert &message_handler)
 
void postprocess_codewarrior (std::istream &instream, std::ostream &outstream)
 post-processing specifically for CodeWarrior More...
 
bool test_c_preprocessor (message_handlert &message_handler)
 

Variables

const char c_test_program []
 tests ANSI-C preprocessing More...
 

Macro Definition Documentation

◆ GCC_DEFINES_16

#define GCC_DEFINES_16
Value:
" -D__INT_MAX__=32767"\
" -D__CHAR_BIT__=8"\
" -D__SCHAR_MAX__=127"\
" -D__SHRT_MAX__=32767"\
" -D__INT32_TYPE__=long"\
" -D__LONG_LONG_MAX__=2147483647L"\
" -D__LONG_MAX__=2147483647" \
" -D__SIZE_TYPE__=\"unsigned int\""\
" -D__PTRDIFF_TYPE__=int"\
" -D__WINT_TYPE__=\"unsigned int\""\
" -D__INTMAX_TYPE__=\"long long int\""\
" -D__UINTMAX_TYPE__=\"long long unsigned int\""\
" -D__INTPTR_TYPE__=\"int\""\
" -D__UINTPTR_TYPE__=\"unsigned int\""

Definition at line 35 of file c_preprocess.cpp.

Referenced by c_preprocess_arm(), and c_preprocess_gcc_clang().

◆ GCC_DEFINES_32

#define GCC_DEFINES_32
Value:
" -D__INT_MAX__=2147483647"\
" -D__CHAR_BIT__=8"\
" -D__SCHAR_MAX__=127"\
" -D__SHRT_MAX__=32767"\
" -D__INT32_TYPE__=int"\
" -D__LONG_LONG_MAX__=9223372036854775807LL"\
" -D__LONG_MAX__=2147483647L" \
" -D__SIZE_TYPE__=\"long unsigned int\""\
" -D__PTRDIFF_TYPE__=int"\
" -D__WINT_TYPE__=\"unsigned int\""\
" -D__INTMAX_TYPE__=\"long long int\""\
" -D__UINTMAX_TYPE__=\"long long unsigned int\""\
" -D__INTPTR_TYPE__=\"long int\""\
" -D__UINTPTR_TYPE__=\"long unsigned int\""

Definition at line 51 of file c_preprocess.cpp.

Referenced by c_preprocess_arm(), and c_preprocess_gcc_clang().

◆ GCC_DEFINES_LLP64

#define GCC_DEFINES_LLP64
Value:
" -D__INT_MAX__=2147483647"\
" -D__CHAR_BIT__=8"\
" -D__SCHAR_MAX__=127"\
" -D__SHRT_MAX__=32767"\
" -D__INT32_TYPE__=int"\
" -D__LONG_LONG_MAX__=9223372036854775807LL"\
" -D__LONG_MAX__=2147483647"\
" -D__SIZE_TYPE__=\"long long unsigned int\""\
" -D__PTRDIFF_TYPE__=\"long long\""\
" -D__WINT_TYPE__=\"unsigned int\""\
" -D__INTMAX_TYPE__=\"long long int\""\
" -D__UINTMAX_TYPE__=\"long long unsigned int\""\
" -D__INTPTR_TYPE__=\"long long int\""\
" -D__UINTPTR_TYPE__=\"long long unsigned int\""

Definition at line 83 of file c_preprocess.cpp.

Referenced by c_preprocess_gcc_clang().

◆ GCC_DEFINES_LP64

#define GCC_DEFINES_LP64
Value:
" -D__INT_MAX__=2147483647"\
" -D__CHAR_BIT__=8"\
" -D__SCHAR_MAX__=127"\
" -D__SHRT_MAX__=32767"\
" -D__INT32_TYPE__=int"\
" -D__LONG_LONG_MAX__=9223372036854775807LL"\
" -D__LONG_MAX__=9223372036854775807L"\
" -D__SIZE_TYPE__=\"long unsigned int\""\
" -D__PTRDIFF_TYPE__=long"\
" -D__WINT_TYPE__=\"unsigned int\""\
" -D__INTMAX_TYPE__=\"long int\""\
" -D__UINTMAX_TYPE__=\"long unsigned int\""\
" -D__INTPTR_TYPE__=\"long int\""\
" -D__UINTPTR_TYPE__=\"long unsigned int\""

Definition at line 67 of file c_preprocess.cpp.

Referenced by c_preprocess_arm(), and c_preprocess_gcc_clang().

Function Documentation

◆ c_preprocess() [1/2]

bool c_preprocess ( std::istream &  instream,
std::ostream &  outstream,
message_handlert message_handler 
)

◆ c_preprocess() [2/2]

◆ c_preprocess_arm()

◆ c_preprocess_codewarrior()

bool c_preprocess_codewarrior ( const std::string &  file,
std::ostream &  outstream,
message_handlert message_handler 
)

◆ c_preprocess_gcc_clang()

◆ c_preprocess_none()

bool c_preprocess_none ( const std::string &  file,
std::ostream &  outstream,
message_handlert message_handler 
)

◆ c_preprocess_visual_studio()

bool c_preprocess_visual_studio ( const std::string &  file,
std::ostream &  outstream,
message_handlert message_handler 
)

◆ error_parse()

static void error_parse ( std::istream &  errors,
bool  warning_only,
messaget message 
)
static

◆ error_parse_line()

static void error_parse_line ( const std::string &  line,
bool  warning_only,
messaget message 
)
static

◆ is_dot_i_file()

static bool is_dot_i_file ( const std::string &  path)
static

ANSI-C preprocessing.

Definition at line 344 of file c_preprocess.cpp.

Referenced by c_preprocess_arm(), c_preprocess_codewarrior(), c_preprocess_gcc_clang(), and c_preprocess_visual_studio().

◆ postprocess_codewarrior()

void postprocess_codewarrior ( std::istream &  instream,
std::ostream &  outstream 
)

post-processing specifically for CodeWarrior

Definition at line 512 of file c_preprocess.cpp.

Referenced by c_preprocess_codewarrior(), and c_preprocess_none().

◆ shell_quote()

static std::string shell_quote ( const std::string &  src)
static

quote a string for bash and CMD

Definition at line 113 of file c_preprocess.cpp.

Referenced by c_preprocess_arm(), c_preprocess_codewarrior(), c_preprocess_gcc_clang(), and c_preprocess_visual_studio().

◆ test_c_preprocessor()

bool test_c_preprocessor ( message_handlert message_handler)

Definition at line 1087 of file c_preprocess.cpp.

References c_preprocess(), and c_test_program.

Referenced by cbmc_parse_optionst::doit().

◆ type_max()

static std::string type_max ( const typet src)
static

produce a string with the maximum value of a given type

Definition at line 100 of file c_preprocess.cpp.

References irept::id(), integer2string(), power(), to_signedbv_type(), and to_unsignedbv_type().

Referenced by c_preprocess_gcc_clang().

Variable Documentation

◆ c_test_program

const char c_test_program[]
Initial value:
=
"#include <stdlib.h>\n"
"\n"
"int main() { }\n"

tests ANSI-C preprocessing

Definition at line 1082 of file c_preprocess.cpp.

Referenced by test_c_preprocessor().