more [[gnu::...]] attributes

This commit is contained in:
Max Kellermann
2021-10-13 11:28:04 +02:00
parent 1c4b484a56
commit f510564d9d
135 changed files with 361 additions and 514 deletions

View File

@@ -20,8 +20,6 @@
#ifndef MPD_CONFIG_BLOCK_HXX
#define MPD_CONFIG_BLOCK_HXX
#include "util/Compiler.h"
#include <string>
#include <vector>
@@ -39,7 +37,7 @@ struct BlockParam {
mutable bool used = false;
template<typename N, typename V>
gcc_nonnull_all
[[gnu::nonnull]]
BlockParam(N &&_name, V &&_value, int _line=-1) noexcept
:name(std::forward<N>(_name)), value(std::forward<V>(_value)),
line(_line) {}
@@ -99,7 +97,7 @@ struct ConfigBlock {
return line < 0;
}
gcc_pure
[[gnu::pure]]
bool IsEmpty() const noexcept {
return block_params.empty();
}
@@ -109,17 +107,17 @@ struct ConfigBlock {
}
template<typename N, typename V>
gcc_nonnull_all
[[gnu::nonnull]]
void AddBlockParam(N &&_name, V &&_value, int _line=-1) noexcept {
block_params.emplace_back(std::forward<N>(_name),
std::forward<V>(_value),
_line);
}
gcc_nonnull_all gcc_pure
[[gnu::nonnull]] [[gnu::pure]]
const BlockParam *GetBlockParam(const char *_name) const noexcept;
gcc_pure
[[gnu::pure]]
const char *GetBlockValue(const char *name,
const char *default_value=nullptr) const noexcept;

View File

@@ -46,7 +46,7 @@ struct ConfigData {
void AddParam(ConfigOption option, ConfigParam &&param) noexcept;
gcc_pure
[[gnu::pure]]
const ConfigParam *GetParam(ConfigOption option) const noexcept {
const auto &list = GetParamList(option);
return list.empty() ? nullptr : &list.front();
@@ -60,7 +60,7 @@ struct ConfigData {
: f(nullptr);
}
gcc_pure
[[gnu::pure]]
const char *GetString(ConfigOption option,
const char *default_value=nullptr) const noexcept;
@@ -100,7 +100,7 @@ struct ConfigData {
ConfigBlock &AddBlock(ConfigBlockOption option,
ConfigBlock &&block) noexcept;
gcc_pure
[[gnu::pure]]
const ConfigBlock *GetBlock(ConfigBlockOption option) const noexcept {
const auto &list = GetBlockList(option);
return list.empty() ? nullptr : &list.front();
@@ -115,7 +115,7 @@ struct ConfigData {
* @param key the attribute name
* @param value the expected attribute value
*/
gcc_pure
[[gnu::pure]]
const ConfigBlock *FindBlock(ConfigBlockOption option,
const char *key, const char *value) const;

View File

@@ -102,14 +102,14 @@ enum class ConfigBlockOption {
/**
* @return #ConfigOption::MAX if not found
*/
gcc_pure
[[gnu::pure]]
enum ConfigOption
ParseConfigOptionName(const char *name) noexcept;
/**
* @return #ConfigOption::MAX if not found
*/
gcc_pure
[[gnu::pure]]
enum ConfigBlockOption
ParseConfigBlockOptionName(const char *name) noexcept;

View File

@@ -35,7 +35,7 @@ struct ConfigParam {
:line(_line) {}
template<typename V>
gcc_nonnull_all
[[gnu::nonnull]]
explicit ConfigParam(V &&_value, int _line=-1) noexcept
:value(std::forward<V>(_value)), line(_line) {}