Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions clang/include/clang/CIR/Dialect/IR/CIROpsEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,18 @@ static bool isLocalLinkage(GlobalLinkageKind linkage) {
static bool isExternalWeakLinkage(GlobalLinkageKind linkage) {
return linkage == GlobalLinkageKind::ExternalWeakLinkage;
}
LLVM_ATTRIBUTE_UNUSED static bool isCommonLinkage(GlobalLinkageKind linkage) {
[[maybe_unused]] static bool isCommonLinkage(GlobalLinkageKind linkage) {
return linkage == GlobalLinkageKind::CommonLinkage;
}
LLVM_ATTRIBUTE_UNUSED static bool
[[maybe_unused]] static bool
isValidDeclarationLinkage(GlobalLinkageKind linkage) {
return isExternalWeakLinkage(linkage) || isExternalLinkage(linkage);
}

/// Whether the definition of this global may be replaced by something
/// non-equivalent at link time. For example, if a function has weak linkage
/// then the code defining it may be replaced by different code.
LLVM_ATTRIBUTE_UNUSED static bool
isInterposableLinkage(GlobalLinkageKind linkage) {
[[maybe_unused]] static bool isInterposableLinkage(GlobalLinkageKind linkage) {
switch (linkage) {
case GlobalLinkageKind::WeakAnyLinkage:
case GlobalLinkageKind::LinkOnceAnyLinkage:
Expand All @@ -89,8 +88,7 @@ isInterposableLinkage(GlobalLinkageKind linkage) {

/// Whether the definition of this global may be discarded if it is not used
/// in its compilation unit.
LLVM_ATTRIBUTE_UNUSED static bool
isDiscardableIfUnused(GlobalLinkageKind linkage) {
[[maybe_unused]] static bool isDiscardableIfUnused(GlobalLinkageKind linkage) {
return isLinkOnceLinkage(linkage) || isLocalLinkage(linkage) ||
isAvailableExternallyLinkage(linkage);
}
Expand All @@ -99,7 +97,7 @@ isDiscardableIfUnused(GlobalLinkageKind linkage) {
/// Using this method outside of the code generators is almost always a
/// mistake: when working at the IR level use isInterposable instead as it
/// knows about ODR semantics.
LLVM_ATTRIBUTE_UNUSED static bool isWeakForLinker(GlobalLinkageKind linkage) {
[[maybe_unused]] static bool isWeakForLinker(GlobalLinkageKind linkage) {
return linkage == GlobalLinkageKind::WeakAnyLinkage ||
linkage == GlobalLinkageKind::WeakODRLinkage ||
linkage == GlobalLinkageKind::LinkOnceAnyLinkage ||
Expand All @@ -108,7 +106,7 @@ LLVM_ATTRIBUTE_UNUSED static bool isWeakForLinker(GlobalLinkageKind linkage) {
linkage == GlobalLinkageKind::ExternalWeakLinkage;
}

LLVM_ATTRIBUTE_UNUSED static bool isValidLinkage(GlobalLinkageKind gl) {
[[maybe_unused]] static bool isValidLinkage(GlobalLinkageKind gl) {
return isExternalLinkage(gl) || isLocalLinkage(gl) || isWeakLinkage(gl) ||
isLinkOnceLinkage(gl);
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ByteCode/InterpBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
namespace clang {
namespace interp {

LLVM_ATTRIBUTE_UNUSED static bool isNoopBuiltin(unsigned ID) {
[[maybe_unused]] static bool isNoopBuiltin(unsigned ID) {
switch (ID) {
case Builtin::BIas_const:
case Builtin::BIforward:
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/AST/Comment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ good implements_child_begin_end(Comment::child_iterator (T::*)() const) {
return good();
}

LLVM_ATTRIBUTE_UNUSED
static inline bad implements_child_begin_end(
Comment::child_iterator (Comment::*)() const) {
[[maybe_unused]]
static inline bad
implements_child_begin_end(Comment::child_iterator (Comment::*)() const) {
return bad();
}

#define ASSERT_IMPLEMENTS_child_begin(function) \
(void) good(implements_child_begin_end(function))

LLVM_ATTRIBUTE_UNUSED
[[maybe_unused]]
static inline void CheckCommentASTNodes() {
#define ABSTRACT_COMMENT(COMMENT)
#define COMMENT(CLASS, PARENT) \
Expand Down
16 changes: 10 additions & 6 deletions clang/lib/AST/Stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ namespace {
template <class T> good implements_children(children_t T::*) {
return good();
}
LLVM_ATTRIBUTE_UNUSED
[[maybe_unused]]
static bad implements_children(children_t Stmt::*) {
return bad();
}
Expand All @@ -261,15 +261,19 @@ namespace {
template <class T> good implements_getBeginLoc(getBeginLoc_t T::*) {
return good();
}
LLVM_ATTRIBUTE_UNUSED
static bad implements_getBeginLoc(getBeginLoc_t Stmt::*) { return bad(); }
[[maybe_unused]]
static bad implements_getBeginLoc(getBeginLoc_t Stmt::*) {
return bad();
}

typedef SourceLocation getLocEnd_t() const;
template <class T> good implements_getEndLoc(getLocEnd_t T::*) {
return good();
}
LLVM_ATTRIBUTE_UNUSED
static bad implements_getEndLoc(getLocEnd_t Stmt::*) { return bad(); }
[[maybe_unused]]
static bad implements_getEndLoc(getLocEnd_t Stmt::*) {
return bad();
}

#define ASSERT_IMPLEMENTS_children(type) \
(void) is_good(implements_children(&type::children))
Expand All @@ -282,7 +286,7 @@ namespace {

/// Check whether the various Stmt classes implement their member
/// functions.
LLVM_ATTRIBUTE_UNUSED
[[maybe_unused]]
static inline void check_implementations() {
#define ABSTRACT_STMT(type)
#define STMT(type, base) \
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/StmtPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ namespace {
else StmtVisitor<StmtPrinter>::Visit(S);
}

void VisitStmt(Stmt *Node) LLVM_ATTRIBUTE_UNUSED {
[[maybe_unused]] void VisitStmt(Stmt *Node) {
Indent() << "<<unknown stmt type>>" << NL;
}

void VisitExpr(Expr *Node) LLVM_ATTRIBUTE_UNUSED {
[[maybe_unused]] void VisitExpr(Expr *Node) {
OS << "<<unknown expr type>>";
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ bool ConstRecordBuilder::updateRecord(ConstantEmitter &emitter,
class ConstExprEmitter
: public StmtVisitor<ConstExprEmitter, mlir::Attribute, QualType> {
CIRGenModule &cgm;
LLVM_ATTRIBUTE_UNUSED ConstantEmitter &emitter;
[[maybe_unused]] ConstantEmitter &emitter;

public:
ConstExprEmitter(ConstantEmitter &emitter)
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/CIR/CodeGen/CIRGenValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class AggValueSlot {
/// destructor for the slot. Otherwise the code which constructs it should
/// push the appropriate cleanup.
LLVM_PREFERRED_TYPE(bool)
LLVM_ATTRIBUTE_UNUSED unsigned destructedFlag : 1;
[[maybe_unused]] unsigned destructedFlag : 1;

/// This is set to true if the memory in the slot is known to be zero before
/// the assignment into it. This means that zero fields don't need to be set.
Expand All @@ -327,15 +327,15 @@ class AggValueSlot {
/// object, it's important that this flag never be set when
/// evaluating an expression which constructs such an object.
LLVM_PREFERRED_TYPE(bool)
LLVM_ATTRIBUTE_UNUSED unsigned aliasedFlag : 1;
[[maybe_unused]] unsigned aliasedFlag : 1;

/// This is set to true if the tail padding of this slot might overlap
/// another object that may have already been initialized (and whose
/// value must be preserved by this initialization). If so, we may only
/// store up to the dsize of the type. Otherwise we can widen stores to
/// the size of the type.
LLVM_PREFERRED_TYPE(bool)
LLVM_ATTRIBUTE_UNUSED unsigned overlapFlag : 1;
[[maybe_unused]] unsigned overlapFlag : 1;

public:
enum IsDestructed_t { IsNotDestructed, IsDestructed };
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/CodeGen/CodeGenTBAA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,7 @@ llvm::MDNode *CodeGenTBAA::getValidBaseTypeInfo(QualType QTy) {
// First calculate the metadata, before recomputing the insertion point, as
// the helper can recursively call us.
llvm::MDNode *TypeNode = getBaseTypeInfoHelper(Ty);
LLVM_ATTRIBUTE_UNUSED auto inserted =
BaseTypeMetadataCache.insert({Ty, TypeNode});
[[maybe_unused]] auto inserted = BaseTypeMetadataCache.insert({Ty, TypeNode});
assert(inserted.second && "BaseType metadata was already inserted");

return TypeNode;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Format/UnwrappedLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void printLine(llvm::raw_ostream &OS, const UnwrappedLine &Line,
OS << "\n";
}

LLVM_ATTRIBUTE_UNUSED static void printDebugInfo(const UnwrappedLine &Line) {
[[maybe_unused]] static void printDebugInfo(const UnwrappedLine &Line) {
printLine(llvm::dbgs(), Line);
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const PointerToMemberData *BasicValueFactory::getPointerToMemberData(
return D;
}

LLVM_ATTRIBUTE_UNUSED static bool hasNoRepeatedElements(
[[maybe_unused]] static bool hasNoRepeatedElements(
llvm::ImmutableList<const CXXBaseSpecifier *> BaseSpecList) {
llvm::SmallPtrSet<QualType, 16> BaseSpecSeen;
for (const CXXBaseSpecifier *BaseSpec : BaseSpecList) {
Expand Down
7 changes: 3 additions & 4 deletions clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ class EquivalenceClass : public llvm::FoldingSetNode {
}

/// Check equivalence data for consistency.
[[nodiscard]] LLVM_ATTRIBUTE_UNUSED static bool
[[nodiscard]] [[maybe_unused]] static bool
isClassDataConsistent(ProgramStateRef State);

[[nodiscard]] QualType getType() const {
Expand Down Expand Up @@ -1041,8 +1041,7 @@ class EquivalenceClass : public llvm::FoldingSetNode {
// Constraint functions
//===----------------------------------------------------------------------===//

[[nodiscard]] LLVM_ATTRIBUTE_UNUSED bool
areFeasible(ConstraintRangeTy Constraints) {
[[nodiscard]] [[maybe_unused]] bool areFeasible(ConstraintRangeTy Constraints) {
return llvm::none_of(
Constraints,
[](const std::pair<EquivalenceClass, RangeSet> &ClassConstraint) {
Expand Down Expand Up @@ -1134,7 +1133,7 @@ template <class EndTy>
return End;
}

[[nodiscard]] LLVM_ATTRIBUTE_UNUSED inline std::optional<RangeSet>
[[nodiscard]] [[maybe_unused]] inline std::optional<RangeSet>
intersect(RangeSet::Factory &F, const RangeSet *End) {
// This is an extraneous conversion from a raw pointer into
// std::optional<RangeSet>
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Tooling/CompilationDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ namespace tooling {
// This anchor is used to force the linker to link in the generated object file
// and thus register the JSONCompilationDatabasePlugin.
extern volatile int JSONAnchorSource;
static int LLVM_ATTRIBUTE_UNUSED JSONAnchorDest = JSONAnchorSource;
[[maybe_unused]] static int JSONAnchorDest = JSONAnchorSource;

} // namespace tooling
} // namespace clang
4 changes: 2 additions & 2 deletions clang/lib/Tooling/Execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ createExecutorFromCommandLineArgs(int &argc, const char **argv,
// and thus register the StandaloneToolExecutorPlugin etc.
extern volatile int StandaloneToolExecutorAnchorSource;
extern volatile int AllTUsToolExecutorAnchorSource;
static int LLVM_ATTRIBUTE_UNUSED StandaloneToolExecutorAnchorDest =
[[maybe_unused]] static int StandaloneToolExecutorAnchorDest =
StandaloneToolExecutorAnchorSource;
static int LLVM_ATTRIBUTE_UNUSED AllTUsToolExecutorAnchorDest =
[[maybe_unused]] static int AllTUsToolExecutorAnchorDest =
AllTUsToolExecutorAnchorSource;

} // end namespace tooling
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/Tooling/Syntax/BuildTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ static Expr *IgnoreImplicit(Expr *E) {
IgnoreCXXFunctionalCastExprWrappingConstructor);
}

LLVM_ATTRIBUTE_UNUSED
static bool isImplicitExpr(Expr *E) { return IgnoreImplicit(E) != E; }
[[maybe_unused]]
static bool isImplicitExpr(Expr *E) {
return IgnoreImplicit(E) != E;
}

namespace {
/// Get start location of the Declarator from the TypeLoc.
Expand Down
14 changes: 7 additions & 7 deletions clang/unittests/StaticAnalyzer/RangeSetTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ template <class RangeOrSet> static std::string toString(const RangeOrSet &Obj) {
Obj.dump(SS);
return ObjRepresentation;
}
LLVM_ATTRIBUTE_UNUSED static std::string toString(const llvm::APSInt &Point) {
[[maybe_unused]] static std::string toString(const llvm::APSInt &Point) {
return toString(Point, 10);
}
// We need it here for better fail diagnostics from gtest.
LLVM_ATTRIBUTE_UNUSED static std::ostream &operator<<(std::ostream &OS,
const RangeSet &Set) {
[[maybe_unused]] static std::ostream &operator<<(std::ostream &OS,
const RangeSet &Set) {
return OS << toString(Set);
}
// We need it here for better fail diagnostics from gtest.
LLVM_ATTRIBUTE_UNUSED static std::ostream &operator<<(std::ostream &OS,
const Range &R) {
[[maybe_unused]] static std::ostream &operator<<(std::ostream &OS,
const Range &R) {
return OS << toString(R);
}
LLVM_ATTRIBUTE_UNUSED static std::ostream &operator<<(std::ostream &OS,
APSIntType Ty) {
[[maybe_unused]] static std::ostream &operator<<(std::ostream &OS,
APSIntType Ty) {
return OS << (Ty.isUnsigned() ? "u" : "s") << Ty.getBitWidth();
}

Expand Down
7 changes: 3 additions & 4 deletions clang/unittests/StaticAnalyzer/SValTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ namespace clang {
// getType() tests include whole bunch of type comparisons,
// so when something is wrong, it's good to have gtest telling us
// what are those types.
LLVM_ATTRIBUTE_UNUSED std::ostream &operator<<(std::ostream &OS,
const QualType &T) {
[[maybe_unused]] std::ostream &operator<<(std::ostream &OS, const QualType &T) {
return OS << T.getAsString();
}

LLVM_ATTRIBUTE_UNUSED std::ostream &operator<<(std::ostream &OS,
const CanQualType &T) {
[[maybe_unused]] std::ostream &operator<<(std::ostream &OS,
const CanQualType &T) {
return OS << QualType{T};
}

Expand Down