Kaydet (Commit) 7f0bf622 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Revert "check for unnecessary DLLPUBLIC annotations"

This reverts commit a599eeab, plus follow-up
fa443144 "Avoid bogus loplugin:dllmacro
'unnecessary *DLLPUBLIC declaration ...'".  See (abandoned)
<https://gerrit.libreoffice.org/#/c/42983/> "loplugin:dllmacro: Handle implicit
member functions" how this would have needed to be extended to give consistent
results across Linux and macOS, but then would have started to remove DLLPUBLIC
from entities that apparently need to at least have default type visibility on
macOS and started to make tests fail.
üst aed18703
...@@ -50,7 +50,7 @@ template< typename T > ...@@ -50,7 +50,7 @@ template< typename T >
<p>In case no number can be generated from the Any, NaN (see <p>In case no number can be generated from the Any, NaN (see
rtl::math::SetNAN()) is returned.</p> rtl::math::SetNAN()) is returned.</p>
*/ */
struct AnyToDouble struct OOO_DLLPUBLIC_CHARTTOOLS AnyToDouble
{ {
double operator() ( const css::uno::Any & rAny ) double operator() ( const css::uno::Any & rAny )
{ {
...@@ -64,7 +64,7 @@ struct AnyToDouble ...@@ -64,7 +64,7 @@ struct AnyToDouble
/** unary function to convert css::uno::Any into an /** unary function to convert css::uno::Any into an
OUString. OUString.
*/ */
struct AnyToString struct OOO_DLLPUBLIC_CHARTTOOLS AnyToString
{ {
OUString operator() ( const css::uno::Any & rAny ) OUString operator() ( const css::uno::Any & rAny )
{ {
...@@ -93,7 +93,7 @@ struct AnyToString ...@@ -93,7 +93,7 @@ struct AnyToString
<p>For conversion rtl::math::StringToDouble is used.</p> <p>For conversion rtl::math::StringToDouble is used.</p>
*/ */
struct OUStringToDouble struct OOO_DLLPUBLIC_CHARTTOOLS OUStringToDouble
{ {
double operator() ( const OUString & rStr ) double operator() ( const OUString & rStr )
{ {
...@@ -111,7 +111,7 @@ struct OUStringToDouble ...@@ -111,7 +111,7 @@ struct OUStringToDouble
<p>For conversion rtl::math::DoubleToOUString is used.</p> <p>For conversion rtl::math::DoubleToOUString is used.</p>
*/ */
struct DoubleToOUString struct OOO_DLLPUBLIC_CHARTTOOLS DoubleToOUString
{ {
OUString operator() ( double fNumber ) OUString operator() ( double fNumber )
{ {
......
...@@ -138,7 +138,7 @@ OOO_DLLPUBLIC_CHARTTOOLS void setEmptyPropertyValueDefault( tPropertyValueMap & ...@@ -138,7 +138,7 @@ OOO_DLLPUBLIC_CHARTTOOLS void setEmptyPropertyValueDefault( tPropertyValueMap &
} // namespace PropertyHelper } // namespace PropertyHelper
struct PropertyNameLess struct OOO_DLLPUBLIC_CHARTTOOLS PropertyNameLess
{ {
bool operator() ( const css::beans::Property & first, bool operator() ( const css::beans::Property & first,
const css::beans::Property & second ) const css::beans::Property & second )
......
...@@ -8,54 +8,32 @@ ...@@ -8,54 +8,32 @@
*/ */
#include "plugin.hxx" #include "plugin.hxx"
#include <iostream>
#include <fstream>
/** namespace {
Check the usage of the various DLL visibility macros.
*/ class Visitor final:
class DllMacro final: public RecursiveASTVisitor<Visitor>, public loplugin::Plugin
public RecursiveASTVisitor<DllMacro>, public loplugin::Plugin
{ {
public: public:
explicit DllMacro(InstantiationData const & data): Plugin(data) {} explicit Visitor(InstantiationData const & data): Plugin(data) {}
bool VisitNamedDecl(NamedDecl const * decl);
private: bool VisitNamedDecl(NamedDecl const * decl) {
void run() override { if (!decl->getLocation().isInvalid()&&ignoreLocation(decl)) {
// DISABLE_DYNLOADING makes SAL_DLLPUBLIC_{EXPORT,IMPORT,TEMPLATE} expand return true;
// to visibility("hidden") attributes, which would cause bogus warnings }
// here (e.g., in UBSan builds that explicitly define DISABLE_DYNLOADING auto a = decl->getAttr<VisibilityAttr>();
// in jurt/source/pipe/staticsalhack.cxx); alternatively, change if (a == nullptr || a->getVisibility() != VisibilityAttr::Hidden) {
// include/sal/types.h to make those SAL_DLLPUBLIC_* expand to nothing return true;
// for DISABLE_DYNLOADING: }
if (!compiler.getPreprocessor().getIdentifierInfo("DISABLE_DYNLOADING") if (compiler.getSourceManager().isMacroBodyExpansion(
->hasMacroDefinition()) decl->getLocation())
&& (Lexer::getImmediateMacroName(
decl->getLocation(), compiler.getSourceManager(),
compiler.getLangOpts())
== "Q_OBJECT")) // from /usr/include/QtCore/qobjectdefs.h
{ {
TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); return true;
} }
}
};
bool DllMacro::VisitNamedDecl(NamedDecl const * decl) {
if (!decl->getLocation().isInvalid() && ignoreLocation(decl)) {
return true;
}
auto a = decl->getAttr<VisibilityAttr>();
if (a == nullptr) {
return true;
}
if (compiler.getSourceManager().isMacroBodyExpansion(
decl->getLocation())
&& (Lexer::getImmediateMacroName(
decl->getLocation(), compiler.getSourceManager(),
compiler.getLangOpts())
== "Q_OBJECT")) // from /usr/include/QtCore/qobjectdefs.h
{
return true;
}
if (a->getVisibility() == VisibilityAttr::Hidden) {
auto p = dyn_cast<RecordDecl>(decl->getDeclContext()); auto p = dyn_cast<RecordDecl>(decl->getDeclContext());
if (p == nullptr) { if (p == nullptr) {
report( report(
...@@ -67,7 +45,7 @@ bool DllMacro::VisitNamedDecl(NamedDecl const * decl) { ...@@ -67,7 +45,7 @@ bool DllMacro::VisitNamedDecl(NamedDecl const * decl) {
report( report(
DiagnosticsEngine::Warning, DiagnosticsEngine::Warning,
("declaration nested in DLLPRIVATE declaration redundantly" ("declaration nested in DLLPRIVATE declaration redundantly"
" marked as DLLPRIVATE"), " marked as DLLPRIVATE"),
a->getLocation()) a->getLocation())
<< decl->getSourceRange(); << decl->getSourceRange();
report( report(
...@@ -75,38 +53,27 @@ bool DllMacro::VisitNamedDecl(NamedDecl const * decl) { ...@@ -75,38 +53,27 @@ bool DllMacro::VisitNamedDecl(NamedDecl const * decl) {
p->getLocation()) p->getLocation())
<< p->getSourceRange(); << p->getSourceRange();
} }
return true;
} }
else if (a->getVisibility() == VisibilityAttr::Default && !a->isInherited())
{ private:
auto p = dyn_cast<CXXRecordDecl>(decl); void run() override {
if (p && p->isCompleteDefinition() && !p->getDescribedClassTemplate()) { // DISABLE_DYNLOADING makes SAL_DLLPUBLIC_{EXPORT,IMPORT,TEMPLATE} expand
// don't know what these macros mean, leave them alone // to visibility("hidden") attributes, which would cause bogus warnings
auto macroLoc = a->getLocation(); // here (e.g., in UBSan builds that explicitly define DISABLE_DYNLOADING
while (compiler.getSourceManager().isMacroBodyExpansion(macroLoc)) { // in jurt/source/pipe/staticsalhack.cxx); alternatively, change
auto macroName = Lexer::getImmediateMacroName( // include/sal/types.h to make those SAL_DLLPUBLIC_* expand to nothing
macroLoc, compiler.getSourceManager(), // for DISABLE_DYNLOADING:
compiler.getLangOpts()); if (!compiler.getPreprocessor().getIdentifierInfo("DISABLE_DYNLOADING")
if (macroName == "SAL_EXCEPTION_DLLPUBLIC_EXPORT") ->hasMacroDefinition())
return true; {
if (macroName == "VCL_PLUGIN_PUBLIC") TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
return true;
macroLoc = compiler.getSourceManager().getImmediateMacroCallerLoc(macroLoc);
}
for (auto it = p->method_begin(); it != p->method_end(); ++it) {
if (!it->hasInlineBody()) {
return true;
}
}
report(
DiagnosticsEngine::Warning,
"unnecessary *DLLPUBLIC declaration for class completely defined in header file",
a->getLocation())
<< decl->getSourceRange();
} }
} }
return true; };
}
static loplugin::Plugin::Registration<DllMacro> reg("dllmacro"); static loplugin::Plugin::Registration<Visitor> reg("dllprivate");
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
/** This exception is thrown, when the arithmetic expression /** This exception is thrown, when the arithmetic expression
parser failed to parse a string. parser failed to parse a string.
*/ */
struct ParseError struct OOO_DLLPUBLIC_DBTOOLS ParseError
{ {
ParseError( const char* ) {} ParseError( const char* ) {}
}; };
......
...@@ -36,7 +36,7 @@ class Content; ...@@ -36,7 +36,7 @@ class Content;
namespace dp_misc { namespace dp_misc {
struct StrTitle struct DESKTOP_DEPLOYMENTMISC_DLLPUBLIC StrTitle
{ {
static css::uno::Sequence< OUString > getTitleSequence() static css::uno::Sequence< OUString > getTitleSequence()
{ {
......
...@@ -42,7 +42,7 @@ namespace basegfx ...@@ -42,7 +42,7 @@ namespace basegfx
@see B3DTuple @see B3DTuple
*/ */
class SAL_WARN_UNUSED BColor : public B3DTuple class SAL_WARN_UNUSED BASEGFX_DLLPUBLIC BColor : public B3DTuple
{ {
public: public:
/** Create a Color with red, green and blue components from [0.0 to 1.0] /** Create a Color with red, green and blue components from [0.0 to 1.0]
......
...@@ -148,7 +148,7 @@ namespace basegfx ...@@ -148,7 +148,7 @@ namespace basegfx
{ {
namespace utils namespace utils
{ {
class B2DHomMatrixBufferedDecompose class BASEGFX_DLLPUBLIC B2DHomMatrixBufferedDecompose
{ {
private: private:
B2DVector maScale; B2DVector maScale;
......
...@@ -148,7 +148,7 @@ namespace basegfx ...@@ -148,7 +148,7 @@ namespace basegfx
*/ */
BASEGFX_DLLPUBLIC double snapToNearestMultiple(double v, const double fStep); BASEGFX_DLLPUBLIC double snapToNearestMultiple(double v, const double fStep);
class fTools class BASEGFX_DLLPUBLIC fTools
{ {
public: public:
/// Get threshold value for equalZero and friends /// Get threshold value for equalZero and friends
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
namespace basegfx namespace basegfx
{ {
class BPixel class BASEGFX_DLLPUBLIC BPixel
{ {
protected: protected:
union union
......
...@@ -32,7 +32,7 @@ namespace comphelper ...@@ -32,7 +32,7 @@ namespace comphelper
// infos about one single property // infos about one single property
struct PropertyDescription struct COMPHELPER_DLLPUBLIC PropertyDescription
{ {
// the possibilities where a property holding object may be located // the possibilities where a property holding object may be located
enum class LocationType enum class LocationType
......
...@@ -472,7 +472,7 @@ namespace connectivity ...@@ -472,7 +472,7 @@ namespace connectivity
/// TSetBound is a functor to set the bound value with e.q. for_each call /// TSetBound is a functor to set the bound value with e.q. for_each call
struct TSetBound struct OOO_DLLPUBLIC_DBTOOLS TSetBound
{ {
bool m_bBound; bool m_bBound;
TSetBound(bool _bBound) : m_bBound(_bBound){} TSetBound(bool _bBound) : m_bBound(_bBound){}
...@@ -482,7 +482,7 @@ namespace connectivity ...@@ -482,7 +482,7 @@ namespace connectivity
/// TSetBound is a functor to set the bound value with e.q. for_each call /// TSetBound is a functor to set the bound value with e.q. for_each call
struct TSetRefBound struct OOO_DLLPUBLIC_DBTOOLS TSetRefBound
{ {
bool m_bBound; bool m_bBound;
TSetRefBound(bool _bBound) : m_bBound(_bBound){} TSetRefBound(bool _bBound) : m_bBound(_bBound){}
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <tools/solar.h> #include <tools/solar.h>
#include <tools/stream.hxx> #include <tools/stream.hxx>
class DffRecordHeader class MSFILTER_DLLPUBLIC DffRecordHeader
{ {
public: public:
sal_uInt8 nRecVer; // may be DFF_PSFLAG_CONTAINER sal_uInt8 nRecVer; // may be DFF_PSFLAG_CONTAINER
......
...@@ -476,13 +476,13 @@ struct MSFILTER_DLLPUBLIC EncryptionVerifierRC4 ...@@ -476,13 +476,13 @@ struct MSFILTER_DLLPUBLIC EncryptionVerifierRC4
EncryptionVerifierRC4(); EncryptionVerifierRC4();
}; };
struct StandardEncryptionInfo struct MSFILTER_DLLPUBLIC StandardEncryptionInfo
{ {
EncryptionStandardHeader header; EncryptionStandardHeader header;
EncryptionVerifierAES verifier; EncryptionVerifierAES verifier;
}; };
struct RC4EncryptionInfo struct MSFILTER_DLLPUBLIC RC4EncryptionInfo
{ {
EncryptionStandardHeader header; EncryptionStandardHeader header;
EncryptionVerifierRC4 verifier; EncryptionVerifierRC4 verifier;
......
...@@ -117,7 +117,7 @@ struct SdHyperlinkEntry ...@@ -117,7 +117,7 @@ struct SdHyperlinkEntry
}; };
// Helper class for reading the PPT InteractiveInfoAtom // Helper class for reading the PPT InteractiveInfoAtom
struct PptInteractiveInfoAtom struct MSFILTER_DLLPUBLIC PptInteractiveInfoAtom
{ {
sal_uInt32 nSoundRef; sal_uInt32 nSoundRef;
sal_uInt32 nExHyperlinkId; sal_uInt32 nExHyperlinkId;
......
...@@ -70,7 +70,7 @@ MSFILTER_DLLPUBLIC OString ConvertColor( const Color &rColor, bool bAutoColor = ...@@ -70,7 +70,7 @@ MSFILTER_DLLPUBLIC OString ConvertColor( const Color &rColor, bool bAutoColor =
/** Paper size in 1/100 millimeters. */ /** Paper size in 1/100 millimeters. */
struct ApiPaperSize struct MSFILTER_DLLPUBLIC ApiPaperSize
{ {
sal_Int32 mnWidth; sal_Int32 mnWidth;
sal_Int32 mnHeight; sal_Int32 mnHeight;
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <tools/fldunit.hxx> #include <tools/fldunit.hxx>
#include <tools/mapunit.hxx> #include <tools/mapunit.hxx>
class TransfrmHelper class SVX_DLLPUBLIC TransfrmHelper
{ {
public: public:
static void ConvertRect(basegfx::B2DRange& rRange, const sal_uInt16 nDigits, const MapUnit ePoolUnit, const FieldUnit eDlgUnit) static void ConvertRect(basegfx::B2DRange& rRange, const sal_uInt16 nDigits, const MapUnit ePoolUnit, const FieldUnit eDlgUnit)
......
...@@ -42,7 +42,7 @@ namespace svx ...@@ -42,7 +42,7 @@ namespace svx
//= OXFormsDescriptor //= OXFormsDescriptor
struct OXFormsDescriptor { struct SVX_DLLPUBLIC OXFormsDescriptor {
OUString szName; OUString szName;
OUString szServiceName; OUString szServiceName;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <tools/toolsdllapi.h> #include <tools/toolsdllapi.h>
#include <tools/gen.hxx> #include <tools/gen.hxx>
class SAL_WARN_UNUSED SvBorder class SAL_WARN_UNUSED TOOLS_DLLPUBLIC SvBorder
{ {
long nTop, nRight, nBottom, nLeft; long nTop, nRight, nBottom, nLeft;
......
...@@ -110,7 +110,7 @@ enum class BmpFilter ...@@ -110,7 +110,7 @@ enum class BmpFilter
Unknown = 65535 Unknown = 65535
}; };
class BmpFilterParam class VCL_DLLPUBLIC BmpFilterParam
{ {
public: public:
......
...@@ -206,7 +206,7 @@ enum class ShowDialogId ...@@ -206,7 +206,7 @@ enum class ShowDialogId
About = 2, About = 2,
}; };
class CommandDialogData class VCL_DLLPUBLIC CommandDialogData
{ {
ShowDialogId m_nDialogId; ShowDialogId m_nDialogId;
public: public:
...@@ -242,7 +242,7 @@ enum class MediaCommand ...@@ -242,7 +242,7 @@ enum class MediaCommand
NextTrackHold = 21,// Button Right holding pressed. NextTrackHold = 21,// Button Right holding pressed.
}; };
class CommandMediaData class VCL_DLLPUBLIC CommandMediaData
{ {
MediaCommand m_nMediaId; MediaCommand m_nMediaId;
bool m_bPassThroughToOS; bool m_bPassThroughToOS;
...@@ -270,7 +270,7 @@ public: ...@@ -270,7 +270,7 @@ public:
sal_uLong GetEnd() const { return mnEnd; } sal_uLong GetEnd() const { return mnEnd; }
}; };
class CommandSwipeData class VCL_DLLPUBLIC CommandSwipeData
{ {
double mnVelocityX; double mnVelocityX;
public: public:
...@@ -286,7 +286,7 @@ public: ...@@ -286,7 +286,7 @@ public:
}; };
class CommandLongPressData class VCL_DLLPUBLIC CommandLongPressData
{ {
double mnX; double mnX;
double mnY; double mnY;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <vcl/dllapi.h> #include <vcl/dllapi.h>
#include <vcl/ptrstyle.hxx> #include <vcl/ptrstyle.hxx>
class Pointer class VCL_DLLPUBLIC Pointer
{ {
PointerStyle meStyle; PointerStyle meStyle;
......
...@@ -91,7 +91,7 @@ enum ScAxisPosition ...@@ -91,7 +91,7 @@ enum ScAxisPosition
} }
struct ScDataBarFormatData struct SC_DLLPUBLIC ScDataBarFormatData
{ {
ScDataBarFormatData(): ScDataBarFormatData():
maAxisColor(COL_BLACK), maAxisColor(COL_BLACK),
......
...@@ -129,7 +129,7 @@ inline std::ostream &operator <<(std::ostream& s, const SwNodeIndex& index) ...@@ -129,7 +129,7 @@ inline std::ostream &operator <<(std::ostream& s, const SwNodeIndex& index)
// SwRange // SwRange
class SwNodeRange class SW_DLLPUBLIC SwNodeRange
{ {
public: public:
SwNodeIndex aStart; SwNodeIndex aStart;
......
...@@ -47,7 +47,7 @@ inline bool SwFltGetFlag(sal_uLong nFieldFlags, int no) ...@@ -47,7 +47,7 @@ inline bool SwFltGetFlag(sal_uLong nFieldFlags, int no)
//Subvert the Node/Content system to get positions which don't update as //Subvert the Node/Content system to get positions which don't update as
//content is appended to them //content is appended to them
struct SwFltPosition struct SW_DLLPUBLIC SwFltPosition
{ {
public: public:
SwNodeIndex m_nNode; SwNodeIndex m_nNode;
......
...@@ -71,7 +71,7 @@ typedef void (*damageHandler)(void* handle, ...@@ -71,7 +71,7 @@ typedef void (*damageHandler)(void* handle,
sal_Int32 nExtentsX, sal_Int32 nExtentsY, sal_Int32 nExtentsX, sal_Int32 nExtentsY,
sal_Int32 nExtentsWidth, sal_Int32 nExtentsHeight); sal_Int32 nExtentsWidth, sal_Int32 nExtentsHeight);
struct DamageHandler struct VCL_DLLPUBLIC DamageHandler
{ {
void *handle; void *handle;
damageHandler damaged; damageHandler damaged;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment