@@ -242,8 +242,7 @@ class simplecpp::TokenList::Stream {
242
242
virtual void unget () = 0;
243
243
virtual bool good () = 0;
244
244
245
- unsigned char readChar ()
246
- {
245
+ unsigned char readChar () {
247
246
unsigned char ch = static_cast <unsigned char >(get ());
248
247
249
248
// For UTF-16 encoded files the BOM is 0xfeff/0xfffe. If the
@@ -271,8 +270,7 @@ class simplecpp::TokenList::Stream {
271
270
return ch;
272
271
}
273
272
274
- unsigned char peekChar ()
275
- {
273
+ unsigned char peekChar () {
276
274
unsigned char ch = static_cast <unsigned char >(peek ());
277
275
278
276
// For UTF-16 encoded files the BOM is 0xfeff/0xfffe. If the
@@ -292,8 +290,7 @@ class simplecpp::TokenList::Stream {
292
290
return ch;
293
291
}
294
292
295
- void ungetChar ()
296
- {
293
+ void ungetChar () {
297
294
unget ();
298
295
if (isUtf16)
299
296
unget ();
@@ -308,13 +305,11 @@ class simplecpp::TokenList::Stream {
308
305
}
309
306
310
307
private:
311
- inline int makeUtf16Char (const unsigned char ch, const unsigned char ch2) const
312
- {
308
+ inline int makeUtf16Char (const unsigned char ch, const unsigned char ch2) const {
313
309
return (bom == 0xfeff ) ? (ch<<8 | ch2) : (ch2<<8 | ch);
314
310
}
315
311
316
- unsigned short getAndSkipBOM ()
317
- {
312
+ unsigned short getAndSkipBOM () {
318
313
const int ch1 = peek ();
319
314
320
315
// The UTF-16 BOM is 0xfffe or 0xfeff.
@@ -353,8 +348,7 @@ class StdIStream : public simplecpp::TokenList::Stream {
353
348
public:
354
349
// cppcheck-suppress uninitDerivedMemberVar - we call Stream::init() to initialize the private members
355
350
EXPLICIT StdIStream (std::istream &istr)
356
- : istr(istr)
357
- {
351
+ : istr(istr) {
358
352
assert (istr.good ());
359
353
init ();
360
354
}
@@ -383,8 +377,7 @@ class StdCharBufStream : public simplecpp::TokenList::Stream {
383
377
: str(str)
384
378
, size(size)
385
379
, pos(0 )
386
- , lastStatus(0 )
387
- {
380
+ , lastStatus(0 ) {
388
381
init ();
389
382
}
390
383
@@ -418,8 +411,7 @@ class FileStream : public simplecpp::TokenList::Stream {
418
411
EXPLICIT FileStream (const std::string &filename, std::vector<std::string> &files)
419
412
: file(fopen(filename.c_str(), "rb"))
420
413
, lastCh(0 )
421
- , lastStatus(0 )
422
- {
414
+ , lastStatus(0 ) {
423
415
if (!file) {
424
416
files.push_back (filename);
425
417
throw simplecpp::Output (files, simplecpp::Output::FILE_NOT_FOUND, " File is missing: " + filename);
@@ -455,8 +447,7 @@ class FileStream : public simplecpp::TokenList::Stream {
455
447
// TODO: use ungetc() as well
456
448
// UTF-16 has subsequent unget() calls
457
449
fseek (file, -1 , SEEK_CUR);
458
- }
459
- else
450
+ } else
460
451
ungetc (ch, file);
461
452
}
462
453
@@ -485,22 +476,19 @@ simplecpp::TokenList::TokenList(const unsigned char* data, std::size_t size, std
485
476
}
486
477
487
478
simplecpp::TokenList::TokenList (const char * data, std::size_t size, std::vector<std::string> &filenames, const std::string &filename, OutputList *outputList)
488
- : frontToken(nullptr ), backToken(nullptr ), files(filenames)
479
+ : frontToken(nullptr ), backToken(nullptr ), files(filenames)
489
480
{
490
481
StdCharBufStream stream (reinterpret_cast <const unsigned char *>(data), size);
491
482
readfile (stream,filename,outputList);
492
483
}
493
484
494
485
simplecpp::TokenList::TokenList (const std::string &filename, std::vector<std::string> &filenames, OutputList *outputList)
495
- : frontToken(nullptr ), backToken(nullptr ), files(filenames)
486
+ : frontToken(nullptr ), backToken(nullptr ), files(filenames)
496
487
{
497
- try
498
- {
488
+ try {
499
489
FileStream stream (filename, filenames);
500
490
readfile (stream,filename,outputList);
501
- }
502
- catch (const simplecpp::Output & e) // TODO handle extra type of errors
503
- {
491
+ } catch (const simplecpp::Output & e) { // TODO handle extra type of errors
504
492
outputList->push_back (e);
505
493
}
506
494
}
@@ -890,7 +878,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
890
878
else
891
879
back ()->setstr (prefix + s);
892
880
893
- if (newlines > 0 ) {
881
+ if (newlines > 0 ) {
894
882
const Token * const llTok = lastLineTok ();
895
883
if (llTok && llTok->op == ' #' && llTok->next && (llTok->next ->str () == " define" || llTok->next ->str () == " pragma" ) && llTok->next ->next ) {
896
884
multiline += newlines;
@@ -2009,14 +1997,14 @@ namespace simplecpp {
2009
1997
int paren = 1 ;
2010
1998
while (sameline (tok, tok->next )) {
2011
1999
if (tok->next ->str () == " (" )
2012
- ++paren;
2000
+ ++paren;
2013
2001
else if (tok->next ->str () == " )" )
2014
- --paren;
2002
+ --paren;
2015
2003
if (paren == 0 )
2016
- return tok->next ->next ;
2004
+ return tok->next ->next ;
2017
2005
tok = tok->next ;
2018
2006
if (parametertokens.size () > args.size () && parametertokens.front ()->next ->str () != " )" )
2019
- tok = expandToken (output, loc, tok, macros, expandedmacros, parametertokens)->previous ;
2007
+ tok = expandToken (output, loc, tok, macros, expandedmacros, parametertokens)->previous ;
2020
2008
}
2021
2009
}
2022
2010
throw Error (tok->location , " Missing parenthesis for __VA_OPT__(content)" );
@@ -2708,8 +2696,7 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
2708
2696
header += headerToken->str ();
2709
2697
// cppcheck-suppress selfAssignment - platform-dependent implementation
2710
2698
header = realFilename (header);
2711
- }
2712
- else {
2699
+ } else {
2713
2700
header = realFilename (tok1->str ().substr (1U , tok1->str ().size () - 2U ));
2714
2701
}
2715
2702
std::ifstream f;
@@ -3625,8 +3612,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
3625
3612
header = realFilename (header);
3626
3613
if (tok && tok->op == ' >' )
3627
3614
closingAngularBracket = true ;
3628
- }
3629
- else {
3615
+ } else {
3630
3616
header = realFilename (tok->str ().substr (1U , tok->str ().size () - 2U ));
3631
3617
closingAngularBracket = true ;
3632
3618
}
@@ -3799,25 +3785,24 @@ simplecpp::cstd_t simplecpp::getCStd(const std::string &std)
3799
3785
3800
3786
std::string simplecpp::getCStdString (cstd_t std)
3801
3787
{
3802
- switch (std)
3803
- {
3804
- case C89:
3805
- // __STDC_VERSION__ is not set for C90 although the macro was added in the 1994 amendments
3806
- return " " ;
3807
- case C99:
3808
- return " 199901L" ;
3809
- case C11:
3810
- return " 201112L" ;
3811
- case C17:
3812
- return " 201710L" ;
3813
- case C23:
3814
- // supported by GCC 9+ and Clang 9+
3815
- // Clang 9, 10, 11, 12, 13 return "201710L"
3816
- // Clang 14, 15, 16, 17 return "202000L"
3817
- // Clang 9, 10, 11, 12, 13, 14, 15, 16, 17 do not support "c23" and "gnu23"
3818
- return " 202311L" ;
3819
- case CUnknown:
3820
- return " " ;
3788
+ switch (std) {
3789
+ case C89:
3790
+ // __STDC_VERSION__ is not set for C90 although the macro was added in the 1994 amendments
3791
+ return " " ;
3792
+ case C99:
3793
+ return " 199901L" ;
3794
+ case C11:
3795
+ return " 201112L" ;
3796
+ case C17:
3797
+ return " 201710L" ;
3798
+ case C23:
3799
+ // supported by GCC 9+ and Clang 9+
3800
+ // Clang 9, 10, 11, 12, 13 return "201710L"
3801
+ // Clang 14, 15, 16, 17 return "202000L"
3802
+ // Clang 9, 10, 11, 12, 13, 14, 15, 16, 17 do not support "c23" and "gnu23"
3803
+ return " 202311L" ;
3804
+ case CUnknown:
3805
+ return " " ;
3821
3806
}
3822
3807
return " " ;
3823
3808
}
@@ -3848,30 +3833,29 @@ simplecpp::cppstd_t simplecpp::getCppStd(const std::string &std)
3848
3833
3849
3834
std::string simplecpp::getCppStdString (cppstd_t std)
3850
3835
{
3851
- switch (std)
3852
- {
3853
- case CPP03:
3854
- return " 199711L" ;
3855
- case CPP11:
3856
- return " 201103L" ;
3857
- case CPP14:
3858
- return " 201402L" ;
3859
- case CPP17:
3860
- return " 201703L" ;
3861
- case CPP20:
3862
- // GCC 10 returns "201703L" - correct in 11+
3863
- return " 202002L" ;
3864
- case CPP23:
3865
- // supported by GCC 11+ and Clang 12+
3866
- // GCC 11, 12, 13 return "202100L"
3867
- // Clang 12, 13, 14, 15, 16 do not support "c++23" and "gnu++23" and return "202101L"
3868
- // Clang 17, 18 return "202302L"
3869
- return " 202302L" ;
3870
- case CPP26:
3871
- // supported by Clang 17+
3872
- return " 202400L" ;
3873
- case CPPUnknown:
3874
- return " " ;
3836
+ switch (std) {
3837
+ case CPP03:
3838
+ return " 199711L" ;
3839
+ case CPP11:
3840
+ return " 201103L" ;
3841
+ case CPP14:
3842
+ return " 201402L" ;
3843
+ case CPP17:
3844
+ return " 201703L" ;
3845
+ case CPP20:
3846
+ // GCC 10 returns "201703L" - correct in 11+
3847
+ return " 202002L" ;
3848
+ case CPP23:
3849
+ // supported by GCC 11+ and Clang 12+
3850
+ // GCC 11, 12, 13 return "202100L"
3851
+ // Clang 12, 13, 14, 15, 16 do not support "c++23" and "gnu++23" and return "202101L"
3852
+ // Clang 17, 18 return "202302L"
3853
+ return " 202302L" ;
3854
+ case CPP26:
3855
+ // supported by Clang 17+
3856
+ return " 202400L" ;
3857
+ case CPPUnknown:
3858
+ return " " ;
3875
3859
}
3876
3860
return " " ;
3877
3861
}
0 commit comments