[clang] nonblocking/nonallocating attributes: 2nd pass caller/callee analysis (PR #99656)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 23 12:54:06 PDT 2024
================
@@ -15074,6 +15012,106 @@ class Sema final : public SemaBase {
std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const;
///@}
+
+ //
+ //
+ // -------------------------------------------------------------------------
+ //
+ //
+
+ /// \name Function Effects
+ /// Implementations are in SemaFunctionEffects.cpp
+ ///@{
+public:
+ struct FunctionEffectDiff {
+ enum class Kind { Added, Removed, ConditionMismatch };
+
+ FunctionEffect::Kind EffectKind;
+ Kind DiffKind;
+ FunctionEffectWithCondition Old; // invalid when Kind is Added.
+ FunctionEffectWithCondition New; // invalid when Kind is Removed.
+
+ StringRef effectName() const {
+ if (Old.Effect.kind() != FunctionEffect::Kind::None)
+ return Old.Effect.name();
+ return New.Effect.name();
+ }
+
+ /// Describes the result of effects differing between a base class's virtual
+ /// method and an overriding method in a subclass.
+ enum class OverrideResult {
+ NoAction,
+ Warn,
+ Merge // Merge missing effect from base to derived.
+ };
+
+ /// Return true if adding or removing the effect as part of a type
+ /// conversion should generate a diagnostic.
+ bool shouldDiagnoseConversion(QualType SrcType,
+ const FunctionEffectsRef &SrcFX,
+ QualType DstType,
+ const FunctionEffectsRef &DstFX) const;
+
+ /// Return true if adding or removing the effect in a redeclaration should
+ /// generate a diagnostic.
+ bool shouldDiagnoseRedeclaration(const FunctionDecl &OldFunction,
+ const FunctionEffectsRef &OldFX,
+ const FunctionDecl &NewFunction,
+ const FunctionEffectsRef &NewFX) const;
+
+ /// Return true if adding or removing the effect in a C++ virtual method
+ /// override should generate a diagnostic.
+ OverrideResult shouldDiagnoseMethodOverride(
+ const CXXMethodDecl &OldMethod, const FunctionEffectsRef &OldFX,
+ const CXXMethodDecl &NewMethod, const FunctionEffectsRef &NewFX) const;
+ };
+
+ struct FunctionEffectDifferences : public SmallVector<FunctionEffectDiff> {
----------------
Sirraide wrote:
Maybe calling this `FunctionEffectDiffVector` would make it more obvious what the purpose of this is.
https://github.com/llvm/llvm-project/pull/99656
More information about the cfe-commits
mailing list