From f73593a4034d9eec0ec4466b8e173d4a4daece1f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 26 Dec 2024 19:41:53 +0000 Subject: Drop usage of macro APT_OVERRIDE for simple override We were rather inconsistent in using it and as our public headers contain deduction guides (a c++17 feature) it seems silly to try to hide a c++11 feature in a macro, so lets stop this charade and drop the macro and while we are changing all these lines lets apply [[nodiscard]] (another c++17 feature) and other suggestions from clang-tidy and formatting for a little more consistency. --- apt-pkg/deb/deblistparser.h | 46 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'apt-pkg/deb/deblistparser.h') diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 637063f94..200e04036 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -59,21 +59,21 @@ class APT_HIDDEN debListParser : public pkgCacheListParser APT_PUBLIC static unsigned char GetPrio(std::string Str); // These all operate against the current section - virtual std::string Package() APT_OVERRIDE; - virtual bool ArchitectureAll() APT_OVERRIDE; - virtual std::string_view Architecture() APT_OVERRIDE; - virtual std::string_view Version() APT_OVERRIDE; - virtual bool NewVersion(pkgCache::VerIterator &Ver) APT_OVERRIDE; - virtual std::vector AvailableDescriptionLanguages() APT_OVERRIDE; - virtual std::string_view Description_md5() APT_OVERRIDE; - virtual uint32_t VersionHash() APT_OVERRIDE; - virtual bool SameVersion(uint32_t Hash, pkgCache::VerIterator const &Ver) APT_OVERRIDE; - virtual bool UsePackage(pkgCache::PkgIterator &Pkg, - pkgCache::VerIterator &Ver) APT_OVERRIDE; - virtual map_filesize_t Offset() APT_OVERRIDE {return iOffset;}; - virtual map_filesize_t Size() APT_OVERRIDE {return Section.size();}; - - virtual bool Step() APT_OVERRIDE; + std::string Package() override; + bool ArchitectureAll() override; + std::string_view Architecture() override; + std::string_view Version() override; + bool NewVersion(pkgCache::VerIterator &Ver) override; + std::vector AvailableDescriptionLanguages() override; + std::string_view Description_md5() override; + uint32_t VersionHash() override; + bool SameVersion(uint32_t Hash, pkgCache::VerIterator const &Ver) override; + bool UsePackage(pkgCache::PkgIterator &Pkg, + pkgCache::VerIterator &Ver) override; + map_filesize_t Offset() override { return iOffset; }; + map_filesize_t Size() override { return Section.size(); }; + + bool Step() override; APT_PUBLIC static const char *ParseDepends(const char *Start, const char *Stop, std::string &Package, std::string &Ver, unsigned int &Op, @@ -99,7 +99,7 @@ class APT_HIDDEN debListParser : public pkgCacheListParser APT_PUBLIC static const char *ConvertRelation(const char *I,unsigned int &Op); explicit debListParser(FileFd *File); - virtual ~debListParser(); + ~debListParser() override; #ifdef APT_COMPILING_APT std::string_view SHA256() const @@ -116,25 +116,25 @@ class APT_HIDDEN debDebFileParser : public debListParser public: debDebFileParser(FileFd *File, std::string const &DebFile); - virtual bool UsePackage(pkgCache::PkgIterator &Pkg, - pkgCache::VerIterator &Ver) APT_OVERRIDE; + bool UsePackage(pkgCache::PkgIterator &Pkg, + pkgCache::VerIterator &Ver) override; }; class APT_HIDDEN debTranslationsParser : public debListParser { public: // a translation can never be a real package - virtual std::string_view Architecture() APT_OVERRIDE { return ""; } - virtual std::string_view Version() APT_OVERRIDE { return ""; } + std::string_view Architecture() override { return {}; } + std::string_view Version() override { return {}; } - explicit debTranslationsParser(FileFd *File) - : debListParser(File) {}; + explicit debTranslationsParser(FileFd *File) + : debListParser(File) {}; }; class APT_HIDDEN debStatusListParser : public debListParser { public: - virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver) APT_OVERRIDE; + bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver) override; explicit debStatusListParser(FileFd *File) : debListParser(File) {}; }; -- cgit v1.2.3-70-g09d2 From 785a7a50b53bd0794e58cca31730818714992c00 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 26 Dec 2024 21:32:44 +0000 Subject: Drop APT_DEPRECATED usage C++14 includes the standard attribute, so we can use that instead. Note that we drop the deprecation of {Pkg,Dep}Iterator::operator<< as this is ignored (a friends declaration must be a definition to have attributes) very noisily by GCC >= 12 and the methods can be somewhat useful in debugging if you are to lazy to get APT::Pretty{Pkg,Dep}. --- apt-pkg/acquire-method.h | 2 +- apt-pkg/cacheiterators.h | 8 ++++---- apt-pkg/contrib/macros.h | 8 ++++---- apt-pkg/contrib/strutl.h | 2 +- apt-pkg/deb/deblistparser.h | 11 ++++++----- 5 files changed, 16 insertions(+), 15 deletions(-) (limited to 'apt-pkg/deb/deblistparser.h') diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h index 387d0984d..bad0935d6 100644 --- a/apt-pkg/acquire-method.h +++ b/apt-pkg/acquire-method.h @@ -102,7 +102,7 @@ class APT_PUBLIC pkgAcqMethod bool MediaFail(std::string Required,std::string Drive); virtual void Exit() {}; - APT_DEPRECATED_MSG("Use SendMessage instead") void PrintStatus(char const * const header, const char* Format, va_list &args) const; + [[deprecated("Use SendMessage instead")]] void PrintStatus(char const * const header, const char* Format, va_list &args) const; public: enum CnfFlags diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 9ed5c1719..31ce1b295 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -177,8 +177,8 @@ class APT_PUBLIC pkgCache::PkgIterator: public Iterator { OkState State() const APT_PURE; const char *CurVersion() const APT_PURE; - //Nice printable representation - APT_DEPRECATED_MSG("Use APT::PrettyPkg instead") friend std::ostream& operator <<(std::ostream& out, PkgIterator i); + // for a nice printable representation you likely want APT::PrettyPkg instead + friend std::ostream& operator<<(std::ostream& out, PkgIterator i); std::string FullName(bool const &Pretty = false) const; // Constructors @@ -364,8 +364,8 @@ class APT_PUBLIC pkgCache::DepIterator : public Iterator(newMap) + (S2 - static_cast(oldMap)); } - //Nice printable representation - APT_DEPRECATED_MSG("Use APT::PrettyDep instead") friend std::ostream& operator <<(std::ostream& out, DepIterator D); + // for a nice printable representation you likely want APT::PrettyDep instead + friend std::ostream& operator<<(std::ostream& out, DepIterator D); inline DepIterator(pkgCache &Owner, Dependency *Trg, Version* = 0) : Iterator(Owner, Trg), Type(DepVer), S2(Trg == 0 ? Owner.DepDataP : (Owner.DepDataP + Trg->DependencyData)) { diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h index c1fa73775..66437f305 100644 --- a/apt-pkg/contrib/macros.h +++ b/apt-pkg/contrib/macros.h @@ -36,16 +36,12 @@ #endif #if APT_GCC_VERSION >= 0x0300 - #define APT_DEPRECATED __attribute__ ((deprecated)) - #define APT_DEPRECATED_MSG(X) __attribute__ ((deprecated(X))) // __attribute__((const)) is too dangerous for us, we end up using it wrongly #define APT_PURE __attribute__((pure)) #define APT_PRINTF(n) __attribute__((format(printf, n, n + 1))) #define APT_WEAK __attribute__((weak)); #define APT_UNUSED __attribute__((unused)) #else - #define APT_DEPRECATED - #define APT_DEPRECATED_MSG #define APT_PURE #define APT_PRINTF(n) #define APT_WEAK @@ -135,8 +131,12 @@ AptScopeWrapper(F) -> AptScopeWrapper; #define CLRFLAG(v,f) ((v) &=~FLAG(f)) #define CHKFLAG(v,f) ((v) & FLAG(f) ? true : false) #if APT_GCC_VERSION >= 0x0300 + #define APT_DEPRECATED __attribute__ ((deprecated)) + #define APT_DEPRECATED_MSG(X) __attribute__ ((deprecated(X))) #define APT_NORETURN __attribute__((noreturn)) #else + #define APT_DEPRECATED + #define APT_DEPRECATED_MSG(X) #define APT_NORETURN #endif #endif diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index 91f5fe44b..ecb61000d 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -56,7 +56,7 @@ namespace APT { APT_PUBLIC bool UTF8ToCodeset(const char *codeset, const std::string &orig, std::string *dest); APT_PUBLIC char *_strstrip(char *String); APT_PUBLIC char *_strrstrip(char *String); // right strip only -APT_DEPRECATED_MSG("Use SubstVar to avoid memory headaches") APT_PUBLIC char *_strtabexpand(char *String,size_t Len); +[[deprecated("Use SubstVar to avoid memory headaches")]] APT_PUBLIC char *_strtabexpand(char *String,size_t Len); APT_PUBLIC bool ParseQuoteWord(const char *&String,std::string &Res); APT_PUBLIC bool ParseCWord(const char *&String,std::string &Res); APT_PUBLIC std::string QuoteString(const std::string &Str,const char *Bad); diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 200e04036..aec09ed2e 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -82,18 +82,19 @@ class APT_HIDDEN debListParser : public pkgCacheListParser std::string const &Arch = ""); #if APT_PKG_ABI <= 600 + [[deprecated("Use std::string_view variant instead")]] APT_PUBLIC static const char *ParseDepends(const char *Start, const char *Stop, APT::StringView &Package, APT::StringView &Ver, unsigned int &Op, - bool const ParseArchFlags = false, bool StripMultiArch = true, - bool const ParseRestrictionsList = false, - std::string Arch = "") APT_DEPRECATED_MSG("Use std::string_view variant instead"); + bool ParseArchFlags = false, bool StripMultiArch = true, + bool ParseRestrictionsList = false, + std::string Arch = ""); #endif APT_PUBLIC static const char *ParseDepends(const char *Start, const char *Stop, std::string_view &Package, std::string_view &Ver, unsigned int &Op, - bool const ParseArchFlags = false, bool StripMultiArch = true, - bool const ParseRestrictionsList = false, + bool ParseArchFlags = false, bool StripMultiArch = true, + bool ParseRestrictionsList = false, std::string Arch = ""); APT_PUBLIC static const char *ConvertRelation(const char *I,unsigned int &Op); -- cgit v1.2.3-70-g09d2