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
f9889a69
Kaydet (Commit)
f9889a69
authored
Haz 27, 2016
tarafından
Noel Grandin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
check for field being returned by non-const ref
Change-Id: I660c98dcbfa6052628ff667886981d075f34b2b7
üst
e4b33235
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
singlevalfields.cxx
compilerplugins/clang/singlevalfields.cxx
+17
-3
No files found.
compilerplugins/clang/singlevalfields.cxx
Dosyayı görüntüle @
f9889a69
...
...
@@ -190,7 +190,8 @@ bool SingleValFields::VisitMemberExpr( const MemberExpr* memberExpr )
if
(
ignoreLocation
(
memberExpr
)
||
!
isInterestingType
(
fieldDecl
->
getType
()))
return
true
;
const
CXXMethodDecl
*
methodDecl
=
dyn_cast_or_null
<
CXXMethodDecl
>
(
get_top_FunctionDecl_from_Stmt
(
*
memberExpr
));
const
FunctionDecl
*
parentFunctionDecl
=
get_top_FunctionDecl_from_Stmt
(
*
memberExpr
);
const
CXXMethodDecl
*
methodDecl
=
dyn_cast_or_null
<
CXXMethodDecl
>
(
parentFunctionDecl
);
if
(
methodDecl
&&
(
methodDecl
->
isCopyAssignmentOperator
()
||
methodDecl
->
isMoveAssignmentOperator
()))
return
true
;
...
...
@@ -200,7 +201,20 @@ bool SingleValFields::VisitMemberExpr( const MemberExpr* memberExpr )
bool
bPotentiallyAssignedTo
=
false
;
bool
bDump
=
false
;
std
::
string
assignValue
;
do
{
// check for field being returned by non-const ref eg. Foo& getFoo() { return f; }
if
(
parent
&&
isa
<
ReturnStmt
>
(
parent
))
{
const
Stmt
*
parent2
=
parentStmt
(
parent
);
if
(
parent2
&&
isa
<
CompoundStmt
>
(
parent2
))
{
QualType
qt
=
parentFunctionDecl
->
getReturnType
().
getDesugaredType
(
compiler
.
getASTContext
());
if
(
!
qt
.
isConstQualified
()
&&
qt
->
isReferenceType
())
{
assignValue
=
"?"
;
bPotentiallyAssignedTo
=
true
;
}
}
}
while
(
!
bPotentiallyAssignedTo
)
{
// check for field being accessed by a reference variable e.g. Foo& f = m.foo;
auto
parentsList
=
compiler
.
getASTContext
().
getParents
(
*
child
);
auto
it
=
parentsList
.
begin
();
...
...
@@ -303,7 +317,7 @@ bool SingleValFields::VisitMemberExpr( const MemberExpr* memberExpr )
bDump
=
true
;
break
;
}
}
while
(
true
);
}
if
(
bDump
)
{
report
(
...
...
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