]> granicus.if.org Git - icu/commitdiff
ICU-20814 new tool for checking API tags vs. ifdef guards; add FORCE guards, and...
authorMarkus Scherer <markus.icu@gmail.com>
Thu, 12 Sep 2019 00:25:34 +0000 (17:25 -0700)
committerMarkus Scherer <markus.icu@gmail.com>
Tue, 24 Sep 2019 00:04:53 +0000 (17:04 -0700)
31 files changed:
.travis.yml
icu4c/source/common/unicode/brkiter.h
icu4c/source/common/unicode/filteredbrk.h
icu4c/source/common/unicode/normlzr.h
icu4c/source/common/unicode/platform.h
icu4c/source/common/unicode/rbbi.h
icu4c/source/common/unicode/uconfig.h
icu4c/source/common/unicode/unorm.h
icu4c/source/common/unicode/utf_old.h
icu4c/source/i18n/unicode/calendar.h
icu4c/source/i18n/unicode/choicfmt.h
icu4c/source/i18n/unicode/coll.h
icu4c/source/i18n/unicode/decimfmt.h
icu4c/source/i18n/unicode/formattedvalue.h
icu4c/source/i18n/unicode/gregocal.h
icu4c/source/i18n/unicode/measfmt.h
icu4c/source/i18n/unicode/nounit.h
icu4c/source/i18n/unicode/numberformatter.h
icu4c/source/i18n/unicode/rbtz.h
icu4c/source/i18n/unicode/simpletz.h
icu4c/source/i18n/unicode/tblcoll.h
icu4c/source/i18n/unicode/timezone.h
icu4c/source/i18n/unicode/tmutfmt.h
icu4c/source/i18n/unicode/ucal.h
icu4c/source/i18n/unicode/ucol.h
icu4c/source/i18n/unicode/udat.h
icu4c/source/i18n/unicode/udatpg.h
icu4c/source/i18n/unicode/uformattedvalue.h
icu4c/source/i18n/unicode/unum.h
icu4c/source/i18n/unicode/vtzone.h
icu4c/source/test/hdrtst/testtagsguards.sh [new file with mode: 0755]

index 289f9cc0295776d6fd0acf03562de01900fd19d6..21370d66b663a90f9b4c105d5a6a4ebc591e3532 100644 (file)
@@ -66,6 +66,11 @@ matrix:
         - PATH="${PREFIX}/bin:$PATH" make -C test/hdrtst check
 
     # clang release build with some options to enforce useful constraints.
+    # Includes dependency checker on an in-source, optimized build.
+    # Includes checking @draft etc. API tags vs. ifndef guards like
+    # U_HIDE_DRAFT_API and U_FORCE_HIDE_DRAFT_API.
+    # (FORCE guards make this tool pass but won't compile to working code.
+    # See the testtagsguards.sh script for details.)
     - name: "c: linux clang"
       dist:     xenial
       language: cpp
@@ -81,6 +86,7 @@ matrix:
       script:
         - make -j2 check
         - ( cd test/depstest && python3 depstest.py ../../../source/ )
+        - ( cd .. && source/test/hdrtst/testtagsguards.sh )
 
     - name: "c: osx clang"
       language: cpp
index 74481983b3f0aeedb3f6093949203017a8431499..b944497345479b90b2791763d036ce9a50661234 100644 (file)
@@ -497,6 +497,7 @@ public:
     static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
                                          UnicodeString& name);
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Deprecated functionality. Use clone() instead.
      *
@@ -519,6 +520,7 @@ public:
     virtual BreakIterator *  createBufferClone(void *stackBuffer,
                                                int32_t &BufferSize,
                                                UErrorCode &status) = 0;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
 #ifndef U_HIDE_DEPRECATED_API
 
index a084556206e585fbfed6cf7a7e30b14df43f2089..42936763259e2d7bd0797c6239cc543e38cb3279 100644 (file)
@@ -104,6 +104,7 @@ class U_COMMON_API FilteredBreakIteratorBuilder : public UObject {
    */
   virtual UBool unsuppressBreakAfter(const UnicodeString& string, UErrorCode& status) = 0;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
   /**
    * This function has been deprecated in favor of wrapIteratorWithFilter()
    * The behavior is identical.
@@ -114,6 +115,7 @@ class U_COMMON_API FilteredBreakIteratorBuilder : public UObject {
    * @see wrapBreakIteratorWithFilter()
    */
   virtual BreakIterator *build(BreakIterator* adoptBreakIterator, UErrorCode& status) = 0;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
   /**
    * Wrap (adopt) an existing break iterator in a new filtered instance.
index 05bc9dfc2957daf6e50619b163c154b2463e14e6..07a596bd11b9187ec7194b5ba60c78882e7c225b 100644 (file)
@@ -185,6 +185,7 @@ public:
   Normalizer(const CharacterIterator& iter, UNormalizationMode mode);
 #endif  /* U_HIDE_DEPRECATED_API */
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
   /**
    * Copy constructor.
    * @param copy The object to be copied.
@@ -197,7 +198,7 @@ public:
    * @deprecated ICU 56 Use Normalizer2 instead.
    */
   virtual ~Normalizer();
-
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
   //-------------------------------------------------------------------------
   // Static utility methods
@@ -725,12 +726,14 @@ public:
   static UClassID U_EXPORT2 getStaticClassID();
 #endif  /* U_HIDE_DEPRECATED_API */
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
   /**
    * ICU "poor man's RTTI", returns a UClassID for the actual class.
    * @return a UClassID for the actual class.
    * @deprecated ICU 56 Use Normalizer2 instead.
    */
   virtual UClassID getDynamicClassID() const;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
 private:
   //-------------------------------------------------------------------------
index 9180a8de79cd96ef3259998042d8d9fd5034a16d..ad75b298a42c52f66e7d6d6b856506f2130930e3 100644 (file)
@@ -882,4 +882,4 @@ namespace std {
 #endif
 /* @} */
 
-#endif
+#endif  // _PLATFORM_H
index 90dee20906faa8610de2776f3abc0f6d46b81aa2..7825f603a51c1b98686c2985372d4d1e6d261365 100644 (file)
@@ -538,6 +538,7 @@ public:
      */
     static UClassID U_EXPORT2 getStaticClassID(void);
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Deprecated functionality. Use clone() instead.
      *
@@ -567,7 +568,7 @@ public:
     virtual RuleBasedBreakIterator *createBufferClone(void *stackBuffer,
                                                       int32_t &BufferSize,
                                                       UErrorCode &status);
-
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Return the binary form of compiled break rules,
index e61eb5795c68abfc6417343b3d9e1770c1419298..bbc232d1ed8fdf94ed8b6f4e5ff9c3aeea7a5e88 100644 (file)
 #   define UCONFIG_NO_FILTERED_BREAK_ITERATION 0
 #endif
 
-#endif
+#endif  // __UCONFIG_H__
index 3839de129573c19b05247ae9d35c2b294ee41f38..09dd366a968c1b473d76417e6dec2a6570872788 100644 (file)
 
 // Do not conditionalize the following enum with #ifndef U_HIDE_DEPRECATED_API,
 // it is needed for layout of Normalizer object.
+#ifndef U_FORCE_HIDE_DEPRECATED_API
+
 /**
  * Constants for normalization modes.
  * @deprecated ICU 56 Use unorm2.h instead.
@@ -155,6 +157,8 @@ typedef enum {
   UNORM_MODE_COUNT
 } UNormalizationMode;
 
+#endif  // U_FORCE_HIDE_DEPRECATED_API
+
 #ifndef U_HIDE_DEPRECATED_API
 
 /**
index b18b824bfcb45651741a63c9c16779c00eaeff99..b2428e6b31e28273c68180465dd545e0bb914d17 100644 (file)
@@ -19,9 +19,6 @@
 /**
  * \file
  * \brief C API: Deprecated macros for Unicode string handling
- */
-
-/**
  *
  * The macros in utf_old.h are all deprecated and their use discouraged.
  * Some of the design principles behind the set of UTF macros
  *
  * <hr>
  *
- * @deprecated ICU 2.4. Use the macros in utf.h, utf16.h, utf8.h instead.
+ * Deprecated ICU 2.4. Use the macros in utf.h, utf16.h, utf8.h instead.
  */
 
 #ifndef __UTF_OLD_H__
 #define __UTF_OLD_H__
 
+#include "unicode/utf.h"
+#include "unicode/utf8.h"
+#include "unicode/utf16.h"
+
 /**
  * \def U_HIDE_OBSOLETE_UTF_OLD_H
  *
 
 #if !defined(U_HIDE_DEPRECATED_API) && !U_HIDE_OBSOLETE_UTF_OLD_H
 
-#include "unicode/utf.h"
-#include "unicode/utf8.h"
-#include "unicode/utf16.h"
-
 /* Formerly utf.h, part 1 --------------------------------------------------- */
 
 #ifdef U_USE_UTF_DEPRECATES
index 47167114ab354820f307ec3a8a64f5994d7297f5..2a8c2935ca8e24696353e1a7e62e43e67d2703e0 100644 (file)
@@ -186,7 +186,7 @@ class BasicTimeZone;
  */
 class U_I18N_API Calendar : public UObject {
 public:
-
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Field IDs for date and time. Used to specify date/time fields. ERA is calendar
      * specific. Example ranges given are for illustration only; see specific Calendar
@@ -229,6 +229,7 @@ public:
         FIELD_COUNT = UCAL_FIELD_COUNT // See ucal.h for other fields.
 #endif /* U_HIDE_DEPRECATED_API */
     };
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
 #ifndef U_HIDE_DEPRECATED_API
     /**
@@ -520,6 +521,7 @@ public:
      */
     UBool after(const Calendar& when, UErrorCode& status) const;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * UDate Arithmetic function. Adds the specified (signed) amount of time to the given
      * time field, based on the calendar's rules. For example, to subtract 5 days from
@@ -541,6 +543,7 @@ public:
      * @deprecated ICU 2.6. use add(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
      */
     virtual void add(EDateFields field, int32_t amount, UErrorCode& status);
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * UDate Arithmetic function. Adds the specified (signed) amount of time to the given
@@ -634,6 +637,7 @@ public:
      */
     inline void roll(UCalendarDateFields field, UBool up, UErrorCode& status);
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Time Field Rolling function. Rolls by the given amount on the given
      * time field. For example, to roll the current date up by one day, call
@@ -666,6 +670,7 @@ public:
      * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
      */
     virtual void roll(EDateFields field, int32_t amount, UErrorCode& status);
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Time Field Rolling function. Rolls by the given amount on the given
@@ -700,6 +705,7 @@ public:
      */
     virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status);
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Return the difference between the given time and the time this
      * calendar object is set to.  If this calendar is set
@@ -756,6 +762,7 @@ public:
      * @deprecated ICU 2.6. Use fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status).
      */
     virtual int32_t fieldDifference(UDate when, EDateFields field, UErrorCode& status);
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Return the difference between the given time and the time this
@@ -1012,6 +1019,7 @@ public:
      */
     uint8_t getMinimalDaysInFirstWeek(void) const;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Gets the minimum value for the given time field. e.g., for Gregorian
      * DAY_OF_MONTH, 1.
@@ -1021,6 +1029,7 @@ public:
      * @deprecated ICU 2.6. Use getMinimum(UCalendarDateFields field) instead.
      */
     virtual int32_t getMinimum(EDateFields field) const;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Gets the minimum value for the given time field. e.g., for Gregorian
@@ -1032,6 +1041,7 @@ public:
      */
     virtual int32_t getMinimum(UCalendarDateFields field) const;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH,
      * 31.
@@ -1041,6 +1051,7 @@ public:
      * @deprecated ICU 2.6. Use getMaximum(UCalendarDateFields field) instead.
      */
     virtual int32_t getMaximum(EDateFields field) const;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH,
@@ -1052,6 +1063,7 @@ public:
      */
     virtual int32_t getMaximum(UCalendarDateFields field) const;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Gets the highest minimum value for the given field if varies. Otherwise same as
      * getMinimum(). For Gregorian, no difference.
@@ -1061,6 +1073,7 @@ public:
      * @deprecated ICU 2.6. Use getGreatestMinimum(UCalendarDateFields field) instead.
      */
     virtual int32_t getGreatestMinimum(EDateFields field) const;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Gets the highest minimum value for the given field if varies. Otherwise same as
@@ -1072,6 +1085,7 @@ public:
      */
     virtual int32_t getGreatestMinimum(UCalendarDateFields field) const;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Gets the lowest maximum value for the given field if varies. Otherwise same as
      * getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.
@@ -1081,6 +1095,7 @@ public:
      * @deprecated ICU 2.6. Use getLeastMaximum(UCalendarDateFields field) instead.
      */
     virtual int32_t getLeastMaximum(EDateFields field) const;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Gets the lowest maximum value for the given field if varies. Otherwise same as
@@ -1897,11 +1912,13 @@ protected:
      */
     int32_t     fFields[UCAL_FIELD_COUNT];
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * The flags which tell if a specified time field for the calendar is set.
      * @deprecated ICU 2.8 use (fStamp[n]!=kUnset)
      */
     UBool      fIsSet[UCAL_FIELD_COUNT];
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /** Special values of stamp[]
      * @stable ICU 2.0
index 54c2e1342fa95201c35c4237b89713fa386e5c0b..3b2f48cb1f853ca1c3f84a735e7fc67c844daa82 100644 (file)
@@ -34,7 +34,6 @@
  */
 
 #if !UCONFIG_NO_FORMATTING
-#ifndef U_HIDE_DEPRECATED_API
 
 #include "unicode/fieldpos.h"
 #include "unicode/format.h"
@@ -42,6 +41,8 @@
 #include "unicode/numfmt.h"
 #include "unicode/unistr.h"
 
+#ifndef U_HIDE_DEPRECATED_API
+
 U_NAMESPACE_BEGIN
 
 class MessageFormat;
index 861bd5c94af260f1d456833abba0863cac2a0eec..f5564c73944bcb1bf30123fbe5818e7ca5398b27 100644 (file)
@@ -206,6 +206,7 @@ public:
 
     // Cannot use #ifndef U_HIDE_DEPRECATED_API for the following, it is
     // used by virtual methods that cannot have that conditional.
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * LESS is returned if source string is compared to be less than target
      * string in the compare() method.
@@ -222,6 +223,7 @@ public:
         EQUAL = UCOL_EQUAL,  // 0
         GREATER = UCOL_GREATER  // 1
     };
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     // Collator public destructor -----------------------------------------
 
@@ -325,6 +327,7 @@ public:
      */
     static Collator* U_EXPORT2 createInstance(const Locale& loc, UErrorCode& err);
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * The comparison function compares the character data stored in two
      * different strings. Returns information about whether a string is less
@@ -338,6 +341,7 @@ public:
      */
     virtual EComparisonResult compare(const UnicodeString& source,
                                       const UnicodeString& target) const;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * The comparison function compares the character data stored in two
@@ -355,6 +359,7 @@ public:
                                       const UnicodeString& target,
                                       UErrorCode &status) const = 0;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Does the same thing as compare but limits the comparison to a specified
      * length
@@ -370,6 +375,7 @@ public:
     virtual EComparisonResult compare(const UnicodeString& source,
                                       const UnicodeString& target,
                                       int32_t length) const;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Does the same thing as compare but limits the comparison to a specified
@@ -389,6 +395,7 @@ public:
                                       int32_t length,
                                       UErrorCode &status) const = 0;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * The comparison function compares the character data stored in two
      * different string arrays. Returns information about whether a string array
@@ -425,6 +432,7 @@ public:
     virtual EComparisonResult compare(const char16_t* source, int32_t sourceLength,
                                       const char16_t* target, int32_t targetLength)
                                       const;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * The comparison function compares the character data stored in two
@@ -529,6 +537,7 @@ public:
      */
     virtual int32_t hashCode(void) const = 0;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Gets the locale of the Collator
      *
@@ -542,6 +551,7 @@ public:
      * in ICU 3.0.
      */
     virtual Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const = 0;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Convenience method for comparing two strings based on the collation rules.
@@ -578,6 +588,7 @@ public:
      */
     UBool equals(const UnicodeString& source, const UnicodeString& target) const;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Determines the minimum strength that will be used in comparison or
      * transformation.
@@ -609,6 +620,7 @@ public:
      * @deprecated ICU 2.6 Use setAttribute(UCOL_STRENGTH...) instead
      */
     virtual void setStrength(ECollationStrength newStrength);
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Retrieves the reordering codes for this collator.
@@ -906,6 +918,7 @@ public:
      */
     virtual UColReorderCode getMaxVariable() const;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Sets the variable top to the primary weight of the specified string.
      *
@@ -953,6 +966,7 @@ public:
      * @deprecated ICU 53 Call setMaxVariable() instead.
      */
     virtual void setVariableTop(uint32_t varTop, UErrorCode &status) = 0;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Gets the variable top value of a Collator.
@@ -974,6 +988,7 @@ public:
      */
     virtual UnicodeSet *getTailoredSet(UErrorCode &status) const;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Same as clone().
      * The base class implementation simply calls clone().
@@ -982,6 +997,7 @@ public:
      * @deprecated ICU 50 no need to have two methods for cloning
      */
     virtual Collator* safeClone() const;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Get the sort key as an array of bytes from a UnicodeString.
index 0e93c17c55cec1f0c74fa9ac1d56fc5783042926..c33ec80cacc5e08481652a3e93cc0750fb80ea57 100644 (file)
@@ -2021,12 +2021,14 @@ class U_I18N_API DecimalFormat : public NumberFormat {
      */
     void setCurrency(const char16_t* theCurrency, UErrorCode& ec) U_OVERRIDE;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Sets the currency used to display currency amounts.  See
      * setCurrency(const char16_t*, UErrorCode&).
      * @deprecated ICU 3.0. Use setCurrency(const char16_t*, UErrorCode&).
      */
     virtual void setCurrency(const char16_t* theCurrency);
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Sets the `Currency Usage` object used to display currency.
index 61fdb8ec6afc7fd4745ef8e8c008969b77d119a8..5c47264136b370feadf9cc1908a6dc8010fd3d8e 100644 (file)
@@ -29,6 +29,7 @@ U_NAMESPACE_BEGIN
 // The following cannot have #ifndef U_HIDE_DRAFT_API because
 // class FormattedValue depends on it, and FormattedValue cannot be
 // hidden becauseclass FormattedNumber (stable ICU 60) depends on it.
+#ifndef U_FORCE_HIDE_DRAFT_API
 /**
  * Represents a span of a string containing a given field.
  *
@@ -320,7 +321,7 @@ class U_I18N_API FormattedValue /* not : public UObject because this is an inter
      */
     virtual UBool nextPosition(ConstrainedFieldPosition& cfpos, UErrorCode& status) const = 0;
 };
-
+#endif  // U_FORCE_HIDE_DRAFT_API
 
 U_NAMESPACE_END
 
index 9249b59be06f9dcbe1894311595fbb5cde4ea0bb..4ce40daf3a4f340b952850e7a247a63bc10c0ee5 100644 (file)
@@ -352,6 +352,7 @@ public:
      */
     virtual UBool isEquivalentTo(const Calendar& other) const;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * (Overrides Calendar) Rolls up or down by the given amount in the specified field.
      * For more information, see the documentation for Calendar::roll().
@@ -364,6 +365,7 @@ public:
      * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
      */
     virtual void roll(EDateFields field, int32_t amount, UErrorCode& status);
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * (Overrides Calendar) Rolls up or down by the given amount in the specified field.
index df79c0f6ed1c74467e4276f165b62cc127f9cc29..b4f904862946f77fa9d8de946562b6201326b0fc 100644 (file)
@@ -165,6 +165,7 @@ class U_I18N_API MeasureFormat : public Format {
             FieldPosition &pos,
             UErrorCode &status) const;
 
+#ifndef U_FORCE_HIDE_DRAFT_API
     /**
      * Parse a string to produce an object. This implementation sets
      * status to U_UNSUPPORTED_ERROR.
@@ -175,6 +176,7 @@ class U_I18N_API MeasureFormat : public Format {
             const UnicodeString &source,
             Formattable &reslt,
             ParsePosition &pos) const;
+#endif  // U_FORCE_HIDE_DRAFT_API
 
     /**
      * Formats measure objects to produce a string. An example of such a
index e1da7c53c4beda5676ad6588048a59052ad79318..61b5c16ee3955b7a02959a185dbc92699e64eb42 100644 (file)
 #if U_SHOW_CPLUSPLUS_API
 
 #if !UCONFIG_NO_FORMATTING
-#ifndef U_HIDE_DRAFT_API
 
 #include "unicode/measunit.h"
 
+#ifndef U_HIDE_DRAFT_API
+
 /**
  * \file
  * \brief C++ API: units for percent and permille
index 82d2e3c596efa21f67120ebddc29bcdd02eeb2b8..6d48f18ab55a4d41080259775a016cc729da9536 100644 (file)
@@ -2411,12 +2411,14 @@ class U_I18N_API FormattedNumber : public UMemory, public FormattedValue {
   public:
 
     // Default constructor cannot have #ifndef U_HIDE_DRAFT_API
+#ifndef U_FORCE_HIDE_DRAFT_API
     /**
      * Default constructor; makes an empty FormattedNumber.
      * @draft ICU 64
      */
     FormattedNumber()
         : fData(nullptr), fErrorCode(U_INVALID_STATE_ERROR) {}
+#endif  // U_FORCE_HIDE_DRAFT_API
 
     /**
      * Move constructor: Leaves the source FormattedNumber in an undefined state.
index 56d6f1c1d0e3c645ee52f334eab6637357ffd0a8..d66e1f08ec85d64305961f829e93c04000c2082f 100644 (file)
@@ -226,6 +226,7 @@ public:
      */
     virtual UBool useDaylightTime(void) const;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Queries if the given date is in daylight savings time in
      * this time zone.
@@ -240,6 +241,7 @@ public:
      * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead.
      */
     virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Returns true if this zone has the same rule and offset as another zone.
index f8e2a747942b7ea79a525c4c7b8f9acb52100736..980a1b8c62e0d4ead90ad66fbedf11b19c934e34 100644 (file)
@@ -674,6 +674,7 @@ public:
      */
     virtual UBool useDaylightTime(void) const;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Returns true if the given date is within the period when daylight savings time
      * is in effect; false otherwise.  If the TimeZone doesn't observe daylight savings
@@ -689,6 +690,7 @@ public:
      * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead.
      */
     virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Return true if this zone has the same rules and offset as another zone.
index c4471b0144097837d27b953a0487d7c9726afe74..f5dc135bc49fc1aa9afef169210e11066237bca4 100644 (file)
@@ -391,6 +391,7 @@ public:
      */
     virtual int32_t hashCode() const;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
     * Gets the locale of the Collator
     * @param type can be either requested, valid or actual locale. For more
@@ -402,6 +403,7 @@ public:
     * @deprecated ICU 2.8 likely to change in ICU 3.0, based on feedback
     */
     virtual Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Gets the tailoring rules for this collator.
@@ -547,6 +549,7 @@ public:
      */
     virtual UColReorderCode getMaxVariable() const;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Sets the variable top to the primary weight of the specified string.
      *
@@ -594,6 +597,7 @@ public:
      * @deprecated ICU 53 Call setMaxVariable() instead.
      */
     virtual void setVariableTop(uint32_t varTop, UErrorCode &status);
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Gets the variable top value of a Collator.
index 5c361e7bcdbe876d94a9b4bf86ad2b35d565243d..433e3b5c4666902c66b051c87a7ae57627ec61f0 100644 (file)
@@ -722,6 +722,7 @@ public:
      */
     virtual UBool useDaylightTime(void) const = 0;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Queries if the given date is in daylight savings time in
      * this time zone.
@@ -736,6 +737,7 @@ public:
      * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead.
      */
     virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Returns true if this zone has the same rule and offset as another zone.
index 82be59705946370b6add5db1196e0c1577049e24..ad871f7c09fd4f43f2f1cb05b2bbd71f8b696581 100644 (file)
@@ -21,7 +21,6 @@
 #if U_SHOW_CPLUSPLUS_API
 
 #if !UCONFIG_NO_FORMATTING
-#ifndef U_HIDE_DEPRECATED_API
 
 #include "unicode/unistr.h"
 #include "unicode/tmunit.h"
@@ -30,6 +29,7 @@
 #include "unicode/numfmt.h"
 #include "unicode/plurrule.h"
 
+#ifndef U_HIDE_DEPRECATED_API
 
 /**
  * Constants for various styles.
index 4466223bf0fc7f231658e40fc2a6bc8a981c0f3e..c198450ba2f82374cd068b39e211dea0b8241279 100644 (file)
@@ -441,11 +441,13 @@ enum UCalendarDateFields {
 
     /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
      * it is needed for layout of Calendar, DateFormat, and other objects */
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * One more than the highest normal UCalendarDateFields value.
      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
      */
-  UCAL_FIELD_COUNT,
+    UCAL_FIELD_COUNT,
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
  /**
    * Field number indicating the
index dbac48e3e498b47b2ccb14850005c8e3869664ca..673af1c55a70c90815efa22823f5439808823171 100644 (file)
@@ -344,11 +344,13 @@ typedef enum {
 
     /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
      * it is needed for layout of RuleBasedCollator object. */
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * One more than the highest normal UColAttribute value.
      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
      */
      UCOL_ATTRIBUTE_COUNT
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 } UColAttribute;
 
 /** Options for retrieving the rule string 
index c67a6d6d4b3a797c741e8ea55d96ed2ba390e730..bdbd080c0058218141ba89ca10687790b893bf83 100644 (file)
@@ -923,11 +923,13 @@ typedef enum UDateFormatBooleanAttribute {
 
     /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
      * it is needed for layout of DateFormat object. */
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * One more than the highest normal UDateFormatBooleanAttribute value.
      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
      */
     UDAT_BOOLEAN_ATTRIBUTE_COUNT = 4
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 } UDateFormatBooleanAttribute;
 
 /**
index fc25d579ff82cd586cb622511424964ccf1c4712..7f28b5a31978f20c78dd4e5a0caa14fafa3db1f1 100644 (file)
@@ -88,11 +88,13 @@ typedef enum UDateTimePatternField {
 
     /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
      * it is needed for layout of DateTimePatternGenerator object. */
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * One more than the highest normal UDateTimePatternField value.
      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
      */
     UDATPG_FIELD_COUNT
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 } UDateTimePatternField;
 
 /**
index eaa4f28893a07654d46112afdf515bd2d05688bc..0b289e3b45515035488e81b1d92f1fdb2c40a288 100644 (file)
@@ -7,10 +7,11 @@
 #include "unicode/utypes.h"
 
 #if !UCONFIG_NO_FORMATTING
-#ifndef U_HIDE_DRAFT_API
 
 #include "unicode/ufieldpositer.h"
 
+#ifndef U_HIDE_DRAFT_API
+
 /**
  * \file
  * \brief C API: Abstract operations for localized strings.
index 3d55cc85ffb30e997ed521b66fefc56f4b95dcef..4304538f059d2d3b5da8caf86951bca77af62f2c 100644 (file)
@@ -338,11 +338,13 @@ enum UCurrencySpacing {
 
     /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
      * it is needed for layout of DecimalFormatSymbols object. */
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * One more than the highest normal UCurrencySpacing value.
      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
      */
     UNUM_CURRENCY_SPACING_COUNT
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 };
 typedef enum UCurrencySpacing UCurrencySpacing; /**< @stable ICU 4.8 */
 
index 32e22b295a43bfec9b93ca19d4ae69f0aa2676ab..2743b6c474f78547917f13208b2f7fb66b7415de 100644 (file)
@@ -290,6 +290,7 @@ public:
      */
     virtual UBool useDaylightTime(void) const;
 
+#ifndef U_FORCE_HIDE_DEPRECATED_API
     /**
      * Queries if the given date is in daylight savings time in
      * this time zone.
@@ -304,6 +305,7 @@ public:
      * @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead.
      */
     virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
+#endif  // U_FORCE_HIDE_DEPRECATED_API
 
     /**
      * Returns true if this zone has the same rule and offset as another zone.
diff --git a/icu4c/source/test/hdrtst/testtagsguards.sh b/icu4c/source/test/hdrtst/testtagsguards.sh
new file mode 100755 (executable)
index 0000000..928707c
--- /dev/null
@@ -0,0 +1,94 @@
+# Copyright © 2019 and later: Unicode, Inc. and others.
+# License & terms of use: http://www.unicode.org/copyright.html
+
+# Run this script from $ICU_ROOT/icu4c.
+# ~/icu/mine/src/icu4c$ source/test/hdrtest/testtagsguards.sh
+
+# set -x # echo on
+
+DEF=-DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1
+INCL="-Isource/common -Isource/i18n -Isource/io"
+TMPDIR=`mktemp -d`
+DIFF="diff -u --minimal"
+
+echo "*** testtagsguards.sh TMPDIR=$TMPDIR"
+
+for file in source/common/unicode/*.h source/i18n/unicode/*.h source/io/unicode/*.h ; do
+    base=`basename $file`
+    echo $file
+    echo '#include "unicode/'$base'"' > $TMPDIR/ht-$base.cpp
+    # Preprocess only.
+    clang++ $INCL -C -E $DEF -o $TMPDIR/ht-$base-normal.i $TMPDIR/ht-$base.cpp
+
+    # When hiding @draft, none should be in the output.
+    TAG=draft
+    GUARD=DRAFT
+    echo "    @$TAG"
+    clang++ $INCL -C -E -DU_HIDE_${GUARD}_API=1 -DU_FORCE_HIDE_${GUARD}_API=1 $DEF -o $TMPDIR/ht-$base-$TAG.i $TMPDIR/ht-$base.cpp
+    if grep "@$TAG" -C 5 $TMPDIR/ht-$base-$TAG.i; then
+        echo "*** error: @$TAG not hidden in $TMPDIR/ht-$base-$TAG.i"
+        exit 1
+    fi
+    # Only @draft should be hidden.
+    # Except: Ok to hide nested @internal/@system/@obsolete.
+    $DIFF $TMPDIR/ht-$base-normal.i $TMPDIR/ht-$base-$TAG.i > $TMPDIR/ht-$base-normal-$TAG.txt
+    if egrep '^-.*@(stable|deprecated)' -C 5 $TMPDIR/ht-$base-normal-$TAG.txt; then
+        echo "*** error: Non-@$TAG hidden in $TMPDIR/ht-$base-$TAG.i see $TMPDIR/ht-$base-normal-$TAG.txt"
+        cat $TMPDIR/ht-$base-normal-$TAG.txt
+        exit 1
+    fi
+
+    # @deprecated
+    TAG=deprecated
+    GUARD=DEPRECATED
+    echo "    @$TAG"
+    clang++ $INCL -C -E -DU_HIDE_${GUARD}_API=1 -DU_FORCE_HIDE_${GUARD}_API=1 $DEF -o $TMPDIR/ht-$base-$TAG.i $TMPDIR/ht-$base.cpp
+    if grep "@$TAG" -C 5 $TMPDIR/ht-$base-$TAG.i; then
+        echo "*** error: @$TAG not hidden in $TMPDIR/ht-$base-$TAG.i"
+        exit 1
+    fi
+    # In the egrep: All tags except $TAG and @internal & similar.
+    $DIFF $TMPDIR/ht-$base-normal.i $TMPDIR/ht-$base-$TAG.i > $TMPDIR/ht-$base-normal-$TAG.txt
+    if egrep '^-.*@(stable|draft)' -C 5 $TMPDIR/ht-$base-normal-$TAG.txt; then
+        echo "*** error: Non-@$TAG hidden in $TMPDIR/ht-$base-$TAG.i see $TMPDIR/ht-$base-normal-$TAG.txt"
+        cat $TMPDIR/ht-$base-normal-$TAG.txt
+        exit 1
+    fi
+
+    # TODO: @internal
+    # Hiding some @internal definitions, in particular in platform.h and similar,
+    # tends to break even preprocessing of other headers.
+
+    # @system
+    TAG=system
+    GUARD=SYSTEM
+    echo "    @$TAG"
+    clang++ $INCL -C -E -DU_HIDE_${GUARD}_API=1 -DU_FORCE_HIDE_${GUARD}_API=1 $DEF -o $TMPDIR/ht-$base-$TAG.i $TMPDIR/ht-$base.cpp
+    if grep "@$TAG" -C 5 $TMPDIR/ht-$base-$TAG.i; then
+        echo "*** error: @$TAG not hidden in $TMPDIR/ht-$base-$TAG.i"
+        exit 1
+    fi
+    # @system is orthogonal to @stable / @deprecated etc.,
+    # so we don't check that none of those are hidden.
+
+    # @obsolete
+    TAG=obsolete
+    GUARD=OBSOLETE
+    echo "    @$TAG"
+    clang++ $INCL -C -E -DU_HIDE_${GUARD}_API=1 -DU_FORCE_HIDE_${GUARD}_API=1 $DEF -o $TMPDIR/ht-$base-$TAG.i $TMPDIR/ht-$base.cpp
+    if grep "@$TAG" -C 5 $TMPDIR/ht-$base-$TAG.i; then
+        echo "*** error: @$TAG not hidden in $TMPDIR/ht-$base-$TAG.i"
+        exit 1
+    fi
+    # In the egrep: All tags except $TAG and @internal & similar.
+    $DIFF $TMPDIR/ht-$base-normal.i $TMPDIR/ht-$base-$TAG.i > $TMPDIR/ht-$base-normal-$TAG.txt
+    if egrep '^-.*@(stable|draft|deprecated)' -C 5 $TMPDIR/ht-$base-normal-$TAG.txt; then
+        echo "*** error: Non-@$TAG hidden in $TMPDIR/ht-$base-$TAG.i see $TMPDIR/ht-$base-normal-$TAG.txt"
+        cat $TMPDIR/ht-$base-normal-$TAG.txt
+        exit 1
+    fi
+done
+
+echo "pass"
+rm -rf $TMPDIR
+