comparison gen/logger.h @ 1372:229e02867307

Fix format-string bugs by adding __attribute__((__format__)) in all applicable places and fixing all warnings my gcc produced. Among other things, this should fix several segfaults (including one I just ran into).
author Frits van Bommel <fvbommel wxs.nl>
date Sun, 17 May 2009 00:15:25 +0200
parents 79758fd2f48a
children 2292878925f4
comparison
equal deleted inserted replaced
1371:967d28b7febe 1372:229e02867307
1 #ifndef _llvmd_gen_logger_h_ 1 #ifndef _llvmd_gen_logger_h_
2 #define _llvmd_gen_logger_h_ 2 #define _llvmd_gen_logger_h_
3 3
4 #include "llvm/Support/Streams.h" 4 #include "llvm/Support/Streams.h"
5
6 #ifndef IS_PRINTF
7 # ifdef __GNUC__
8 # define IS_PRINTF(FMTARG) __attribute((__format__ (__printf__, (FMTARG), (FMTARG)+1) ))
9 # else
10 # define IS_PRINTF(FMTARG)
11 # endif
12 #endif
5 13
6 struct Loc; 14 struct Loc;
7 15
8 namespace Logger 16 namespace Logger
9 { 17 {
10 void indent(); 18 void indent();
11 void undent(); 19 void undent();
12 llvm::OStream cout(); 20 llvm::OStream cout();
13 void println(const char* fmt, ...); 21 void println(const char* fmt, ...) IS_PRINTF(1);
14 void print(const char* fmt, ...); 22 void print(const char* fmt, ...) IS_PRINTF(1);
15 void enable(); 23 void enable();
16 void disable(); 24 void disable();
17 bool enabled(); 25 bool enabled();
18 26
19 void attention(Loc loc, const char* fmt, ...); 27 void attention(Loc loc, const char* fmt, ...) IS_PRINTF(2);
20 28
21 struct LoggerScope 29 struct LoggerScope
22 { 30 {
23 LoggerScope() 31 LoggerScope()
24 { 32 {