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
e8b5ec65
Kaydet (Commit)
e8b5ec65
authored
Eyl 20, 2017
tarafından
Noel Grandin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
loplugin:unusedfields, fix var taking ref
Change-Id: I0ea1f0c7488c140fca9f64de326c6ac588ece925
üst
d6e8e522
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
7 deletions
+28
-7
unusedfields.cxx
compilerplugins/clang/test/unusedfields.cxx
+14
-4
unusedfields.cxx
compilerplugins/clang/unusedfields.cxx
+13
-0
CompilerTest_compilerplugins_clang.mk
solenv/CompilerTest_compilerplugins_clang.mk
+1
-3
No files found.
compilerplugins/clang/test/unusedfields.cxx
Dosyayı görüntüle @
e8b5ec65
...
...
@@ -116,16 +116,19 @@ struct ReadOnlyAnalysis
// expected-error@-2 {{read m_f3 [loplugin:unusedfields]}}
// expected-error@-3 {{read m_f4 [loplugin:unusedfields]}}
// expected-error@-4 {{read m_f5 [loplugin:unusedfields]}}
// expected-error@-5 {{write m_f2 [loplugin:unusedfields]}}
// expected-error@-6 {{write m_f3 [loplugin:unusedfields]}}
// expected-error@-7 {{write m_f4 [loplugin:unusedfields]}}
// expected-error@-8 {{write m_f5 [loplugin:unusedfields]}}
// expected-error@-5 {{read m_f6 [loplugin:unusedfields]}}
// expected-error@-6 {{write m_f2 [loplugin:unusedfields]}}
// expected-error@-7 {{write m_f3 [loplugin:unusedfields]}}
// expected-error@-8 {{write m_f4 [loplugin:unusedfields]}}
// expected-error@-9 {{write m_f5 [loplugin:unusedfields]}}
// expected-error@-10 {{write m_f6 [loplugin:unusedfields]}}
{
int
m_f1
;
int
m_f2
;
int
m_f3
;
std
::
vector
<
int
>
m_f4
;
int
m_f5
;
int
m_f6
;
// check that we dont see a write of m_f1
ReadOnlyAnalysis
()
:
m_f1
(
0
)
{}
...
...
@@ -141,6 +144,13 @@ struct ReadOnlyAnalysis
// check that we see a write when we pass by non-const ref
void
method5
()
{
ReadOnly1
a
(
m_f5
);
}
// check that we see a write when we pass by non-const ref
void
method6
()
{
int
&
r
=
m_f6
;
r
=
1
;
}
};
struct
ReadOnlyAnalysis2
...
...
compilerplugins/clang/unusedfields.cxx
Dosyayı görüntüle @
e8b5ec65
...
...
@@ -611,6 +611,19 @@ void UnusedFields::checkReadOnly(const FieldDecl* fieldDecl, const Expr* memberE
{
if
(
!
parent
)
{
// check if we have an expression like
// int& r = m_field;
auto
parentsRange
=
compiler
.
getASTContext
().
getParents
(
*
child
);
if
(
parentsRange
.
begin
()
!=
parentsRange
.
end
())
{
auto
varDecl
=
dyn_cast_or_null
<
VarDecl
>
(
parentsRange
.
begin
()
->
get
<
Decl
>
());
// The isImplicit() call is to avoid triggering when we see the vardecl which is part of a for-range statement,
// which is of type 'T&&' and also an l-value-ref ?
if
(
varDecl
&&
!
varDecl
->
isImplicit
()
&&
loplugin
::
TypeCheck
(
varDecl
->
getType
()).
LvalueReference
().
NonConst
())
{
bPotentiallyWrittenTo
=
true
;
}
}
break
;
}
if
(
isa
<
CXXReinterpretCastExpr
>
(
parent
))
...
...
solenv/CompilerTest_compilerplugins_clang.mk
Dosyayı görüntüle @
e8b5ec65
...
...
@@ -38,13 +38,11 @@ $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \
compilerplugins/clang/test/unnecessaryoverride-dtor \
compilerplugins/clang/test/unnecessaryparen \
compilerplugins/clang/test/unoany \
compilerplugins/clang/test/unusedfields \
compilerplugins/clang/test/useuniqueptr \
compilerplugins/clang/test/vclwidgets \
))
# FIXME Fails with clang-3.8.
# compilerplugins/clang/test/unusedfields \
$(eval $(call gb_CompilerTest_use_externals,compilerplugins_clang, \
boost_headers \
cppunit \
...
...
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