[clang][clang-tools-extra] LLVM_NODISCARD => [[nodiscard]]. NFC

This commit is contained in:
Fangrui Song 2022-08-09 07:11:18 +00:00
parent d3580c2eb6
commit 32197830ef
25 changed files with 226 additions and 243 deletions

View File

@ -63,8 +63,8 @@ struct ClangTidyOptions {
/// Creates a new \c ClangTidyOptions instance combined from all fields
/// of this instance overridden by the fields of \p Other that have a value.
/// \p Order specifies precedence of \p Other option.
LLVM_NODISCARD ClangTidyOptions merge(const ClangTidyOptions &Other,
unsigned Order) const;
[[nodiscard]] ClangTidyOptions merge(const ClangTidyOptions &Other,
unsigned Order) const;
/// Checks filter.
llvm::Optional<std::string> Checks;

View File

@ -1000,7 +1000,7 @@ llvm::StringMap<TUScheduler::FileStats> ClangdServer::fileStats() const {
return WorkScheduler->fileStats();
}
LLVM_NODISCARD bool
[[nodiscard]] bool
ClangdServer::blockUntilIdleForTest(llvm::Optional<double> TimeoutSeconds) {
// Order is important here: we don't want to block on A and then B,
// if B might schedule work on A.

View File

@ -390,7 +390,7 @@ public:
// Returns false if the timeout expires.
// FIXME: various subcomponents each get the full timeout, so it's more of
// an order of magnitude than a hard deadline.
LLVM_NODISCARD bool
[[nodiscard]] bool
blockUntilIdleForTest(llvm::Optional<double> TimeoutSeconds = 10);
/// Builds a nested representation of memory used by components.

View File

@ -110,7 +110,7 @@ public:
// Disables thread priority lowering to ensure progress on loaded systems.
// Only affects tasks that run after the call.
static void preventThreadStarvationInTests();
LLVM_NODISCARD bool
[[nodiscard]] bool
blockUntilIdleForTest(llvm::Optional<double> TimeoutSeconds);
private:
@ -172,7 +172,7 @@ public:
}
// Wait until the queue is empty, to allow deterministic testing.
LLVM_NODISCARD bool
[[nodiscard]] bool
blockUntilIdleForTest(llvm::Optional<double> TimeoutSeconds = 10) {
return Queue.blockUntilIdleForTest(TimeoutSeconds);
}

View File

@ -116,7 +116,7 @@ public:
// Read a varint (as consumeVar) and resize the container accordingly.
// If the size is invalid, return false and mark an error.
// (The caller should abort in this case).
template <typename T> LLVM_NODISCARD bool consumeSize(T &Container) {
template <typename T> [[nodiscard]] bool consumeSize(T &Container) {
auto Size = consumeVar();
// Conservatively assume each element is at least one byte.
if (Size > (size_t)(End - Begin)) {

View File

@ -184,7 +184,7 @@ private:
/// WithContext replaces Context::current() with a provided scope.
/// When the WithContext is destroyed, the original scope is restored.
/// For extending the current context with new value, prefer WithContextValue.
class LLVM_NODISCARD WithContext {
class [[nodiscard]] WithContext {
public:
WithContext(Context C) : Restore(Context::swapCurrent(std::move(C))) {}
~WithContext() { Context::swapCurrent(std::move(Restore)); }
@ -199,7 +199,7 @@ private:
/// WithContextValue extends Context::current() with a single value.
/// When the WithContextValue is destroyed, the original scope is restored.
class LLVM_NODISCARD WithContextValue {
class [[nodiscard]] WithContextValue {
public:
template <typename T>
WithContextValue(const Key<T> &K, typename std::decay<T>::type V)

View File

@ -35,7 +35,7 @@ public:
// A subscription defines the scope of when a listener should receive events.
// After destroying the subscription, no more events are received.
class LLVM_NODISCARD Subscription {
class [[nodiscard]] Subscription {
Event *Parent;
unsigned ListenerID;

View File

@ -76,8 +76,8 @@ void wait(std::unique_lock<std::mutex> &Lock, std::condition_variable &CV,
Deadline D);
/// Waits on a condition variable until F() is true or D expires.
template <typename Func>
LLVM_NODISCARD bool wait(std::unique_lock<std::mutex> &Lock,
std::condition_variable &CV, Deadline D, Func F) {
[[nodiscard]] bool wait(std::unique_lock<std::mutex> &Lock,
std::condition_variable &CV, Deadline D, Func F) {
while (!F()) {
if (D.expired())
return false;
@ -93,7 +93,7 @@ public:
void notify();
// Blocks until flag is set.
void wait() const { (void)wait(Deadline::infinity()); }
LLVM_NODISCARD bool wait(Deadline D) const;
[[nodiscard]] bool wait(Deadline D) const;
private:
bool Notified = false;
@ -110,7 +110,7 @@ public:
~AsyncTaskRunner();
void wait() const { (void)wait(Deadline::infinity()); }
LLVM_NODISCARD bool wait(Deadline D) const;
[[nodiscard]] bool wait(Deadline D) const;
// The name is used for tracing and debugging (e.g. to name a spawned thread).
void runAsync(const llvm::Twine &Name, llvm::unique_function<void()> Action);

View File

@ -3202,11 +3202,11 @@ OPT_LIST(V)
#undef OPT_LIST
LLVM_NODISCARD ObjCEncOptions keepingOnly(ObjCEncOptions Mask) const {
[[nodiscard]] ObjCEncOptions keepingOnly(ObjCEncOptions Mask) const {
return Bits & Mask.Bits;
}
LLVM_NODISCARD ObjCEncOptions forComponentType() const {
[[nodiscard]] ObjCEncOptions forComponentType() const {
ObjCEncOptions Mask = ObjCEncOptions()
.setIsOutermostType()
.setIsStructField();

View File

@ -304,7 +304,7 @@ class TypeSourceInfo;
/// \param From Object to import.
/// \return Error information (success or error).
template <typename ImportT>
LLVM_NODISCARD llvm::Error importInto(ImportT &To, const ImportT &From) {
[[nodiscard]] llvm::Error importInto(ImportT &To, const ImportT &From) {
auto ToOrErr = Import(From);
if (ToOrErr)
To = *ToOrErr;
@ -482,7 +482,7 @@ class TypeSourceInfo;
/// Import the definition of the given declaration, including all of
/// the declarations it contains.
LLVM_NODISCARD llvm::Error ImportDefinition(Decl *From);
[[nodiscard]] llvm::Error ImportDefinition(Decl *From);
/// Cope with a name conflict when importing a declaration into the
/// given context.

View File

@ -164,7 +164,7 @@ private:
/// \param Component The component to push onto the path components stack.
/// \return A PathComponentGuard responsible for removing the latest
/// component from the stack on scope exit.
LLVM_NODISCARD PathComponentGuard makePathComponentGuard(StringRef Component);
[[nodiscard]] PathComponentGuard makePathComponentGuard(StringRef Component);
public:
SymbolGraphSerializer(const APISet &API, StringRef ProductName,

View File

@ -27,39 +27,39 @@ using TaintTagType = unsigned;
static constexpr TaintTagType TaintTagGeneric = 0;
/// Create a new state in which the value of the statement is marked as tainted.
LLVM_NODISCARD ProgramStateRef addTaint(ProgramStateRef State, const Stmt *S,
const LocationContext *LCtx,
TaintTagType Kind = TaintTagGeneric);
[[nodiscard]] ProgramStateRef addTaint(ProgramStateRef State, const Stmt *S,
const LocationContext *LCtx,
TaintTagType Kind = TaintTagGeneric);
/// Create a new state in which the value is marked as tainted.
LLVM_NODISCARD ProgramStateRef addTaint(ProgramStateRef State, SVal V,
TaintTagType Kind = TaintTagGeneric);
[[nodiscard]] ProgramStateRef addTaint(ProgramStateRef State, SVal V,
TaintTagType Kind = TaintTagGeneric);
/// Create a new state in which the symbol is marked as tainted.
LLVM_NODISCARD ProgramStateRef addTaint(ProgramStateRef State, SymbolRef Sym,
TaintTagType Kind = TaintTagGeneric);
[[nodiscard]] ProgramStateRef addTaint(ProgramStateRef State, SymbolRef Sym,
TaintTagType Kind = TaintTagGeneric);
/// Create a new state in which the pointer represented by the region
/// is marked as tainted.
LLVM_NODISCARD ProgramStateRef addTaint(ProgramStateRef State,
const MemRegion *R,
TaintTagType Kind = TaintTagGeneric);
[[nodiscard]] ProgramStateRef addTaint(ProgramStateRef State,
const MemRegion *R,
TaintTagType Kind = TaintTagGeneric);
LLVM_NODISCARD ProgramStateRef removeTaint(ProgramStateRef State, SVal V);
[[nodiscard]] ProgramStateRef removeTaint(ProgramStateRef State, SVal V);
LLVM_NODISCARD ProgramStateRef removeTaint(ProgramStateRef State,
const MemRegion *R);
[[nodiscard]] ProgramStateRef removeTaint(ProgramStateRef State,
const MemRegion *R);
LLVM_NODISCARD ProgramStateRef removeTaint(ProgramStateRef State,
SymbolRef Sym);
[[nodiscard]] ProgramStateRef removeTaint(ProgramStateRef State, SymbolRef Sym);
/// Create a new state in a which a sub-region of a given symbol is tainted.
/// This might be necessary when referring to regions that can not have an
/// individual symbol, e.g. if they are represented by the default binding of
/// a LazyCompoundVal.
LLVM_NODISCARD ProgramStateRef addPartialTaint(
ProgramStateRef State, SymbolRef ParentSym, const SubRegion *SubRegion,
TaintTagType Kind = TaintTagGeneric);
[[nodiscard]] ProgramStateRef
addPartialTaint(ProgramStateRef State, SymbolRef ParentSym,
const SubRegion *SubRegion,
TaintTagType Kind = TaintTagGeneric);
/// Check if the statement has a tainted value in the given state.
bool isTainted(ProgramStateRef State, const Stmt *S,

View File

@ -190,7 +190,7 @@ public:
CallDescriptionMap(CallDescriptionMap &&) = default;
CallDescriptionMap &operator=(CallDescriptionMap &&) = default;
LLVM_NODISCARD const T *lookup(const CallEvent &Call) const {
[[nodiscard]] const T *lookup(const CallEvent &Call) const {
// Slow path: linear lookup.
// TODO: Implement some sort of fast path.
for (const std::pair<CallDescription, T> &I : LinearMap)
@ -212,7 +212,7 @@ public:
/// information, such as the precise argument count (see comments for
/// CallEvent::getNumArgs), the called function if it was called through a
/// function pointer, and other information not available syntactically.
LLVM_NODISCARD const T *lookupAsWritten(const CallExpr &Call) const {
[[nodiscard]] const T *lookupAsWritten(const CallExpr &Call) const {
// Slow path: linear lookup.
// TODO: Implement some sort of fast path.
for (const std::pair<CallDescription, T> &I : LinearMap)
@ -235,7 +235,7 @@ public:
CallDescriptionSet(const CallDescriptionSet &) = delete;
CallDescriptionSet &operator=(const CallDescription &) = delete;
LLVM_NODISCARD bool contains(const CallEvent &Call) const;
[[nodiscard]] bool contains(const CallEvent &Call) const;
/// When available, always prefer lookup with a CallEvent! This function
/// exists only when that is not available, for example, when _only_
@ -249,7 +249,7 @@ public:
/// information, such as the precise argument count (see comments for
/// CallEvent::getNumArgs), the called function if it was called through a
/// function pointer, and other information not available syntactically.
LLVM_NODISCARD bool containsAsWritten(const CallExpr &CE) const;
[[nodiscard]] bool containsAsWritten(const CallExpr &CE) const;
};
} // namespace ento

View File

@ -899,18 +899,19 @@ public:
/// Note whether this loop has any more iteratios to model. These methods are
/// essentially an interface for a GDM trait. Further reading in
/// ExprEngine::VisitObjCForCollectionStmt().
LLVM_NODISCARD static ProgramStateRef
[[nodiscard]] static ProgramStateRef
setWhetherHasMoreIteration(ProgramStateRef State,
const ObjCForCollectionStmt *O,
const LocationContext *LC, bool HasMoreIteraton);
LLVM_NODISCARD static ProgramStateRef
[[nodiscard]] static ProgramStateRef
removeIterationState(ProgramStateRef State, const ObjCForCollectionStmt *O,
const LocationContext *LC);
LLVM_NODISCARD static bool hasMoreIteration(ProgramStateRef State,
const ObjCForCollectionStmt *O,
const LocationContext *LC);
[[nodiscard]] static bool hasMoreIteration(ProgramStateRef State,
const ObjCForCollectionStmt *O,
const LocationContext *LC);
private:
/// Assuming we construct an array of non-POD types, this method allows us
/// to store which element is to be constructed next.

View File

@ -216,22 +216,22 @@ public:
///
/// This returns a new state with the added constraint on \p cond.
/// If no new state is feasible, NULL is returned.
LLVM_NODISCARD ProgramStateRef assume(DefinedOrUnknownSVal cond,
bool assumption) const;
[[nodiscard]] ProgramStateRef assume(DefinedOrUnknownSVal cond,
bool assumption) const;
/// Assumes both "true" and "false" for \p cond, and returns both
/// corresponding states (respectively).
///
/// This is more efficient than calling assume() twice. Note that one (but not
/// both) of the returned states may be NULL.
LLVM_NODISCARD std::pair<ProgramStateRef, ProgramStateRef>
[[nodiscard]] std::pair<ProgramStateRef, ProgramStateRef>
assume(DefinedOrUnknownSVal cond) const;
LLVM_NODISCARD std::pair<ProgramStateRef, ProgramStateRef>
[[nodiscard]] std::pair<ProgramStateRef, ProgramStateRef>
assumeInBoundDual(DefinedOrUnknownSVal idx, DefinedOrUnknownSVal upperBound,
QualType IndexType = QualType()) const;
LLVM_NODISCARD ProgramStateRef
[[nodiscard]] ProgramStateRef
assumeInBound(DefinedOrUnknownSVal idx, DefinedOrUnknownSVal upperBound,
bool assumption, QualType IndexType = QualType()) const;
@ -241,17 +241,17 @@ public:
///
/// This returns a new state with the added constraint on \p cond.
/// If no new state is feasible, NULL is returned.
LLVM_NODISCARD ProgramStateRef assumeInclusiveRange(DefinedOrUnknownSVal Val,
const llvm::APSInt &From,
const llvm::APSInt &To,
bool assumption) const;
[[nodiscard]] ProgramStateRef assumeInclusiveRange(DefinedOrUnknownSVal Val,
const llvm::APSInt &From,
const llvm::APSInt &To,
bool assumption) const;
/// Assumes given range both "true" and "false" for \p Val, and returns both
/// corresponding states (respectively).
///
/// This is more efficient than calling assume() twice. Note that one (but not
/// both) of the returned states may be NULL.
LLVM_NODISCARD std::pair<ProgramStateRef, ProgramStateRef>
[[nodiscard]] std::pair<ProgramStateRef, ProgramStateRef>
assumeInclusiveRange(DefinedOrUnknownSVal Val, const llvm::APSInt &From,
const llvm::APSInt &To) const;
@ -276,16 +276,16 @@ public:
/// Create a new state by binding the value 'V' to the statement 'S' in the
/// state's environment.
LLVM_NODISCARD ProgramStateRef BindExpr(const Stmt *S,
const LocationContext *LCtx, SVal V,
bool Invalidate = true) const;
[[nodiscard]] ProgramStateRef BindExpr(const Stmt *S,
const LocationContext *LCtx, SVal V,
bool Invalidate = true) const;
LLVM_NODISCARD ProgramStateRef bindLoc(Loc location, SVal V,
const LocationContext *LCtx,
bool notifyChanges = true) const;
[[nodiscard]] ProgramStateRef bindLoc(Loc location, SVal V,
const LocationContext *LCtx,
bool notifyChanges = true) const;
LLVM_NODISCARD ProgramStateRef bindLoc(SVal location, SVal V,
const LocationContext *LCtx) const;
[[nodiscard]] ProgramStateRef bindLoc(SVal location, SVal V,
const LocationContext *LCtx) const;
/// Initializes the region of memory represented by \p loc with an initial
/// value. Once initialized, all values loaded from any sub-regions of that
@ -293,15 +293,15 @@ public:
/// This method should not be used on regions that are already initialized.
/// If you need to indicate that memory contents have suddenly become unknown
/// within a certain region of memory, consider invalidateRegions().
LLVM_NODISCARD ProgramStateRef
[[nodiscard]] ProgramStateRef
bindDefaultInitial(SVal loc, SVal V, const LocationContext *LCtx) const;
/// Performs C++ zero-initialization procedure on the region of memory
/// represented by \p loc.
LLVM_NODISCARD ProgramStateRef
[[nodiscard]] ProgramStateRef
bindDefaultZero(SVal loc, const LocationContext *LCtx) const;
LLVM_NODISCARD ProgramStateRef killBinding(Loc LV) const;
[[nodiscard]] ProgramStateRef killBinding(Loc LV) const;
/// Returns the state with bindings for the given regions
/// cleared from the store.
@ -321,24 +321,25 @@ public:
/// the call and should be considered directly invalidated.
/// \param ITraits information about special handling for a particular
/// region/symbol.
LLVM_NODISCARD ProgramStateRef
[[nodiscard]] ProgramStateRef
invalidateRegions(ArrayRef<const MemRegion *> Regions, const Expr *E,
unsigned BlockCount, const LocationContext *LCtx,
bool CausesPointerEscape, InvalidatedSymbols *IS = nullptr,
const CallEvent *Call = nullptr,
RegionAndSymbolInvalidationTraits *ITraits = nullptr) const;
LLVM_NODISCARD ProgramStateRef
invalidateRegions(ArrayRef<SVal> Regions, const Expr *E,
unsigned BlockCount, const LocationContext *LCtx,
bool CausesPointerEscape, InvalidatedSymbols *IS = nullptr,
[[nodiscard]] ProgramStateRef
invalidateRegions(ArrayRef<SVal> Regions, const Expr *E, unsigned BlockCount,
const LocationContext *LCtx, bool CausesPointerEscape,
InvalidatedSymbols *IS = nullptr,
const CallEvent *Call = nullptr,
RegionAndSymbolInvalidationTraits *ITraits = nullptr) const;
/// enterStackFrame - Returns the state for entry to the given stack frame,
/// preserving the current state.
LLVM_NODISCARD ProgramStateRef enterStackFrame(
const CallEvent &Call, const StackFrameContext *CalleeCtx) const;
[[nodiscard]] ProgramStateRef
enterStackFrame(const CallEvent &Call,
const StackFrameContext *CalleeCtx) const;
/// Return the value of 'self' if available in the given context.
SVal getSelfSVal(const LocationContext *LC) const;
@ -417,7 +418,7 @@ public:
void *const* FindGDM(void *K) const;
template <typename T>
LLVM_NODISCARD ProgramStateRef
[[nodiscard]] ProgramStateRef
add(typename ProgramStateTrait<T>::key_type K) const;
template <typename T>
@ -437,27 +438,27 @@ public:
typename ProgramStateTrait<T>::context_type get_context() const;
template <typename T>
LLVM_NODISCARD ProgramStateRef
[[nodiscard]] ProgramStateRef
remove(typename ProgramStateTrait<T>::key_type K) const;
template <typename T>
LLVM_NODISCARD ProgramStateRef
[[nodiscard]] ProgramStateRef
remove(typename ProgramStateTrait<T>::key_type K,
typename ProgramStateTrait<T>::context_type C) const;
template <typename T> LLVM_NODISCARD ProgramStateRef remove() const;
template <typename T> [[nodiscard]] ProgramStateRef remove() const;
template <typename T>
LLVM_NODISCARD ProgramStateRef
[[nodiscard]] ProgramStateRef
set(typename ProgramStateTrait<T>::data_type D) const;
template <typename T>
LLVM_NODISCARD ProgramStateRef
[[nodiscard]] ProgramStateRef
set(typename ProgramStateTrait<T>::key_type K,
typename ProgramStateTrait<T>::value_type E) const;
template <typename T>
LLVM_NODISCARD ProgramStateRef
[[nodiscard]] ProgramStateRef
set(typename ProgramStateTrait<T>::key_type K,
typename ProgramStateTrait<T>::value_type E,
typename ProgramStateTrait<T>::context_type C) const;

View File

@ -259,7 +259,7 @@ public:
/// Merges \p Replaces into the current replacements. \p Replaces
/// refers to code after applying the current replacements.
LLVM_NODISCARD Replacements merge(const Replacements &Replaces) const;
[[nodiscard]] Replacements merge(const Replacements &Replaces) const;
// Returns the affected ranges in the changed code.
std::vector<Range> getAffectedRanges() const;

View File

@ -425,7 +425,7 @@ public:
/// Finalizes token collection. Should be called after preprocessing is
/// finished, i.e. after running Execute().
LLVM_NODISCARD TokenBuffer consume() &&;
[[nodiscard]] TokenBuffer consume() &&;
private:
/// Maps from a start to an end spelling location of transformations

View File

@ -184,13 +184,13 @@ namespace clang {
// Use this instead of Importer.importInto .
template <typename ImportT>
LLVM_NODISCARD Error importInto(ImportT &To, const ImportT &From) {
[[nodiscard]] Error importInto(ImportT &To, const ImportT &From) {
return Importer.importInto(To, From);
}
// Use this to import pointers of specific type.
template <typename ImportT>
LLVM_NODISCARD Error importInto(ImportT *&To, ImportT *From) {
[[nodiscard]] Error importInto(ImportT *&To, ImportT *From) {
auto ToOrErr = Importer.Import(From);
if (ToOrErr)
To = cast_or_null<ImportT>(*ToOrErr);
@ -245,8 +245,8 @@ namespace clang {
// then to the already imported Decl. Returns a bool value set to true if
// the `FromD` had been imported before.
template <typename ToDeclT, typename FromDeclT, typename... Args>
LLVM_NODISCARD bool GetImportedOrCreateDecl(ToDeclT *&ToD, FromDeclT *FromD,
Args &&... args) {
[[nodiscard]] bool GetImportedOrCreateDecl(ToDeclT *&ToD, FromDeclT *FromD,
Args &&...args) {
// There may be several overloads of ToDeclT::Create. We must make sure
// to call the one which would be chosen by the arguments, thus we use a
// wrapper for the overload set.
@ -261,8 +261,8 @@ namespace clang {
// GetImportedOrCreateDecl<TypeAliasDecl>(ToTypedef, FromD, ...);
template <typename NewDeclT, typename ToDeclT, typename FromDeclT,
typename... Args>
LLVM_NODISCARD bool GetImportedOrCreateDecl(ToDeclT *&ToD, FromDeclT *FromD,
Args &&... args) {
[[nodiscard]] bool GetImportedOrCreateDecl(ToDeclT *&ToD, FromDeclT *FromD,
Args &&...args) {
CallOverloadedCreateFun<NewDeclT> OC;
return GetImportedOrCreateSpecialDecl(ToD, OC, FromD,
std::forward<Args>(args)...);
@ -271,9 +271,9 @@ namespace clang {
// used, e.g. CXXRecordDecl::CreateLambda .
template <typename ToDeclT, typename CreateFunT, typename FromDeclT,
typename... Args>
LLVM_NODISCARD bool
[[nodiscard]] bool
GetImportedOrCreateSpecialDecl(ToDeclT *&ToD, CreateFunT CreateFun,
FromDeclT *FromD, Args &&... args) {
FromDeclT *FromD, Args &&...args) {
if (Importer.getImportDeclErrorIfAny(FromD)) {
ToD = nullptr;
return true; // Already imported but with error.

View File

@ -1219,7 +1219,7 @@ namespace {
/// (Foo(), 1) // use noteSideEffect
/// (Foo() || true) // use noteSideEffect
/// Foo() + 1 // use noteFailure
LLVM_NODISCARD bool noteFailure() {
[[nodiscard]] bool noteFailure() {
// Failure when evaluating some expression often means there is some
// subexpression whose evaluation was skipped. Therefore, (because we
// don't track whether we skipped an expression when unwinding after an
@ -6834,9 +6834,8 @@ public:
: Bytes(Width.getQuantity()),
TargetIsLittleEndian(TargetIsLittleEndian) {}
LLVM_NODISCARD
bool readObject(CharUnits Offset, CharUnits Width,
SmallVectorImpl<unsigned char> &Output) const {
[[nodiscard]] bool readObject(CharUnits Offset, CharUnits Width,
SmallVectorImpl<unsigned char> &Output) const {
for (CharUnits I = Offset, E = Offset + Width; I != E; ++I) {
// If a byte of an integer is uninitialized, then the whole integer is
// uninitialized.

View File

@ -4601,7 +4601,7 @@ namespace {
/// Specify given \p NewAlign as the alignment of return value attribute. If
/// such attribute already exists, re-set it to the maximal one of two options.
LLVM_NODISCARD llvm::AttributeList
[[nodiscard]] llvm::AttributeList
maybeRaiseRetAlignmentAttribute(llvm::LLVMContext &Ctx,
const llvm::AttributeList &Attrs,
llvm::Align NewAlign) {
@ -4632,7 +4632,7 @@ protected:
public:
/// If we can, materialize the alignment as an attribute on return value.
LLVM_NODISCARD llvm::AttributeList
[[nodiscard]] llvm::AttributeList
TryEmitAsCallSiteAttribute(const llvm::AttributeList &Attrs) {
if (!AA || OffsetCI || CGF.SanOpts.has(SanitizerKind::Alignment))
return Attrs;

View File

@ -596,9 +596,9 @@ public:
}
/// Determine whether the token is a simple-type-specifier.
LLVM_NODISCARD bool isSimpleTypeSpecifier() const;
[[nodiscard]] bool isSimpleTypeSpecifier() const;
LLVM_NODISCARD bool isTypeOrIdentifier() const;
[[nodiscard]] bool isTypeOrIdentifier() const;
bool isObjCAccessSpecifier() const {
return is(tok::at) && Next &&
@ -723,7 +723,7 @@ public:
}
/// Returns the previous token ignoring comments.
LLVM_NODISCARD FormatToken *getPreviousNonComment() const {
[[nodiscard]] FormatToken *getPreviousNonComment() const {
FormatToken *Tok = Previous;
while (Tok && Tok->is(tok::comment))
Tok = Tok->Previous;
@ -731,7 +731,7 @@ public:
}
/// Returns the next token ignoring comments.
LLVM_NODISCARD const FormatToken *getNextNonComment() const {
[[nodiscard]] const FormatToken *getNextNonComment() const {
const FormatToken *Tok = Next;
while (Tok && Tok->is(tok::comment))
Tok = Tok->Next;
@ -740,7 +740,7 @@ public:
/// Returns \c true if this tokens starts a block-type list, i.e. a
/// list that should be indented with a block indent.
LLVM_NODISCARD bool opensBlockOrBlockTypeList(const FormatStyle &Style) const;
[[nodiscard]] bool opensBlockOrBlockTypeList(const FormatStyle &Style) const;
/// Returns whether the token is the left square bracket of a C++
/// structured binding declaration.

View File

@ -81,7 +81,7 @@ struct Scanner {
private:
/// Lexes next token and advances \p First and the \p Lexer.
LLVM_NODISCARD dependency_directives_scan::Token &
[[nodiscard]] dependency_directives_scan::Token &
lexToken(const char *&First, const char *const End);
dependency_directives_scan::Token &lexIncludeFilename(const char *&First,
@ -92,35 +92,35 @@ private:
///
/// In any case (whatever the token kind) \p First and the \p Lexer will
/// advance beyond the token.
LLVM_NODISCARD Optional<StringRef>
[[nodiscard]] Optional<StringRef>
tryLexIdentifierOrSkipLine(const char *&First, const char *const End);
/// Used when it is certain that next token is an identifier.
LLVM_NODISCARD StringRef lexIdentifier(const char *&First,
const char *const End);
[[nodiscard]] StringRef lexIdentifier(const char *&First,
const char *const End);
/// Lexes next token and returns true iff it is an identifier that matches \p
/// Id, otherwise it skips the current line and returns false.
///
/// In any case (whatever the token kind) \p First and the \p Lexer will
/// advance beyond the token.
LLVM_NODISCARD bool isNextIdentifierOrSkipLine(StringRef Id,
const char *&First,
const char *const End);
[[nodiscard]] bool isNextIdentifierOrSkipLine(StringRef Id,
const char *&First,
const char *const End);
LLVM_NODISCARD bool scanImpl(const char *First, const char *const End);
LLVM_NODISCARD bool lexPPLine(const char *&First, const char *const End);
LLVM_NODISCARD bool lexAt(const char *&First, const char *const End);
LLVM_NODISCARD bool lexModule(const char *&First, const char *const End);
LLVM_NODISCARD bool lexDefine(const char *HashLoc, const char *&First,
[[nodiscard]] bool scanImpl(const char *First, const char *const End);
[[nodiscard]] bool lexPPLine(const char *&First, const char *const End);
[[nodiscard]] bool lexAt(const char *&First, const char *const End);
[[nodiscard]] bool lexModule(const char *&First, const char *const End);
[[nodiscard]] bool lexDefine(const char *HashLoc, const char *&First,
const char *const End);
[[nodiscard]] bool lexPragma(const char *&First, const char *const End);
[[nodiscard]] bool lexEndif(const char *&First, const char *const End);
[[nodiscard]] bool lexDefault(DirectiveKind Kind, const char *&First,
const char *const End);
LLVM_NODISCARD bool lexPragma(const char *&First, const char *const End);
LLVM_NODISCARD bool lexEndif(const char *&First, const char *const End);
LLVM_NODISCARD bool lexDefault(DirectiveKind Kind, const char *&First,
const char *const End);
LLVM_NODISCARD bool lexModuleDirectiveBody(DirectiveKind Kind,
const char *&First,
const char *const End);
[[nodiscard]] bool lexModuleDirectiveBody(DirectiveKind Kind,
const char *&First,
const char *const End);
void lexPPDirectiveBody(const char *&First, const char *const End);
DirectiveWithTokens &pushDirective(DirectiveKind Kind) {
@ -177,8 +177,8 @@ static void skipOverSpaces(const char *&First, const char *const End) {
++First;
}
LLVM_NODISCARD static bool isRawStringLiteral(const char *First,
const char *Current) {
[[nodiscard]] static bool isRawStringLiteral(const char *First,
const char *Current) {
assert(First <= Current);
// Check if we can even back up.
@ -517,7 +517,7 @@ void Scanner::lexPPDirectiveBody(const char *&First, const char *const End) {
}
}
LLVM_NODISCARD Optional<StringRef>
[[nodiscard]] Optional<StringRef>
Scanner::tryLexIdentifierOrSkipLine(const char *&First, const char *const End) {
const dependency_directives_scan::Token &Tok = lexToken(First, End);
if (Tok.isNot(tok::raw_identifier)) {

View File

@ -454,10 +454,9 @@ private:
/// Process C++ operator new()'s allocation, which is the part of C++
/// new-expression that goes before the constructor.
LLVM_NODISCARD
ProgramStateRef processNewAllocation(const CXXAllocatorCall &Call,
CheckerContext &C,
AllocationFamily Family) const;
[[nodiscard]] ProgramStateRef
processNewAllocation(const CXXAllocatorCall &Call, CheckerContext &C,
AllocationFamily Family) const;
/// Perform a zero-allocation check.
///
@ -467,11 +466,9 @@ private:
/// 0.
/// \param [in] RetVal Specifies the newly allocated pointer value;
/// if unspecified, the value of expression \p E is used.
LLVM_NODISCARD
static ProgramStateRef ProcessZeroAllocCheck(const CallEvent &Call,
const unsigned IndexOfSizeArg,
ProgramStateRef State,
Optional<SVal> RetVal = None);
[[nodiscard]] static ProgramStateRef
ProcessZeroAllocCheck(const CallEvent &Call, const unsigned IndexOfSizeArg,
ProgramStateRef State, Optional<SVal> RetVal = None);
/// Model functions with the ownership_returns attribute.
///
@ -489,10 +486,9 @@ private:
/// \param [in] Att The ownership_returns attribute.
/// \param [in] State The \c ProgramState right before allocation.
/// \returns The ProgramState right after allocation.
LLVM_NODISCARD
ProgramStateRef MallocMemReturnsAttr(CheckerContext &C, const CallEvent &Call,
const OwnershipAttr *Att,
ProgramStateRef State) const;
[[nodiscard]] ProgramStateRef
MallocMemReturnsAttr(CheckerContext &C, const CallEvent &Call,
const OwnershipAttr *Att, ProgramStateRef State) const;
/// Models memory allocation.
///
@ -503,11 +499,9 @@ private:
/// malloc leaves it undefined.
/// \param [in] State The \c ProgramState right before allocation.
/// \returns The ProgramState right after allocation.
LLVM_NODISCARD
static ProgramStateRef MallocMemAux(CheckerContext &C, const CallEvent &Call,
const Expr *SizeEx, SVal Init,
ProgramStateRef State,
AllocationFamily Family);
[[nodiscard]] static ProgramStateRef
MallocMemAux(CheckerContext &C, const CallEvent &Call, const Expr *SizeEx,
SVal Init, ProgramStateRef State, AllocationFamily Family);
/// Models memory allocation.
///
@ -518,16 +512,13 @@ private:
/// malloc leaves it undefined.
/// \param [in] State The \c ProgramState right before allocation.
/// \returns The ProgramState right after allocation.
LLVM_NODISCARD
static ProgramStateRef MallocMemAux(CheckerContext &C, const CallEvent &Call,
SVal Size, SVal Init,
ProgramStateRef State,
AllocationFamily Family);
[[nodiscard]] static ProgramStateRef
MallocMemAux(CheckerContext &C, const CallEvent &Call, SVal Size, SVal Init,
ProgramStateRef State, AllocationFamily Family);
// Check if this malloc() for special flags. At present that means M_ZERO or
// __GFP_ZERO (in which case, treat it like calloc).
LLVM_NODISCARD
llvm::Optional<ProgramStateRef>
[[nodiscard]] llvm::Optional<ProgramStateRef>
performKernelMalloc(const CallEvent &Call, CheckerContext &C,
const ProgramStateRef &State) const;
@ -548,10 +539,10 @@ private:
/// \param [in] Att The ownership_takes or ownership_holds attribute.
/// \param [in] State The \c ProgramState right before allocation.
/// \returns The ProgramState right after deallocation.
LLVM_NODISCARD
ProgramStateRef FreeMemAttr(CheckerContext &C, const CallEvent &Call,
const OwnershipAttr *Att,
ProgramStateRef State) const;
[[nodiscard]] ProgramStateRef FreeMemAttr(CheckerContext &C,
const CallEvent &Call,
const OwnershipAttr *Att,
ProgramStateRef State) const;
/// Models memory deallocation.
///
@ -572,12 +563,10 @@ private:
/// \param [in] ReturnsNullOnFailure Whether the memory deallocation function
/// we're modeling returns with Null on failure.
/// \returns The ProgramState right after deallocation.
LLVM_NODISCARD
ProgramStateRef FreeMemAux(CheckerContext &C, const CallEvent &Call,
ProgramStateRef State, unsigned Num, bool Hold,
bool &IsKnownToBeAllocated,
AllocationFamily Family,
bool ReturnsNullOnFailure = false) const;
[[nodiscard]] ProgramStateRef
FreeMemAux(CheckerContext &C, const CallEvent &Call, ProgramStateRef State,
unsigned Num, bool Hold, bool &IsKnownToBeAllocated,
AllocationFamily Family, bool ReturnsNullOnFailure = false) const;
/// Models memory deallocation.
///
@ -598,12 +587,10 @@ private:
/// \param [in] ReturnsNullOnFailure Whether the memory deallocation function
/// we're modeling returns with Null on failure.
/// \returns The ProgramState right after deallocation.
LLVM_NODISCARD
ProgramStateRef FreeMemAux(CheckerContext &C, const Expr *ArgExpr,
const CallEvent &Call, ProgramStateRef State,
bool Hold, bool &IsKnownToBeAllocated,
AllocationFamily Family,
bool ReturnsNullOnFailure = false) const;
[[nodiscard]] ProgramStateRef
FreeMemAux(CheckerContext &C, const Expr *ArgExpr, const CallEvent &Call,
ProgramStateRef State, bool Hold, bool &IsKnownToBeAllocated,
AllocationFamily Family, bool ReturnsNullOnFailure = false) const;
// TODO: Needs some refactoring, as all other deallocation modeling
// functions are suffering from out parameters and messy code due to how
@ -618,29 +605,27 @@ private:
/// \param [in] SuffixWithN Whether the reallocation function we're modeling
/// has an '_n' suffix, such as g_realloc_n.
/// \returns The ProgramState right after reallocation.
LLVM_NODISCARD
ProgramStateRef ReallocMemAux(CheckerContext &C, const CallEvent &Call,
bool ShouldFreeOnFail, ProgramStateRef State,
AllocationFamily Family,
bool SuffixWithN = false) const;
[[nodiscard]] ProgramStateRef
ReallocMemAux(CheckerContext &C, const CallEvent &Call, bool ShouldFreeOnFail,
ProgramStateRef State, AllocationFamily Family,
bool SuffixWithN = false) const;
/// Evaluates the buffer size that needs to be allocated.
///
/// \param [in] Blocks The amount of blocks that needs to be allocated.
/// \param [in] BlockBytes The size of a block.
/// \returns The symbolic value of \p Blocks * \p BlockBytes.
LLVM_NODISCARD
static SVal evalMulForBufferSize(CheckerContext &C, const Expr *Blocks,
const Expr *BlockBytes);
[[nodiscard]] static SVal evalMulForBufferSize(CheckerContext &C,
const Expr *Blocks,
const Expr *BlockBytes);
/// Models zero initialized array allocation.
///
/// \param [in] Call The expression that reallocated memory
/// \param [in] State The \c ProgramState right before reallocation.
/// \returns The ProgramState right after allocation.
LLVM_NODISCARD
static ProgramStateRef CallocMem(CheckerContext &C, const CallEvent &Call,
ProgramStateRef State);
[[nodiscard]] static ProgramStateRef
CallocMem(CheckerContext &C, const CallEvent &Call, ProgramStateRef State);
/// See if deallocation happens in a suspicious context. If so, escape the
/// pointers that otherwise would have been deallocated and return true.
@ -673,12 +658,11 @@ private:
SymbolRef &EscapingSymbol) const;
/// Implementation of the checkPointerEscape callbacks.
LLVM_NODISCARD
ProgramStateRef checkPointerEscapeAux(ProgramStateRef State,
const InvalidatedSymbols &Escaped,
const CallEvent *Call,
PointerEscapeKind Kind,
bool IsConstPointerEscape) const;
[[nodiscard]] ProgramStateRef
checkPointerEscapeAux(ProgramStateRef State,
const InvalidatedSymbols &Escaped,
const CallEvent *Call, PointerEscapeKind Kind,
bool IsConstPointerEscape) const;
// Implementation of the checkPreStmt and checkEndFunction callbacks.
void checkEscapeOnReturn(const ReturnStmt *S, CheckerContext &C) const;

View File

@ -314,7 +314,7 @@ ProgramStateRef ProgramState::BindExpr(const Stmt *S,
return getStateManager().getPersistentState(NewSt);
}
LLVM_NODISCARD std::pair<ProgramStateRef, ProgramStateRef>
[[nodiscard]] std::pair<ProgramStateRef, ProgramStateRef>
ProgramState::assumeInBoundDual(DefinedOrUnknownSVal Idx,
DefinedOrUnknownSVal UpperBound,
QualType indexTy) const {

View File

@ -913,20 +913,20 @@ namespace {
class EquivalenceClass : public llvm::FoldingSetNode {
public:
/// Find equivalence class for the given symbol in the given state.
LLVM_NODISCARD static inline EquivalenceClass find(ProgramStateRef State,
SymbolRef Sym);
[[nodiscard]] static inline EquivalenceClass find(ProgramStateRef State,
SymbolRef Sym);
/// Merge classes for the given symbols and return a new state.
LLVM_NODISCARD static inline ProgramStateRef merge(RangeSet::Factory &F,
ProgramStateRef State,
SymbolRef First,
SymbolRef Second);
[[nodiscard]] static inline ProgramStateRef merge(RangeSet::Factory &F,
ProgramStateRef State,
SymbolRef First,
SymbolRef Second);
// Merge this class with the given class and return a new state.
LLVM_NODISCARD inline ProgramStateRef
[[nodiscard]] inline ProgramStateRef
merge(RangeSet::Factory &F, ProgramStateRef State, EquivalenceClass Other);
/// Return a set of class members for the given state.
LLVM_NODISCARD inline SymbolSet getClassMembers(ProgramStateRef State) const;
[[nodiscard]] inline SymbolSet getClassMembers(ProgramStateRef State) const;
/// Return true if the current class is trivial in the given state.
/// A class is trivial if and only if there is not any member relations stored
@ -939,43 +939,42 @@ public:
/// members and then during the removal of dead symbols we remove one of its
/// members. In this case, the class is still non-trivial (it still has the
/// mappings in ClassMembers), even though it has only one member.
LLVM_NODISCARD inline bool isTrivial(ProgramStateRef State) const;
[[nodiscard]] inline bool isTrivial(ProgramStateRef State) const;
/// Return true if the current class is trivial and its only member is dead.
LLVM_NODISCARD inline bool isTriviallyDead(ProgramStateRef State,
SymbolReaper &Reaper) const;
[[nodiscard]] inline bool isTriviallyDead(ProgramStateRef State,
SymbolReaper &Reaper) const;
LLVM_NODISCARD static inline ProgramStateRef
[[nodiscard]] static inline ProgramStateRef
markDisequal(RangeSet::Factory &F, ProgramStateRef State, SymbolRef First,
SymbolRef Second);
LLVM_NODISCARD static inline ProgramStateRef
[[nodiscard]] static inline ProgramStateRef
markDisequal(RangeSet::Factory &F, ProgramStateRef State,
EquivalenceClass First, EquivalenceClass Second);
LLVM_NODISCARD inline ProgramStateRef
[[nodiscard]] inline ProgramStateRef
markDisequal(RangeSet::Factory &F, ProgramStateRef State,
EquivalenceClass Other) const;
LLVM_NODISCARD static inline ClassSet
getDisequalClasses(ProgramStateRef State, SymbolRef Sym);
LLVM_NODISCARD inline ClassSet
getDisequalClasses(ProgramStateRef State) const;
LLVM_NODISCARD inline ClassSet
[[nodiscard]] static inline ClassSet getDisequalClasses(ProgramStateRef State,
SymbolRef Sym);
[[nodiscard]] inline ClassSet getDisequalClasses(ProgramStateRef State) const;
[[nodiscard]] inline ClassSet
getDisequalClasses(DisequalityMapTy Map, ClassSet::Factory &Factory) const;
LLVM_NODISCARD static inline Optional<bool> areEqual(ProgramStateRef State,
EquivalenceClass First,
EquivalenceClass Second);
LLVM_NODISCARD static inline Optional<bool>
[[nodiscard]] static inline Optional<bool> areEqual(ProgramStateRef State,
EquivalenceClass First,
EquivalenceClass Second);
[[nodiscard]] static inline Optional<bool>
areEqual(ProgramStateRef State, SymbolRef First, SymbolRef Second);
/// Remove one member from the class.
LLVM_NODISCARD ProgramStateRef removeMember(ProgramStateRef State,
const SymbolRef Old);
[[nodiscard]] ProgramStateRef removeMember(ProgramStateRef State,
const SymbolRef Old);
/// Iterate over all symbols and try to simplify them.
LLVM_NODISCARD static inline ProgramStateRef simplify(SValBuilder &SVB,
RangeSet::Factory &F,
ProgramStateRef State,
EquivalenceClass Class);
[[nodiscard]] static inline ProgramStateRef simplify(SValBuilder &SVB,
RangeSet::Factory &F,
ProgramStateRef State,
EquivalenceClass Class);
void dumpToStream(ProgramStateRef State, raw_ostream &os) const;
LLVM_DUMP_METHOD void dump(ProgramStateRef State) const {
@ -983,10 +982,10 @@ public:
}
/// Check equivalence data for consistency.
LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED static bool
[[nodiscard]] LLVM_ATTRIBUTE_UNUSED static bool
isClassDataConsistent(ProgramStateRef State);
LLVM_NODISCARD QualType getType() const {
[[nodiscard]] QualType getType() const {
return getRepresentativeSymbol()->getType();
}
@ -1041,7 +1040,7 @@ private:
// Constraint functions
//===----------------------------------------------------------------------===//
LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED bool
[[nodiscard]] LLVM_ATTRIBUTE_UNUSED bool
areFeasible(ConstraintRangeTy Constraints) {
return llvm::none_of(
Constraints,
@ -1050,24 +1049,24 @@ areFeasible(ConstraintRangeTy Constraints) {
});
}
LLVM_NODISCARD inline const RangeSet *getConstraint(ProgramStateRef State,
EquivalenceClass Class) {
[[nodiscard]] inline const RangeSet *getConstraint(ProgramStateRef State,
EquivalenceClass Class) {
return State->get<ConstraintRange>(Class);
}
LLVM_NODISCARD inline const RangeSet *getConstraint(ProgramStateRef State,
SymbolRef Sym) {
[[nodiscard]] inline const RangeSet *getConstraint(ProgramStateRef State,
SymbolRef Sym) {
return getConstraint(State, EquivalenceClass::find(State, Sym));
}
LLVM_NODISCARD ProgramStateRef setConstraint(ProgramStateRef State,
EquivalenceClass Class,
RangeSet Constraint) {
[[nodiscard]] ProgramStateRef setConstraint(ProgramStateRef State,
EquivalenceClass Class,
RangeSet Constraint) {
return State->set<ConstraintRange>(Class, Constraint);
}
LLVM_NODISCARD ProgramStateRef setConstraints(ProgramStateRef State,
ConstraintRangeTy Constraints) {
[[nodiscard]] ProgramStateRef setConstraints(ProgramStateRef State,
ConstraintRangeTy Constraints) {
return State->set<ConstraintRange>(Constraints);
}
@ -1105,8 +1104,8 @@ Optional<bool> meansEquality(const SymSymExpr *Sym) {
//===----------------------------------------------------------------------===//
template <class SecondTy, class... RestTy>
LLVM_NODISCARD inline RangeSet intersect(RangeSet::Factory &F, RangeSet Head,
SecondTy Second, RestTy... Tail);
[[nodiscard]] inline RangeSet intersect(RangeSet::Factory &F, RangeSet Head,
SecondTy Second, RestTy... Tail);
template <class... RangeTy> struct IntersectionTraits;
@ -1128,13 +1127,13 @@ struct IntersectionTraits<OptionalOrPointer, TailTy...> {
};
template <class EndTy>
LLVM_NODISCARD inline EndTy intersect(RangeSet::Factory &F, EndTy End) {
[[nodiscard]] inline EndTy intersect(RangeSet::Factory &F, EndTy End) {
// If the list contains only RangeSet or Optional<RangeSet>, simply return
// that range set.
return End;
}
LLVM_NODISCARD LLVM_ATTRIBUTE_UNUSED inline Optional<RangeSet>
[[nodiscard]] LLVM_ATTRIBUTE_UNUSED inline Optional<RangeSet>
intersect(RangeSet::Factory &F, const RangeSet *End) {
// This is an extraneous conversion from a raw pointer into Optional<RangeSet>
if (End) {
@ -1144,16 +1143,16 @@ intersect(RangeSet::Factory &F, const RangeSet *End) {
}
template <class... RestTy>
LLVM_NODISCARD inline RangeSet intersect(RangeSet::Factory &F, RangeSet Head,
RangeSet Second, RestTy... Tail) {
[[nodiscard]] inline RangeSet intersect(RangeSet::Factory &F, RangeSet Head,
RangeSet Second, RestTy... Tail) {
// Here we call either the <RangeSet,RangeSet,...> or <RangeSet,...> version
// of the function and can be sure that the result is RangeSet.
return intersect(F, F.intersect(Head, Second), Tail...);
}
template <class SecondTy, class... RestTy>
LLVM_NODISCARD inline RangeSet intersect(RangeSet::Factory &F, RangeSet Head,
SecondTy Second, RestTy... Tail) {
[[nodiscard]] inline RangeSet intersect(RangeSet::Factory &F, RangeSet Head,
SecondTy Second, RestTy... Tail) {
if (Second) {
// Here we call the <RangeSet,RangeSet,...> version of the function...
return intersect(F, Head, *Second, Tail...);
@ -1183,7 +1182,7 @@ LLVM_NODISCARD inline RangeSet intersect(RangeSet::Factory &F, RangeSet Head,
/// a raw pointer and all previous arguments are None, it will cost one
/// additional check to convert RangeSet * into Optional<RangeSet>.
template <class HeadTy, class SecondTy, class... RestTy>
LLVM_NODISCARD inline
[[nodiscard]] inline
typename IntersectionTraits<HeadTy, SecondTy, RestTy...>::Type
intersect(RangeSet::Factory &F, HeadTy Head, SecondTy Second,
RestTy... Tail) {
@ -1995,7 +1994,7 @@ public:
class ConstraintAssignor : public ConstraintAssignorBase<ConstraintAssignor> {
public:
template <class ClassOrSymbol>
LLVM_NODISCARD static ProgramStateRef
[[nodiscard]] static ProgramStateRef
assign(ProgramStateRef State, SValBuilder &Builder, RangeSet::Factory &F,
ClassOrSymbol CoS, RangeSet NewConstraint) {
if (!State || NewConstraint.isEmpty())
@ -2037,7 +2036,7 @@ private:
using Base = ConstraintAssignorBase<ConstraintAssignor>;
/// Base method for handling new constraints for symbols.
LLVM_NODISCARD ProgramStateRef assign(SymbolRef Sym, RangeSet NewConstraint) {
[[nodiscard]] ProgramStateRef assign(SymbolRef Sym, RangeSet NewConstraint) {
// All constraints are actually associated with equivalence classes, and
// that's what we are going to do first.
State = assign(EquivalenceClass::find(State, Sym), NewConstraint);
@ -2051,8 +2050,8 @@ private:
}
/// Base method for handling new constraints for classes.
LLVM_NODISCARD ProgramStateRef assign(EquivalenceClass Class,
RangeSet NewConstraint) {
[[nodiscard]] ProgramStateRef assign(EquivalenceClass Class,
RangeSet NewConstraint) {
// There is a chance that we might need to update constraints for the
// classes that are known to be disequal to Class.
//
@ -2098,7 +2097,7 @@ private:
return EquivalenceClass::merge(RangeFactory, State, LHS, RHS);
}
LLVM_NODISCARD Optional<bool> interpreteAsBool(RangeSet Constraint) {
[[nodiscard]] Optional<bool> interpreteAsBool(RangeSet Constraint) {
assert(!Constraint.isEmpty() && "Empty ranges shouldn't get here");
if (Constraint.getConcreteValue())
@ -2527,7 +2526,7 @@ inline Optional<bool> EquivalenceClass::areEqual(ProgramStateRef State,
return llvm::None;
}
LLVM_NODISCARD ProgramStateRef
[[nodiscard]] ProgramStateRef
EquivalenceClass::removeMember(ProgramStateRef State, const SymbolRef Old) {
SymbolSet ClsMembers = getClassMembers(State);
@ -2556,9 +2555,8 @@ EquivalenceClass::removeMember(ProgramStateRef State, const SymbolRef Old) {
}
// Re-evaluate an SVal with top-level `State->assume` logic.
LLVM_NODISCARD ProgramStateRef reAssume(ProgramStateRef State,
const RangeSet *Constraint,
SVal TheValue) {
[[nodiscard]] ProgramStateRef
reAssume(ProgramStateRef State, const RangeSet *Constraint, SVal TheValue) {
if (!Constraint)
return State;
@ -2587,7 +2585,7 @@ LLVM_NODISCARD ProgramStateRef reAssume(ProgramStateRef State,
// class to this class. This way, we simplify not just the symbols but the
// classes as well: we strive to keep the number of the classes to be the
// absolute minimum.
LLVM_NODISCARD ProgramStateRef
[[nodiscard]] ProgramStateRef
EquivalenceClass::simplify(SValBuilder &SVB, RangeSet::Factory &F,
ProgramStateRef State, EquivalenceClass Class) {
SymbolSet ClassMembers = Class.getClassMembers(State);