diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-11-19 16:32:49 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-11-22 12:57:32 +0100 |
commit | f853ec317f6af1b8c65cc5bd758371689c75118d (patch) | |
tree | b86d729bf9a9465ee619ead3b5635efa62a1804e /hwpfilter | |
parent | f31d36966bceb90e261cbecd42634bde4448d527 (diff) |
Extend loplugin:external to warn about classes
...following up on 314f15bff08b76bf96acf99141776ef64d2f1355 "Extend
loplugin:external to warn about enums".
Cases where free functions were moved into an unnamed namespace along with a
class, to not break ADL, are in:
filter/source/svg/svgexport.cxx
sc/source/filter/excel/xelink.cxx
sc/source/filter/excel/xilink.cxx
svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx
All other free functions mentioning moved classes appear to be harmless and not
give rise to (silent, even) ADL breakage. (One remaining TODO in
compilerplugins/clang/external.cxx is that derived classes are not covered by
computeAffectedTypes, even though they could also be affected by ADL-breakage---
but don't seem to be in any acutal case across the code base.)
For friend declarations using elaborate type specifiers, like
class C1 {};
class C2 { friend class C1; };
* If C2 (but not C1) is moved into an unnamed namespace, the friend declaration
must be changed to not use an elaborate type specifier (i.e., "friend C1;"; see
C++17 [namespace.memdef]/3: "If the name in a friend declaration is neither
qualified nor a template-id and the declaration is a function or an
elaborated-type-specifier, the lookup to determine whether the entity has been
previously declared shall not consider any scopes outside the innermost
enclosing namespace.")
* If C1 (but not C2) is moved into an unnamed namespace, the friend declaration
must be changed too, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71882>
"elaborated-type-specifier friend not looked up in unnamed namespace".
Apart from that, to keep changes simple and mostly mechanical (which should help
avoid regressions), out-of-line definitions of class members have been left in
the enclosing (named) namespace. But explicit specializations of class
templates had to be moved into the unnamed namespace to appease
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92598> "explicit specialization of
template from unnamed namespace using unqualified-id in enclosing namespace".
Also, accompanying declarations (of e.g. typedefs or static variables) that
could arguably be moved into the unnamed namespace too have been left alone.
And in some cases, mention of affected types in blacklists in other loplugins
needed to be adapted.
And sc/qa/unit/mark_test.cxx uses a hack of including other .cxx, one of which
is sc/source/core/data/segmenttree.cxx where e.g. ScFlatUInt16SegmentsImpl is
not moved into an unnamed namespace (because it is declared in
sc/inc/segmenttree.hxx), but its base ScFlatSegmentsImpl is. GCC warns about
such combinations with enabled-by-default -Wsubobject-linkage, but "The compiler
doesn’t give this warning for types defined in the main .C file, as those are
unlikely to have multiple definitions."
(<https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html>) The
warned-about classes also don't have multiple definitions in the given test, so
disable the warning when including the .cxx.
Change-Id: Ib694094c0d8168be68f8fe90dfd0acbb66a3f1e4
Reviewed-on: https://gerrit.libreoffice.org/83239
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'hwpfilter')
-rw-r--r-- | hwpfilter/source/attributes.cxx | 4 | ||||
-rw-r--r-- | hwpfilter/source/fontmap.cxx | 5 | ||||
-rw-r--r-- | hwpfilter/source/hcode.cxx | 5 | ||||
-rw-r--r-- | hwpfilter/source/hstyle.cxx | 4 | ||||
-rw-r--r-- | hwpfilter/source/hwpeq.cxx | 8 | ||||
-rw-r--r-- | hwpfilter/source/hwpreader.cxx | 3 | ||||
-rw-r--r-- | hwpfilter/source/lexer.cxx | 7 |
7 files changed, 36 insertions, 0 deletions
diff --git a/hwpfilter/source/attributes.cxx b/hwpfilter/source/attributes.cxx index 533769d879ac..f9e33b1f40f7 100644 --- a/hwpfilter/source/attributes.cxx +++ b/hwpfilter/source/attributes.cxx @@ -22,6 +22,8 @@ #include <vector> #include "attributes.hxx" +namespace { + struct TagAttribute { TagAttribute( const OUString &rName, const OUString &rType , const OUString &rValue ) @@ -36,6 +38,8 @@ struct TagAttribute OUString sValue; }; +} + struct AttributeListImpl_impl { AttributeListImpl_impl() diff --git a/hwpfilter/source/fontmap.cxx b/hwpfilter/source/fontmap.cxx index 52fffd8f910a..fcd6c4822169 100644 --- a/hwpfilter/source/fontmap.cxx +++ b/hwpfilter/source/fontmap.cxx @@ -27,12 +27,17 @@ #include <sal/types.h> #include "fontmap.hxx" +namespace { + struct FontEntry { const char *familyname; int key; double ratio; }; + +} + /** * ratio\xb4\xc2 \xc7\xd1\xb1\xdb 70%, \xbc\xfd\xc0\xda 10% \xbf\xb5\xb9\xae 20%\xc0\xc7 \xba\xf1\xc0\xb2\xb7\xce \xb1\xb8\xbc\xba\xb5\xc7\xbe\xfa\xb4\xd9\xb4\xc2 \xb0\xa1\xc1\xa4\xc7\xcf\xbf\xa1 \xc1\xa4\xc7\xd8\xc1\xf8\xb4\xd9. */ diff --git a/hwpfilter/source/hcode.cxx b/hwpfilter/source/hcode.cxx index fda36e0953ca..99885d00460b 100644 --- a/hwpfilter/source/hcode.cxx +++ b/hwpfilter/source/hcode.cxx @@ -653,12 +653,17 @@ static const hchar jamo_to_unicode[] = 0x11f6, 0x11f7, 0x11f8, 0x11f9 }; +namespace { + struct JamoComp{ int size; hchar v1; hchar v2; hchar v3; }; + +} + /* 704 + 12 = 706 */ static const JamoComp jamocomp1_to_unicode[] = { diff --git a/hwpfilter/source/hstyle.cxx b/hwpfilter/source/hstyle.cxx index e0573edf9cad..e80a9c1a8b0d 100644 --- a/hwpfilter/source/hstyle.cxx +++ b/hwpfilter/source/hstyle.cxx @@ -30,6 +30,8 @@ enum #define DATA static_cast<StyleData *>(style) +namespace { + struct StyleData { char name[MAXSTYLENAME + 1]; @@ -37,6 +39,8 @@ struct StyleData ParaShape pshape; }; +} + static char buffer[MAXSTYLENAME + 1]; HWPStyle::HWPStyle() diff --git a/hwpfilter/source/hwpeq.cxx b/hwpfilter/source/hwpeq.cxx index d3bd46207469..00cf2182866c 100644 --- a/hwpfilter/source/hwpeq.cxx +++ b/hwpfilter/source/hwpeq.cxx @@ -68,6 +68,8 @@ enum { SCRIPT_NONE, SCRIPT_SUB, SCRIPT_SUP, SCRIPT_ALL}; static int eq_word(MzString& outs, istream *strm, int script = SCRIPT_NONE); static bool eq_sentence(MzString& outs, istream *strm, const char *end = nullptr); +namespace { + struct hwpeq { const char *key; // hwp math keyword const char *latex; // corresponding latex keyword @@ -75,6 +77,8 @@ struct hwpeq { unsigned char flag; // case sensitive? }; +} + static const hwpeq eq_tbl[] = { { "!=", "\\equiv ", 0, 0 }, { "#", "\\\\", 0, 0 }, @@ -452,6 +456,8 @@ static void make_keyword( char *keyword, const char *token) } } +namespace { + // token reading function struct eq_stack { MzString white; @@ -465,6 +471,8 @@ struct eq_stack { } }; +} + static eq_stack *stk = nullptr; static void push_token(MzString const &white, MzString const &token, istream *strm) diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx index 4144d20e0bde..51f072fed4ad 100644 --- a/hwpfilter/source/hwpreader.cxx +++ b/hwpfilter/source/hwpreader.cxx @@ -927,6 +927,7 @@ void HwpReader::makeAutoStyles() rendEl("office:automatic-styles"); } +namespace { struct PageSetting { @@ -951,6 +952,8 @@ struct PageSetting bool bIsSet; }; +} + void HwpReader::makeMasterStyles() { rstartEl("office:master-styles", mxList.get()); diff --git a/hwpfilter/source/lexer.cxx b/hwpfilter/source/lexer.cxx index d70d81a92923..829431cfcc50 100644 --- a/hwpfilter/source/lexer.cxx +++ b/hwpfilter/source/lexer.cxx @@ -89,8 +89,12 @@ /* Size of default input buffer. */ #define YY_BUF_SIZE 16384 +namespace { + typedef struct yy_buffer_state *YY_BUFFER_STATE; +} + #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 @@ -103,6 +107,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; */ typedef unsigned int yy_size_t; +namespace { struct yy_buffer_state { @@ -161,6 +166,8 @@ struct yy_buffer_state #define YY_BUFFER_EOF_PENDING 2 }; +} + static YY_BUFFER_STATE yy_current_buffer = nullptr; /* We provide macros for accessing buffer states in case in the |