Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
1ed9af9a
Kaydet (Commit)
1ed9af9a
authored
Kas 20, 2012
tarafından
Luboš Luňák
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
skip 'else' from a macro expansion too
Change-Id: I1a6d70d1554dc5bf8f46940ed62b47ab34983aa7
üst
13cca3de
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
+11
-9
bodynotinblock.cxx
compilerplugins/clang/bodynotinblock.cxx
+9
-8
bodynotinblock.hxx
compilerplugins/clang/bodynotinblock.hxx
+2
-1
No files found.
compilerplugins/clang/bodynotinblock.cxx
Dosyayı görüntüle @
1ed9af9a
...
@@ -56,15 +56,15 @@ void BodyNotInBlock::traverseStatement( const Stmt* stmt, StmtParents& parents )
...
@@ -56,15 +56,15 @@ void BodyNotInBlock::traverseStatement( const Stmt* stmt, StmtParents& parents )
parents
.
push_back
(
*
it
);
parents
.
push_back
(
*
it
);
if
(
const
IfStmt
*
ifstmt
=
dyn_cast
<
IfStmt
>
(
*
it
))
if
(
const
IfStmt
*
ifstmt
=
dyn_cast
<
IfStmt
>
(
*
it
))
{
{
checkBody
(
ifstmt
->
getThen
(),
parents
,
0
,
ifstmt
->
getElse
()
!=
NULL
);
checkBody
(
ifstmt
->
getThen
(),
ifstmt
->
getIfLoc
(),
parents
,
0
,
ifstmt
->
getElse
()
!=
NULL
);
checkBody
(
ifstmt
->
getElse
(),
parents
,
0
);
checkBody
(
ifstmt
->
getElse
(),
ifstmt
->
getElseLoc
(),
parents
,
0
);
}
}
else
if
(
const
WhileStmt
*
whilestmt
=
dyn_cast
<
WhileStmt
>
(
*
it
))
else
if
(
const
WhileStmt
*
whilestmt
=
dyn_cast
<
WhileStmt
>
(
*
it
))
checkBody
(
whilestmt
->
getBody
(),
parents
,
1
);
checkBody
(
whilestmt
->
getBody
(),
whilestmt
->
getWhileLoc
(),
parents
,
1
);
else
if
(
const
ForStmt
*
forstmt
=
dyn_cast
<
ForStmt
>
(
*
it
))
else
if
(
const
ForStmt
*
forstmt
=
dyn_cast
<
ForStmt
>
(
*
it
))
checkBody
(
forstmt
->
getBody
(),
parents
,
2
);
checkBody
(
forstmt
->
getBody
(),
forstmt
->
getForLoc
(),
parents
,
2
);
else
if
(
const
CXXForRangeStmt
*
forstmt
=
dyn_cast
<
CXXForRangeStmt
>
(
*
it
))
else
if
(
const
CXXForRangeStmt
*
forstmt
=
dyn_cast
<
CXXForRangeStmt
>
(
*
it
))
checkBody
(
forstmt
->
getBody
(),
parents
,
2
);
checkBody
(
forstmt
->
getBody
(),
forstmt
->
getForLoc
(),
parents
,
2
);
parents
.
pop_back
();
parents
.
pop_back
();
}
}
}
}
...
@@ -72,16 +72,17 @@ void BodyNotInBlock::traverseStatement( const Stmt* stmt, StmtParents& parents )
...
@@ -72,16 +72,17 @@ void BodyNotInBlock::traverseStatement( const Stmt* stmt, StmtParents& parents )
parents
.
pop_back
();
parents
.
pop_back
();
}
}
void
BodyNotInBlock
::
checkBody
(
const
Stmt
*
body
,
const
StmtParents
&
parents
,
int
stmtType
,
bool
dontGoUp
)
void
BodyNotInBlock
::
checkBody
(
const
Stmt
*
body
,
SourceLocation
stmtLocation
,
const
StmtParents
&
parents
,
int
stmtType
,
bool
dontGoUp
)
{
{
if
(
body
==
NULL
||
parents
.
size
()
<
2
)
if
(
body
==
NULL
||
parents
.
size
()
<
2
)
return
;
return
;
// TODO: If the if/while/for comes from a macro expansion, ignore it completely for
// TODO: If the if/
else/
while/for comes from a macro expansion, ignore it completely for
// now. The code below could assume everything is in the same place (and thus also column)
// now. The code below could assume everything is in the same place (and thus also column)
// and give a false warning. Moreover some macros are rather lousily written and would
// and give a false warning. Moreover some macros are rather lousily written and would
// result in poor formatting. To be evaluated later, maybe this could be handled
// result in poor formatting. To be evaluated later, maybe this could be handled
// including macro expansion.
// including macro expansion.
if
(
parents
.
back
()
->
getLocStart
()
.
isMacroID
())
if
(
stmtLocation
.
isMacroID
())
return
;
return
;
if
(
dyn_cast
<
CompoundStmt
>
(
body
))
if
(
dyn_cast
<
CompoundStmt
>
(
body
))
return
;
// if body is a compound statement, then it is in {}
return
;
// if body is a compound statement, then it is in {}
...
...
compilerplugins/clang/bodynotinblock.hxx
Dosyayı görüntüle @
1ed9af9a
...
@@ -27,7 +27,8 @@ class BodyNotInBlock
...
@@ -27,7 +27,8 @@ class BodyNotInBlock
private
:
private
:
typedef
vector
<
const
Stmt
*
>
StmtParents
;
typedef
vector
<
const
Stmt
*
>
StmtParents
;
void
traverseStatement
(
const
Stmt
*
stmt
,
StmtParents
&
parents
);
void
traverseStatement
(
const
Stmt
*
stmt
,
StmtParents
&
parents
);
void
checkBody
(
const
Stmt
*
body
,
const
StmtParents
&
parents
,
int
stmtType
,
bool
dontGoUp
=
false
);
void
checkBody
(
const
Stmt
*
body
,
SourceLocation
stmtLocation
,
const
StmtParents
&
parents
,
int
stmtType
,
bool
dontGoUp
=
false
);
};
};
}
// namespace
}
// namespace
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment