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
258aca99
Kaydet (Commit)
258aca99
authored
Ock 03, 2013
tarafından
Luboš Luňák
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
rewriter plugin for removing forward rtl string declarations
Change-Id: I12bf38985ae62756973c05aacf762ae3c405ac9b
üst
c26e6552
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
116 additions
and
0 deletions
+116
-0
Makefile-clang.mk
compilerplugins/Makefile-clang.mk
+1
-0
plugin.cxx
compilerplugins/clang/plugin.cxx
+5
-0
removeforwardstringdecl.cxx
compilerplugins/clang/removeforwardstringdecl.cxx
+76
-0
removeforwardstringdecl.hxx
compilerplugins/clang/removeforwardstringdecl.hxx
+34
-0
No files found.
compilerplugins/Makefile-clang.mk
Dosyayı görüntüle @
258aca99
...
...
@@ -14,6 +14,7 @@ CLANGSRC= \
bodynotinblock.cxx \
lclstaticfix.cxx \
postfixincrementfix.cxx \
removeforwardstringdecl.cxx \
sallogareas.cxx \
unusedvariablecheck.cxx \
...
...
compilerplugins/clang/plugin.cxx
Dosyayı görüntüle @
258aca99
...
...
@@ -22,6 +22,7 @@
#include "bodynotinblock.hxx"
#include "lclstaticfix.hxx"
#include "postfixincrementfix.hxx"
#include "removeforwardstringdecl.hxx"
#include "sallogareas.hxx"
#include "unusedvariablecheck.hxx"
...
...
@@ -192,6 +193,7 @@ class PluginHandler
,
bodyNotInBlock
(
context
)
,
lclStaticFix
(
context
,
rewriter
)
,
postfixIncrementFix
(
context
,
rewriter
)
,
removeForwardStringDecl
(
context
,
rewriter
)
,
salLogAreas
(
context
)
,
unusedVariableCheck
(
context
)
{
...
...
@@ -204,6 +206,8 @@ class PluginHandler
lclStaticFix
.
run
();
else
if
(
isArg
(
"postfixincrementfix"
))
postfixIncrementFix
.
run
();
else
if
(
isArg
(
"removeforwardstringdecl"
))
removeForwardStringDecl
.
run
();
else
if
(
args
.
empty
())
{
bodyNotInBlock
.
run
();
...
...
@@ -292,6 +296,7 @@ class PluginHandler
BodyNotInBlock
bodyNotInBlock
;
LclStaticFix
lclStaticFix
;
PostfixIncrementFix
postfixIncrementFix
;
RemoveForwardStringDecl
removeForwardStringDecl
;
SalLogAreas
salLogAreas
;
UnusedVariableCheck
unusedVariableCheck
;
};
...
...
compilerplugins/clang/removeforwardstringdecl.cxx
0 → 100644
Dosyayı görüntüle @
258aca99
/*
* This file is part of the LibreOffice project.
*
* Based on LLVM/Clang.
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
*/
#include "removeforwardstringdecl.hxx"
#include <clang/AST/ASTContext.h>
#include <clang/Basic/SourceManager.h>
/*
This is a rewriter.
Remove all forward declarations of rtl strings. I.e. 'namespace rtl { class OUString; }' etc.
*/
namespace
loplugin
{
RemoveForwardStringDecl
::
RemoveForwardStringDecl
(
ASTContext
&
context
,
Rewriter
&
rewriter
)
:
RewritePlugin
(
context
,
rewriter
)
{
}
void
RemoveForwardStringDecl
::
run
()
{
TraverseDecl
(
context
.
getTranslationUnitDecl
());
}
bool
RemoveForwardStringDecl
::
VisitNamespaceDecl
(
NamespaceDecl
*
declaration
)
{
if
(
ignoreLocation
(
declaration
))
return
true
;
if
(
declaration
->
getQualifiedNameAsString
()
!=
"rtl"
)
return
true
;
bool
canRemove
=
true
;
for
(
NamespaceDecl
::
decl_iterator
it
=
declaration
->
decls_begin
();
it
!=
declaration
->
decls_end
();
++
it
)
{
if
(
*
it
!=
NULL
)
{
if
(
!
tryRemoveStringForwardDecl
(
*
it
))
canRemove
=
false
;
}
}
if
(
canRemove
)
// contained only forward decls that we removed
removeText
(
declaration
->
getSourceRange
(),
RemoveLineIfEmpty
);
return
true
;
}
bool
RemoveForwardStringDecl
::
tryRemoveStringForwardDecl
(
const
Decl
*
decl
)
{
const
CXXRecordDecl
*
classdecl
=
dyn_cast
<
CXXRecordDecl
>
(
decl
);
if
(
classdecl
==
NULL
)
return
false
;
if
(
!
classdecl
->
isFreeStanding
()
||
classdecl
->
isCompleteDefinition
())
return
false
;
// not a simple forward declaration
if
(
classdecl
->
getName
()
==
"OString"
||
classdecl
->
getName
()
==
"OUString"
||
classdecl
->
getName
()
==
"OStringBuffer"
||
classdecl
->
getName
()
==
"OUStringBuffer"
||
classdecl
->
getName
()
==
"OStringHash"
||
classdecl
->
getName
()
==
"OUStringHash"
||
classdecl
->
getName
()
==
"OStringLiteral"
||
classdecl
->
getName
()
==
"OUStringLiteral"
)
{
removeText
(
SourceRange
(
classdecl
->
getOuterLocStart
(),
classdecl
->
getLocEnd
()),
RemoveLineIfEmpty
|
RemoveWholeStatement
);
return
true
;
}
return
false
;
}
}
// namespace
compilerplugins/clang/removeforwardstringdecl.hxx
0 → 100644
Dosyayı görüntüle @
258aca99
/*
* This file is part of the LibreOffice project.
*
* Based on LLVM/Clang.
*
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
*/
#ifndef REMOVEFORWARDSTRINGDECL_H
#define REMOVEFORWARDSTRINGDECL_H
#include "plugin.hxx"
namespace
loplugin
{
class
RemoveForwardStringDecl
:
public
RecursiveASTVisitor
<
RemoveForwardStringDecl
>
,
public
RewritePlugin
{
public
:
explicit
RemoveForwardStringDecl
(
ASTContext
&
context
,
Rewriter
&
rewriter
);
void
run
();
bool
VisitNamespaceDecl
(
NamespaceDecl
*
declaration
);
private
:
bool
tryRemoveStringForwardDecl
(
const
Decl
*
decl
);
};
}
// namespace
#endif // REMOVEFORWARDSTRINGDECL_H
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