Skip to content

Commit 9dcd2b1

Browse files
authored
Merge pull request doxygen#11825 from artyom-fedosov/feature/clang
Add -Wcomma option for Clang
2 parents 41d5bbb + 1a3c4ac commit 9dcd2b1

File tree

4 files changed

+113
-27
lines changed

4 files changed

+113
-27
lines changed

cmake/CompilerWarnings.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function(set_project_warnings project_name)
6060
-Wdouble-promotion # warn if float is implicit promoted to double
6161
-Wformat=2 # warn on security issues around functions that format output
6262
# (ie printf)
63-
-Wpedantic # warn if non-standard C++ is used
63+
$<$<COMPILE_LANGUAGE:CXX>:-Wcomma>
6464

6565
# turn off warning caused by generated code (flex)
6666
-Wno-unused-parameter

src/definition.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,15 @@ static bool matchExcludedSymbols(const QCString &name)
164164
bool forceStart=FALSE;
165165
bool forceEnd=FALSE;
166166
if (pattern.at(0)=='^')
167-
pattern=pattern.mid(1),forceStart=TRUE;
168-
if (pattern.at(pattern.length()-1)=='$')
169-
pattern=pattern.left(pattern.length()-1),forceEnd=TRUE;
167+
{
168+
pattern = pattern.mid(1);
169+
forceStart = true;
170+
}
171+
if (pattern.at(pattern.length() - 1) == '$')
172+
{
173+
pattern = pattern.left(pattern.length() - 1);
174+
forceEnd = true;
175+
}
170176
if (pattern.find('*')!=-1) // wildcard mode
171177
{
172178
const reg::Ex re(substitute(pattern,"*",".*").str());
@@ -781,7 +787,8 @@ bool readCodeFragment(const QCString &fileName,bool isMacro,
781787
//printf("parsing char '%c'\n",c);
782788
if (c=='\n')
783789
{
784-
lineNr++,col=0;
790+
lineNr++;
791+
col = 0;
785792
}
786793
else if (c=='\t')
787794
{
@@ -790,13 +797,21 @@ bool readCodeFragment(const QCString &fileName,bool isMacro,
790797
else if (pc=='/' && c=='/') // skip single line comment
791798
{
792799
while ((c=*p++)!='\n' && c!=0);
793-
if (c=='\n') lineNr++,col=0;
800+
if (c == '\n')
801+
{
802+
lineNr++;
803+
col = 0;
804+
}
794805
}
795806
else if (pc=='/' && c=='*') // skip C style comment
796807
{
797808
while (((c=*p++)!='/' || pc!='*') && c!=0)
798809
{
799-
if (c=='\n') lineNr++,col=0;
810+
if (c == '\n')
811+
{
812+
lineNr++;
813+
col = 0;
814+
}
800815
pc=c;
801816
}
802817
}

src/doxygen.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11443,7 +11443,11 @@ static int computeIdealCacheParam(size_t v)
1144311443
//printf("computeIdealCacheParam(v=%u)\n",v);
1144411444

1144511445
int r=0;
11446-
while (v!=0) v>>=1,r++;
11446+
while (v!=0)
11447+
{
11448+
v >>= 1;
11449+
r++;
11450+
}
1144711451
// r = log2(v)
1144811452

1144911453
// convert to a valid cache size value

src/markdown.cpp

Lines changed: 86 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,11 @@ size_t Markdown::Private::findEmphasisChar(std::string_view data, char c, size_t
778778
if (data[i]=='`')
779779
{
780780
int snb=0;
781-
while (i<size && data[i]=='`') snb++,i++;
781+
while (i < size && data[i] == '`')
782+
{
783+
snb++;
784+
i++;
785+
}
782786

783787
// find same pattern to end the span
784788
int enb=0;
@@ -977,11 +981,13 @@ int Markdown::Private::processNmdash(std::string_view data,size_t offset)
977981
int count=1;
978982
if (i<size && data[i]=='-') // found --
979983
{
980-
count++,i++;
984+
count++;
985+
i++;
981986
}
982987
if (i<size && data[i]=='-') // found ---
983988
{
984-
count++,i++;
989+
count++;
990+
i++;
985991
}
986992
if (i<size && data[i]=='-') // found ----
987993
{
@@ -1045,7 +1051,11 @@ int Markdown::Private::processHtmlTagWrite(std::string_view data,size_t offset,b
10451051
size_t i=1;
10461052
size_t l=0;
10471053
// compute length of the tag name
1048-
while (i<size && isIdChar(data[i])) i++,l++;
1054+
while (i < size && isIdChar(data[i]))
1055+
{
1056+
i++;
1057+
l++;
1058+
}
10491059
QCString tagName(data.substr(1,i-1));
10501060
if (tagName.lower()=="pre") // found <pre> tag
10511061
{
@@ -1895,7 +1905,11 @@ int Markdown::Private::isHeaderline(std::string_view data, bool allowAdjustLevel
18951905
// test of level 1 header
18961906
if (data[i]=='=')
18971907
{
1898-
while (i<size && data[i]=='=') i++,c++;
1908+
while (i < size && data[i] == '=')
1909+
{
1910+
i++;
1911+
c++;
1912+
}
18991913
while (i<size && data[i]==' ') i++;
19001914
int level = (c>1 && (i>=size || data[i]=='\n')) ? 1 : 0;
19011915
if (allowAdjustLevel && level==1 && indentLevel==-1)
@@ -1913,7 +1927,11 @@ int Markdown::Private::isHeaderline(std::string_view data, bool allowAdjustLevel
19131927
// test of level 2 header
19141928
if (data[i]=='-')
19151929
{
1916-
while (i<size && data[i]=='-') i++,c++;
1930+
while (i < size && data[i] == '-')
1931+
{
1932+
i++;
1933+
c++;
1934+
}
19171935
while (i<size && data[i]==' ') i++;
19181936
return (c>1 && (i>=size || data[i]=='\n')) ? indentLevel+2 : 0;
19191937
}
@@ -2117,12 +2135,20 @@ int Markdown::Private::isAtxHeader(std::string_view data,
21172135
{
21182136
return 0;
21192137
}
2120-
while (i<size && data[i]=='#') i++,level++;
2138+
while (i < size && data[i] == '#')
2139+
{
2140+
i++;
2141+
level++;
2142+
}
21212143
if (level>SectionType::MaxLevel) // too many #'s -> no section
21222144
{
21232145
return 0;
21242146
}
2125-
while (i<size && data[i]==' ') i++,blanks++;
2147+
while (i < size && data[i] == ' ')
2148+
{
2149+
i++;
2150+
blanks++;
2151+
}
21262152
if (level==1 && blanks==0)
21272153
{
21282154
return 0; // special case to prevent #someid seen as a header (see bug 671395)
@@ -2255,7 +2281,8 @@ static size_t computeIndentExcludingListMarkers(std::string_view data)
22552281
{ // end of indent
22562282
break;
22572283
}
2258-
indent++,i++;
2284+
indent++;
2285+
i++;
22592286
}
22602287
AUTO_TRACE_EXIT("result={}",indent);
22612288
return indent;
@@ -2313,15 +2340,23 @@ static bool isFencedCodeBlock(std::string_view data,size_t refIndent,
23132340
size_t indent=0;
23142341
int startTildes=0;
23152342
const size_t size = data.size();
2316-
while (i<size && data[i]==' ') indent++,i++;
2343+
while (i < size && data[i] == ' ')
2344+
{
2345+
indent++;
2346+
i++;
2347+
}
23172348
if (indent>=refIndent+4)
23182349
{
23192350
AUTO_TRACE_EXIT("result=false: content is part of code block indent={} refIndent={}",indent,refIndent);
23202351
return FALSE;
23212352
} // part of code block
23222353
char tildaChar='~';
23232354
if (i<size && data[i]=='`') tildaChar='`';
2324-
while (i<size && data[i]==tildaChar) startTildes++,i++;
2355+
while (i < size && data[i] == tildaChar)
2356+
{
2357+
startTildes++;
2358+
i++;
2359+
}
23252360
if (startTildes<3)
23262361
{
23272362
AUTO_TRACE_EXIT("result=false: no fence marker found #tildes={}",startTildes);
@@ -2367,7 +2402,11 @@ static bool isFencedCodeBlock(std::string_view data,size_t refIndent,
23672402
{
23682403
end=i;
23692404
int endTildes=0;
2370-
while (i<size && data[i]==tildaChar) endTildes++,i++;
2405+
while (i < size && data[i] == tildaChar)
2406+
{
2407+
endTildes++;
2408+
i++;
2409+
}
23712410
while (i<size && data[i]==' ') i++;
23722411
{
23732412
if (endTildes==startTildes)
@@ -2392,7 +2431,11 @@ static bool isCodeBlock(std::string_view data, size_t offset,size_t &indent)
23922431
size_t i=0;
23932432
size_t indent0=0;
23942433
const size_t size = data.size();
2395-
while (i<size && data[i]==' ') indent0++,i++;
2434+
while (i < size && data[i] == ' ')
2435+
{
2436+
indent0++;
2437+
i++;
2438+
}
23962439

23972440
if (indent0<codeBlockIndent)
23982441
{
@@ -2484,7 +2527,11 @@ static size_t findTableColumns(std::string_view data,size_t &start,size_t &end,s
24842527
size_t i=0,n=0;
24852528
// find start character of the table line
24862529
while (i<size && data[i]==' ') i++;
2487-
if (i<size && data[i]=='|' && data[i]!='\n') i++,n++; // leading | does not count
2530+
if (i < size && data[i] == '|' && data[i] != '\n')
2531+
{
2532+
i++;
2533+
n++; // leading | does not count
2534+
}
24882535
start = i;
24892536

24902537
// find end character of the table line
@@ -2494,7 +2541,11 @@ static size_t findTableColumns(std::string_view data,size_t &start,size_t &end,s
24942541

24952542
if (j>0 && i>0) i--; // move i to point before newline
24962543
while (i>0 && data[i]==' ') i--;
2497-
if (i>0 && data[i-1]!='\\' && data[i]=='|') i--,n++; // trailing or escaped | does not count
2544+
if (i > 0 && data[i - 1] != '\\' && data[i] == '|')
2545+
{
2546+
i--;
2547+
n++; // trailing or escaped | does not count
2548+
}
24982549
end = i;
24992550

25002551
// count columns between start and end
@@ -2980,7 +3031,11 @@ bool skipOverFileAndLineCommands(std::string_view data,size_t indent,size_t &off
29803031
i+=9;
29813032
location=data.substr(locStart,i-locStart);
29823033
location+='\n';
2983-
while (indent>0 && i<size && data[i]==' ') i++,indent--;
3034+
while (indent > 0 && i < size && data[i] == ' ')
3035+
{
3036+
i++;
3037+
indent--;
3038+
}
29843039
if (i<size && data[i]=='\n') i++;
29853040
offset = i;
29863041
return true;
@@ -3005,7 +3060,11 @@ size_t Markdown::Private::writeCodeBlock(std::string_view data,size_t refIndent)
30053060
while (end<=size && data[end-1]!='\n') end++;
30063061
size_t j=i;
30073062
size_t indent=0;
3008-
while (j<end && data[j]==' ') j++,indent++;
3063+
while (j < end && data[j] == ' ')
3064+
{
3065+
j++;
3066+
indent++;
3067+
}
30093068
//printf("j=%d end=%d indent=%d refIndent=%d tabSize=%d data={%s}\n",
30103069
// j,end,indent,refIndent,Config_getInt(TAB_SIZE),qPrint(QCString(data+i).left(end-i-1)));
30113070
if (j==end-1) // empty line
@@ -3111,12 +3170,20 @@ size_t Markdown::Private::findEndOfLine(std::string_view data,size_t offset)
31113170
}
31123171
else if (nb==0 && data[end-1]=='`')
31133172
{
3114-
while (end<=size && data[end-1]=='`') end++,nb++;
3173+
while (end <= size && data[end - 1] == '`')
3174+
{
3175+
end++;
3176+
nb++;
3177+
}
31153178
}
31163179
else if (nb>0 && data[end-1]=='`')
31173180
{
31183181
size_t enb=0;
3119-
while (end<=size && data[end-1]=='`') end++,enb++;
3182+
while (end <= size && data[end - 1] == '`')
3183+
{
3184+
end++;
3185+
enb++;
3186+
}
31203187
if (enb==nb) nb=0;
31213188
}
31223189
else

0 commit comments

Comments
 (0)