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
b6778e92
Kaydet (Commit)
b6778e92
authored
May 19, 2017
tarafından
Stephan Bergmann
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
loplugin:stringcopy
Change-Id: Ib04ef019996888166c25ad140b7c718a173a782a
üst
0e4a884b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
0 deletions
+77
-0
stringcopy.cxx
compilerplugins/clang/stringcopy.cxx
+53
-0
stringcopy.cxx
compilerplugins/clang/test/stringcopy.cxx
+23
-0
CompilerTest_compilerplugins_clang.mk
solenv/CompilerTest_compilerplugins_clang.mk
+1
-0
No files found.
compilerplugins/clang/stringcopy.cxx
0 → 100644
Dosyayı görüntüle @
b6778e92
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "check.hxx"
#include "plugin.hxx"
namespace
{
class
Visitor
final
:
public
RecursiveASTVisitor
<
Visitor
>
,
public
loplugin
::
Plugin
{
public
:
explicit
Visitor
(
InstantiationData
const
&
data
)
:
Plugin
(
data
)
{}
bool
VisitCXXFunctionalCastExpr
(
CXXFunctionalCastExpr
const
*
expr
)
{
if
(
ignoreLocation
(
expr
))
{
return
true
;
}
auto
const
t1
=
expr
->
getTypeAsWritten
();
auto
const
t2
=
expr
->
getSubExprAsWritten
()
->
getType
();
if
((
t1
.
getCanonicalType
().
getTypePtr
()
!=
t2
.
getCanonicalType
().
getTypePtr
())
||
!
(
loplugin
::
TypeCheck
(
t1
).
Class
(
"OUString"
).
Namespace
(
"rtl"
)
.
GlobalNamespace
()))
{
return
true
;
}
report
(
DiagnosticsEngine
::
Warning
,
"redundant copy construction from %0 to %1"
,
expr
->
getExprLoc
())
<<
t2
<<
t1
<<
expr
->
getSourceRange
();
return
true
;
}
private
:
void
run
()
override
{
if
(
compiler
.
getLangOpts
().
CPlusPlus
)
{
TraverseDecl
(
compiler
.
getASTContext
().
getTranslationUnitDecl
());
}
}
};
static
loplugin
::
Plugin
::
Registration
<
Visitor
>
reg
(
"stringcopy"
);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
compilerplugins/clang/test/stringcopy.cxx
0 → 100644
Dosyayı görüntüle @
b6778e92
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "sal/config.h"
#include "rtl/ustring.hxx"
int
main
()
{
OUString
s
;
(
void
)
OUString
(
s
);
// expected-error {{redundant copy construction from 'rtl::OUString' to 'rtl::OUString' [loplugin:stringcopy]}}
using
T1
=
OUString
;
(
void
)
T1
(
s
);
// expected-error {{redundant copy construction from 'rtl::OUString' to 'T1' (aka 'rtl::OUString') [loplugin:stringcopy]}}
using
T2
=
OUString
const
;
(
void
)
T2
(
s
);
// expected-error {{redundant copy construction from 'rtl::OUString' to 'T2' (aka 'const rtl::OUString') [loplugin:stringcopy]}}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
solenv/CompilerTest_compilerplugins_clang.mk
Dosyayı görüntüle @
b6778e92
...
...
@@ -24,6 +24,7 @@ $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \
compilerplugins/clang/test/salbool \
compilerplugins/clang/test/salunicodeliteral \
compilerplugins/clang/test/stringconstant \
compilerplugins/clang/test/stringcopy \
compilerplugins/clang/test/unnecessaryoverride-dtor \
compilerplugins/clang/test/unoany \
compilerplugins/clang/test/vclwidgets \
...
...
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