diff options
18 files changed, 24 insertions, 102 deletions
diff --git a/config/src/vespa/config/common/misc.h b/config/src/vespa/config/common/misc.h index 584a7ca527b..7c5fb82352c 100644 --- a/config/src/vespa/config/common/misc.h +++ b/config/src/vespa/config/common/misc.h @@ -23,8 +23,7 @@ vespalib::string calculateContentXxhash64(const StringVector & fileContents); bool isGenerationNewer(int64_t newGen, int64_t oldGen); // Helper for throwing invalid config exception -void throwInvalid(const char *fmt, ...) - __attribute__((format(printf, 1, 2))) __attribute__((noreturn)); +[[noreturn]] void throwInvalid(const char *fmt, ...) __attribute__((format(printf, 1, 2))); typedef std::shared_ptr<const vespalib::Slime> SlimePtr; diff --git a/configd/src/apps/sentinel/service.h b/configd/src/apps/sentinel/service.h index 6e4e0a60232..a5cdaabaab9 100644 --- a/configd/src/apps/sentinel/service.h +++ b/configd/src/apps/sentinel/service.h @@ -32,7 +32,7 @@ private: vespalib::duration _restartPenalty; vespalib::steady_time _last_start; - void runChild() __attribute__((noreturn)); + [[noreturn]] void runChild(); void setState(ServiceState state); void runCommand(const std::string & command); const char *stateName(ServiceState state) const; diff --git a/document/src/vespa/document/util/bytebuffer.cpp b/document/src/vespa/document/util/bytebuffer.cpp index 8568ce44c5e..f206fe89e91 100644 --- a/document/src/vespa/document/util/bytebuffer.cpp +++ b/document/src/vespa/document/util/bytebuffer.cpp @@ -19,7 +19,7 @@ namespace document { namespace { -static void throwOutOfBounds(size_t want, size_t has) __attribute__((noinline, noreturn)); +[[noreturn]] static void throwOutOfBounds(size_t want, size_t has) __attribute__((noinline)); void throwOutOfBounds(size_t want, size_t has) { diff --git a/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp b/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp index 33a52f70f2b..7ae4ac84bdb 100644 --- a/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp +++ b/searchcore/src/tests/proton/verify_ranksetup/verify_ranksetup_test.cpp @@ -31,10 +31,7 @@ struct Writer { file = fopen(file_name.c_str(), "w"); ASSERT_TRUE(file != nullptr); } - void fmt(const char *format, ...) const -#ifdef __GNUC__ - __attribute__ ((format (printf,2,3))) -#endif + void fmt(const char *format, ...) const __attribute__((format(printf,2,3))) { va_list ap; va_start(ap, format); diff --git a/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp b/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp index ac7dabd786b..07ff335092e 100644 --- a/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp +++ b/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp @@ -34,10 +34,7 @@ struct Writer { void write(const char *data, size_t size) const { fwrite(data, 1, size, file); } - void fmt(const char *format, ...) const -#ifdef __GNUC__ - __attribute__ ((format (printf,2,3))) -#endif + void fmt(const char *format, ...) const __attribute__ ((format (printf,2,3))) { va_list ap; va_start(ap, format); diff --git a/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.h b/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.h index 9f951f6a41d..e824b0dd691 100644 --- a/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.h +++ b/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.h @@ -9,7 +9,7 @@ namespace search { struct NotImplementedAttribute : AttributeVector { NotImplementedAttribute(const vespalib::string & name); NotImplementedAttribute(const vespalib::string & name, const Config & config); - void notImplemented [[noreturn]] () const; + [[noreturn]] void notImplemented() const; uint32_t getValueCount(DocId) const override; largeint_t getInt(DocId) const override; diff --git a/searchlib/src/vespa/searchlib/fef/blueprint.h b/searchlib/src/vespa/searchlib/fef/blueprint.h index bfa772d7c6d..2c501144bd9 100644 --- a/searchlib/src/vespa/searchlib/fef/blueprint.h +++ b/searchlib/src/vespa/searchlib/fef/blueprint.h @@ -75,7 +75,7 @@ protected: * class. The @ref setup method is used to tailor a blueprint * object for a specific set of parameters. **/ - Blueprint(vespalib::stringref baseName); + explicit Blueprint(vespalib::stringref baseName); using IAttributeVector = attribute::IAttributeVector; /** @@ -117,11 +117,7 @@ protected: * @return false * @param format printf-style format string **/ - bool fail(const char *format, ...) -#ifdef __GNUC__ - __attribute__ ((format (printf,2,3))) -#endif - ; + bool fail(const char *format, ...) __attribute__ ((format (printf,2,3))); /** * Used to store a reference to the attribute during prepareSharedState diff --git a/vbench/src/vbench/core/string.h b/vbench/src/vbench/core/string.h index f09f010e265..49882afc302 100644 --- a/vbench/src/vbench/core/string.h +++ b/vbench/src/vbench/core/string.h @@ -21,15 +21,9 @@ using string = vespalib::string; using string = std::string; #endif -extern string strfmt(const char *fmt, ...) -#ifdef __GNUC__ - // Add printf format checks with gcc - __attribute__ ((format (printf,1,2))) -#endif - ; +extern string strfmt(const char *fmt, ...) __attribute__ ((format (printf,1,2))); -extern size_t splitstr(const string &str, const string &sep, - std::vector<string> &dst); +extern size_t splitstr(const string &str, const string &sep, std::vector<string> &dst); } // namespace vbench diff --git a/vespalib/src/vespa/vespalib/data/output_writer.h b/vespalib/src/vespa/vespalib/data/output_writer.h index c95f13ad704..d53ac5e94d5 100644 --- a/vespalib/src/vespa/vespalib/data/output_writer.h +++ b/vespalib/src/vespa/vespalib/data/output_writer.h @@ -72,12 +72,7 @@ public: commit(memory.size); } - void printf(const char *fmt, ...) -#ifdef __GNUC__ - // Add printf format checks with gcc - __attribute__ ((format (printf,2,3))) -#endif - ; + void printf(const char *fmt, ...) __attribute__ ((format (printf,2,3))); }; } // namespace vespalib diff --git a/vespalib/src/vespa/vespalib/data/slime/strfmt.h b/vespalib/src/vespa/vespalib/data/slime/strfmt.h index 01e60eac3c0..5421281286c 100644 --- a/vespalib/src/vespa/vespalib/data/slime/strfmt.h +++ b/vespalib/src/vespa/vespalib/data/slime/strfmt.h @@ -6,11 +6,6 @@ namespace vespalib::slime { -extern std::string strfmt(const char *fmt, ...) -#ifdef __GNUC__ - __attribute__ ((format (printf,1,2))) // Add printf format checks with gcc - __attribute__((nonnull(1))) // Format string can never be null -#endif - ; +extern std::string strfmt(const char *fmt, ...) __attribute__((format (printf,1,2), nonnull(1))); } // namespace vespalib::slime diff --git a/vespalib/src/vespa/vespalib/text/utf8.h b/vespalib/src/vespa/vespalib/text/utf8.h index aa0e7c2f680..98e06ca5faf 100644 --- a/vespalib/src/vespa/vespalib/text/utf8.h +++ b/vespalib/src/vespa/vespalib/text/utf8.h @@ -152,8 +152,7 @@ public: protected: - static void throwX(const char *msg, unsigned int number) - __attribute__((__noreturn__)); + [[noreturn]] static void throwX(const char *msg, unsigned int number); enum { low_7bits_mask = 0x7F, diff --git a/vespalib/src/vespa/vespalib/util/inline.h b/vespalib/src/vespa/vespalib/util/inline.h index 9ecee12046f..cf6fe0e696a 100644 --- a/vespalib/src/vespa/vespalib/util/inline.h +++ b/vespalib/src/vespa/vespalib/util/inline.h @@ -3,23 +3,7 @@ #pragma once #ifndef noinline__ -#ifdef __GNUC__ #define noinline__ __attribute__((noinline)) #endif -#ifndef noinline__ -#define noinline__ -#endif -#endif -#ifndef always_inline__ -#ifdef __GNUC__ -/* if user specifies -O -fno-inline the compiler may get confused */ -#if !defined(__NO_INLINE__) && defined(__OPTIMIZE__) -#define always_inline__ __attribute__((always_inline)) -#endif -#endif -#ifndef always_inline__ -#define always_inline__ -#endif -#endif diff --git a/vespalib/src/vespa/vespalib/util/issue.h b/vespalib/src/vespa/vespalib/util/issue.h index a98997dddf4..9bc906b2a33 100644 --- a/vespalib/src/vespa/vespalib/util/issue.h +++ b/vespalib/src/vespa/vespalib/util/issue.h @@ -63,12 +63,7 @@ public: static Binding listen(Handler &handler); static void report(vespalib::string msg); static void report(const std::exception &e); - static void report(const char *format, ...) -#ifdef __GNUC__ - // Add printf format checks with gcc - __attribute__ ((format (printf,1,2))) -#endif - ; + static void report(const char *format, ...) __attribute__ ((format (printf,1,2))); }; } diff --git a/vespalib/src/vespa/vespalib/util/stringfmt.h b/vespalib/src/vespa/vespalib/util/stringfmt.h index ec295572499..5e30869287c 100644 --- a/vespalib/src/vespa/vespalib/util/stringfmt.h +++ b/vespalib/src/vespa/vespalib/util/stringfmt.h @@ -9,20 +9,10 @@ namespace vespalib { extern vespalib::string make_string_va(const char *fmt, va_list ap); -extern vespalib::string make_string(const char *fmt, ...) -#ifdef __GNUC__ - // Add printf format checks with gcc - __attribute__ ((format (printf,1,2))) -#endif - ; +extern vespalib::string make_string(const char *fmt, ...) __attribute__ ((format (printf,1,2))); namespace make_string_short { -extern vespalib::string fmt(const char *format, ...) -#ifdef __GNUC__ - // Add printf format checks with gcc - __attribute__ ((format (printf,1,2))) -#endif - ; +extern vespalib::string fmt(const char *format, ...) __attribute__ ((format (printf,1,2))); } // namespace vespalib::make_string_short } // namespace vespalib diff --git a/vespalib/src/vespa/vespalib/util/unwind_message.cpp b/vespalib/src/vespa/vespalib/util/unwind_message.cpp index 3789ae0d9e9..6a203eaf533 100644 --- a/vespalib/src/vespa/vespalib/util/unwind_message.cpp +++ b/vespalib/src/vespa/vespalib/util/unwind_message.cpp @@ -11,7 +11,7 @@ UnwindMessage::UnwindMessage(const vespalib::string &msg) { } -UnwindMessage::UnwindMessage(UnwindMessage &&rhs) +UnwindMessage::UnwindMessage(UnwindMessage &&rhs) noexcept : _num_active(std::uncaught_exceptions()), _message(rhs._message) { diff --git a/vespalib/src/vespa/vespalib/util/unwind_message.h b/vespalib/src/vespa/vespalib/util/unwind_message.h index 752719c4f74..10d8680e14f 100644 --- a/vespalib/src/vespa/vespalib/util/unwind_message.h +++ b/vespalib/src/vespa/vespalib/util/unwind_message.h @@ -17,19 +17,14 @@ private: vespalib::string _message; public: UnwindMessage(const vespalib::string &msg); - UnwindMessage(UnwindMessage &&rhs); + UnwindMessage(UnwindMessage &&rhs) noexcept ; UnwindMessage(const UnwindMessage &) = delete; UnwindMessage &operator=(const UnwindMessage &) = delete; UnwindMessage &operator=(UnwindMessage &&) = delete; ~UnwindMessage(); }; -extern UnwindMessage unwind_msg(const char *fmt, ...) -#ifdef __GNUC__ - // Add printf format checks with gcc - __attribute__ ((format (printf,1,2))) -#endif - ; +extern UnwindMessage unwind_msg(const char *fmt, ...) __attribute__ ((format (printf,1,2))); // make an unwind message with a hopefully unique name on the stack #define UNWIND_MSG(...) auto VESPA_CAT(unwindMessageOnLine, __LINE__) = unwind_msg(__VA_ARGS__) diff --git a/vespalog/src/vespa/log/internal.h b/vespalog/src/vespa/log/internal.h index 4411d9fa6e6..c25c7cc44b6 100644 --- a/vespalog/src/vespa/log/internal.h +++ b/vespalog/src/vespa/log/internal.h @@ -4,14 +4,9 @@ #include <string> #include <cstdlib> -#if !__GNUC__ && !defined(__attribute__) -#define __attribute__(x) -#endif - namespace ns_log { -void throwInvalid(const char *fmt, ...) - __attribute__((format(printf, 1, 2))) __attribute__((noreturn)); +[[noreturn]] void throwInvalid(const char *fmt, ...) __attribute__((format(printf, 1, 2))); class InvalidLogException { private: @@ -20,10 +15,9 @@ private: public: InvalidLogException& operator = (const InvalidLogException&) = delete; InvalidLogException(const InvalidLogException &x) = default; - InvalidLogException(const char *s) : _what(s) {} + explicit InvalidLogException(const char *s) : _what(s) {} ~InvalidLogException() = default; - const char *what() const { return _what.c_str(); } + [[nodiscard]] const char *what() const { return _what.c_str(); } }; } // end namespace ns_log - diff --git a/vespalog/src/vespa/log/log.h b/vespalog/src/vespa/log/log.h index 22b6a720bd2..888e24a0f28 100644 --- a/vespalog/src/vespa/log/log.h +++ b/vespalog/src/vespa/log/log.h @@ -252,17 +252,9 @@ inline bool Logger::wants(LogLevel level) return _logLevels[level] == CHARS_TO_UINT(' ', ' ', 'O', 'N'); } -#define LOG_noreturn __attribute__((__noreturn__)) +[[noreturn]] extern void log_assert_fail(const char *assertion, const char *file, uint32_t line); -extern void log_assert_fail(const char *assertion, - const char *file, - uint32_t line) LOG_noreturn; - -extern void log_abort(const char *message, - const char *file, - uint32_t line) LOG_noreturn; - -#undef LOG_noreturn +[[noreturn]] extern void log_abort(const char *message, const char *file, uint32_t line); } // end namespace log |