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
3c2a6ad9
Kaydet (Commit)
3c2a6ad9
authored
Ock 20, 2014
tarafından
Stephan Bergmann
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make implicitboolconversion.cxx compile with Clang 3.2
Change-Id: I011e74fd044d0b76cccc60adea362805917c584a
üst
6789e6de
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
implicitboolconversion.cxx
compilerplugins/clang/implicitboolconversion.cxx
+30
-3
No files found.
compilerplugins/clang/implicitboolconversion.cxx
Dosyayı görüntüle @
3c2a6ad9
...
...
@@ -65,6 +65,33 @@ bool isBoolExpr(Expr const * expr) {
return
false
;
}
// It appears that, given a function declaration, there is no way to determine
// the language linkage of the function's type, only of the function's name
// (via FunctionDecl::isExternC); however, in a case like
//
// extern "C" { static void f(); }
//
// the function's name does not have C language linkage while the function's
// type does (as clarified in C++11 [decl.link]); cf. <http://clang-developers.
// 42468.n3.nabble.com/Language-linkage-of-function-type-tt4037248.html>
// "Language linkage of function type":
bool
hasCLanguageLinkageType
(
FunctionDecl
const
*
decl
)
{
assert
(
decl
!=
nullptr
);
if
(
decl
->
isExternC
())
{
return
true
;
}
#if (__clang_major__ == 3 && __clang_minor__ >= 3) || __clang_major__ > 3
if
(
decl
->
isInExternCContext
())
{
return
true
;
}
#else
if
(
decl
->
getDeclContext
()
->
isExternCContext
())
{
return
true
;
}
#endif
return
false
;
}
class
ImplicitBoolConversion
:
public
RecursiveASTVisitor
<
ImplicitBoolConversion
>
,
public
loplugin
::
Plugin
{
...
...
@@ -126,14 +153,14 @@ bool ImplicitBoolConversion::TraverseCallExpr(CallExpr * expr) {
FunctionProtoType
const
*
t
=
nullptr
;
if
(
d
!=
nullptr
)
{
FunctionDecl
const
*
fd
=
dyn_cast
<
FunctionDecl
>
(
d
);
if
(
fd
!=
nullptr
&&
(
fd
->
isExternC
()
||
fd
->
isInExternCContext
()
))
{
if
(
fd
!=
nullptr
&&
fd
->
isExternC
(
))
{
ext
=
true
;
PointerType
const
*
pt
=
dyn_cast
<
PointerType
>
(
fd
->
getType
());
t
=
(
pt
==
nullptr
?
fd
->
getType
()
:
pt
->
getPointeeType
())
->
getAs
<
FunctionProtoType
>
();
}
else
{
VarDecl
const
*
vd
=
dyn_cast
<
VarDecl
>
(
d
);
if
(
vd
!=
nullptr
&&
(
vd
->
isExternC
()
||
vd
->
isInExternCContext
()
))
if
(
vd
!=
nullptr
&&
vd
->
isExternC
(
))
{
ext
=
true
;
PointerType
const
*
pt
=
dyn_cast
<
PointerType
>
(
vd
->
getType
());
...
...
@@ -432,7 +459,7 @@ bool ImplicitBoolConversion::TraverseReturnStmt(ReturnStmt * stmt) {
}
bool
ImplicitBoolConversion
::
TraverseFunctionDecl
(
FunctionDecl
*
decl
)
{
bool
ext
=
(
decl
->
isExternC
()
||
decl
->
isInExternCContext
()
)
bool
ext
=
hasCLanguageLinkageType
(
decl
)
&&
decl
->
isThisDeclarationADefinition
()
&&
(
decl
->
getResultType
()
->
isSpecificBuiltinType
(
BuiltinType
::
Int
)
||
decl
->
getResultType
()
->
isSpecificBuiltinType
(
BuiltinType
::
UInt
));
...
...
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