Author: NeKon69 Date: 2026-06-12T14:10:41Z New Revision: 95ca0744abc76f10da86bdd6e74f674a10a869f2
URL: https://github.com/llvm/llvm-project/commit/95ca0744abc76f10da86bdd6e74f674a10a869f2 DIFF: https://github.com/llvm/llvm-project/commit/95ca0744abc76f10da86bdd6e74f674a10a869f2.diff LOG: [LifetimeSafety] Warn on inapplicable [[clang::lifetimebound]] parameters (#201101) Adds `-Wlifetime-safety-inapplicable-lifetimebound` to diagnose `[[clang::lifetimebound]]` annotations that have no effect because the parameter type cannot carry a lifetime. This currently diagnoses scalar parameters and `gsl::Owner` parameters and unannotated record values (because they currently do not have origins), while still allowing references, pointers and `gsl::Pointer` values. Closes #177184 Added: clang/test/Sema/LifetimeSafety/inapplicable-lifetimebound.cpp Modified: clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeSafety.h clang/include/clang/Analysis/Analyses/LifetimeSafety/Origins.h clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Analysis/LifetimeSafety/Checker.cpp clang/lib/Analysis/LifetimeSafety/Origins.cpp clang/lib/Sema/SemaLifetimeSafety.h clang/test/Sema/LifetimeSafety/annotation-suggestions-fixits.cpp clang/test/Sema/LifetimeSafety/annotation-suggestions.cpp clang/test/Sema/LifetimeSafety/dangling-field.cpp clang/test/Sema/LifetimeSafety/lifetime-facts.cpp clang/test/Sema/LifetimeSafety/lifetimebound-violation.cpp clang/test/Sema/LifetimeSafety/misplaced-lifetimebound-cross-tu.cpp clang/test/Sema/LifetimeSafety/misplaced-lifetimebound-intra-tu.cpp clang/test/Sema/LifetimeSafety/misplaced-lifetimebound-macro.cpp clang/test/Sema/LifetimeSafety/nocfg.cpp clang/test/Sema/LifetimeSafety/noescape-violation.cpp clang/test/Sema/LifetimeSafety/safety.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeSafety.h b/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeSafety.h index 398cce1395854..b89e1bfe4b43e 100644 --- a/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeSafety.h +++ b/clang/include/clang/Analysis/Analyses/LifetimeSafety/LifetimeSafety.h @@ -141,6 +141,8 @@ class LifetimeSafetySemaHelper { const ParmVarDecl *PVDDef, const ParmVarDecl *PVDDecl) {} + virtual void reportInapplicableLifetimebound(const ParmVarDecl *PVD) {} + // Suggests lifetime bound annotations for implicit this. virtual void suggestLifetimeboundToImplicitThis(WarningScope Scope, const CXXMethodDecl *MD, diff --git a/clang/include/clang/Analysis/Analyses/LifetimeSafety/Origins.h b/clang/include/clang/Analysis/Analyses/LifetimeSafety/Origins.h index c2db59c579060..6ab2f59283ad3 100644 --- a/clang/include/clang/Analysis/Analyses/LifetimeSafety/Origins.h +++ b/clang/include/clang/Analysis/Analyses/LifetimeSafety/Origins.h @@ -158,7 +158,29 @@ class OriginManager { unsigned getNumOrigins() const { return NextOriginID.Value; } - bool hasOrigins(QualType QT) const; + /// Determines whether a type can carry lifetime origins. + /// + /// \param QT The type to check. + /// \param IntrinsicOnly If true, only consider types that can intrinsically + /// carry origins. If false, also include types that are tracked due to + /// context-sensitive annotations (e.g., return types of + /// [[clang::lifetimebound]] functions). + /// + /// Intrinsic origin types: + /// - Pointer types (int*, void*) + /// - Reference types (int&, const T&) + /// - gsl::Pointer annotated types (std::string_view) + /// - Lambdas capturing pointer-like objects + /// - Standard callable wrappers (std::function) + /// + /// TODO: Expand this list with other origin types such as: user-defined + /// structs with pointer-like fields. + /// + /// Contextual origin types (excluded when IntrinsicOnly=true): + /// - Types appearing as return values of functions with + /// [[clang::lifetimebound]] parameters, stored in + /// LifetimeAnnotatedOriginTypes during function body analysis. + bool hasOrigins(QualType QT, bool IntrinsicOnly = false) const; bool hasOrigins(const Expr *E) const; void dump(OriginID OID, llvm::raw_ostream &OS) const; diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 8031f99419bdc..244cd3630bb11 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -631,6 +631,13 @@ This warning may produce false-positives diagnostics when it cannot fully model }]; } +def LifetimeSafetyInapplicableLifetimebound + : DiagGroup<"lifetime-safety-inapplicable-lifetimebound"> { + code Documentation = [{ +Detects uses of [[clang::lifetimebound]] that have no effect because the type of the annotated parameter cannot carry a lifetime. + }]; +} + def LifetimeSafetyCrossTUMisplacedLifetimebound : DiagGroup<"lifetime-safety-cross-tu-misplaced-lifetimebound">; def LifetimeSafetyIntraTUMisplacedLifetimebound @@ -685,13 +692,29 @@ Detects misuse of [[clang::noescape]] annotation where the parameter escapes (fo }]; } +def LifetimeSafetyAnnotationPlacement + : DiagGroup<"lifetime-safety-annotation-placement", + [LifetimeSafetyInapplicableLifetimebound, + LifetimeSafetyMisplacedLifetimebound]> { + code Documentation = [{ +Validates that lifetime annotations are placed on appropriate types and in appropriate locations. + }]; +} + +def LifetimeSafetyAnnotationVerification + : DiagGroup<"lifetime-safety-annotation-verification", + [LifetimeSafetyNoescape, + LifetimeSafetyLifetimeboundViolation]> { + code Documentation = [{ +Verifies that function implementations adhere to their lifetime annotation contracts through dataflow analysis. + }]; +} + def LifetimeSafetyValidations : DiagGroup<"lifetime-safety-validations", - [LifetimeSafetyNoescape, - LifetimeSafetyLifetimeboundViolation, - LifetimeSafetyMisplacedLifetimebound]> { + [LifetimeSafetyAnnotationPlacement, + LifetimeSafetyAnnotationVerification]> { code Documentation = [{ -Verify function implementations adhere to the annotated lifetime contracts through lifetime safety -like verifying [[clang::noescape]] and [[clang::lifetimebound]]. +Validates correct usage and adherence to lifetime safety annotations like [[clang::noescape]] and [[clang::lifetimebound]]. }]; } diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index a3b575b7ee63a..583f3f9d2eff5 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -11043,6 +11043,11 @@ def warn_lifetime_safety_cross_tu_misplaced_lifetimebound InGroup<LifetimeSafetyCrossTUMisplacedLifetimebound>, DefaultIgnore; +def warn_lifetime_safety_inapplicable_lifetimebound + : Warning<"'lifetimebound' attribute has no effect on parameter of type %0. The attribute only applies to reference types, pointer types, and non-owner record types">, + InGroup<LifetimeSafetyInapplicableLifetimebound>, + DefaultIgnore; + def note_lifetime_safety_used_here : Note<"later used here">; def note_lifetime_safety_invalidated_here : Note<"invalidated here">; def note_lifetime_safety_destroyed_here : Note<"destroyed here">; diff --git a/clang/lib/Analysis/LifetimeSafety/Checker.cpp b/clang/lib/Analysis/LifetimeSafety/Checker.cpp index 2a71b5eb9a934..71cf2d2d5a674 100644 --- a/clang/lib/Analysis/LifetimeSafety/Checker.cpp +++ b/clang/lib/Analysis/LifetimeSafety/Checker.cpp @@ -104,6 +104,7 @@ class LifetimeChecker { reportNoescapeViolations(); reportLifetimeboundViolations(); reportMisplacedLifetimebound(); + reportInapplicableLifetimebound(); // Annotation inference is currently guarded by a frontend flag. In the // future, this might be replaced by a design that diff erentiates between // explicit and inferred findings with separate warning groups. @@ -470,6 +471,24 @@ class LifetimeChecker { } } + void reportInapplicableLifetimebound() { + const auto *FDef = dyn_cast<FunctionDecl>(FD); + if (!FDef) + return; + + // If analyzed function is a template definition or an implicit + // instantiation, skip. + if (FDef->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate || + FDef->getTemplateSpecializationKind() == TSK_ImplicitInstantiation) + return; + + for (const auto &PVD : FDef->parameters()) + if (PVD->hasAttr<LifetimeBoundAttr>() && + !FactMgr.getOriginMgr().hasOrigins(PVD->getType(), + /*IntrinsicOnly=*/true)) + SemaHelper->reportInapplicableLifetimebound(PVD); + } + void inferAnnotations() { for (auto [Target, EscapeTarget] : AnnotationWarningsMap) { if (const auto *MD = Target.dyn_cast<const CXXMethodDecl *>()) { diff --git a/clang/lib/Analysis/LifetimeSafety/Origins.cpp b/clang/lib/Analysis/LifetimeSafety/Origins.cpp index 37bd8a3ccc6bb..55d3b36e3163a 100644 --- a/clang/lib/Analysis/LifetimeSafety/Origins.cpp +++ b/clang/lib/Analysis/LifetimeSafety/Origins.cpp @@ -100,10 +100,11 @@ class LifetimeAnnotatedOriginTypeCollector } // namespace -bool OriginManager::hasOrigins(QualType QT) const { +bool OriginManager::hasOrigins(QualType QT, bool IntrinsicOnly) const { if (QT->isPointerOrReferenceType() || isGslPointerType(QT)) return true; - if (LifetimeAnnotatedOriginTypes.contains(QT.getCanonicalType().getTypePtr())) + if (!IntrinsicOnly && + LifetimeAnnotatedOriginTypes.contains(QT.getCanonicalType().getTypePtr())) return true; const auto *RD = QT->getAsCXXRecordDecl(); if (!RD) @@ -117,7 +118,7 @@ bool OriginManager::hasOrigins(QualType QT) const { if (!RD->isLambda()) return false; for (const auto *FD : RD->fields()) - if (hasOrigins(FD->getType())) + if (hasOrigins(FD->getType(), IntrinsicOnly)) return true; return false; } diff --git a/clang/lib/Sema/SemaLifetimeSafety.h b/clang/lib/Sema/SemaLifetimeSafety.h index 6da4953dea56d..462a4ed168e24 100644 --- a/clang/lib/Sema/SemaLifetimeSafety.h +++ b/clang/lib/Sema/SemaLifetimeSafety.h @@ -48,7 +48,8 @@ inline bool IsLifetimeSafetyEnabled(Sema &S, const Decl *D) { diag::warn_lifetime_safety_cross_tu_param_suggestion, diag::warn_lifetime_safety_intra_tu_param_suggestion, diag::warn_lifetime_safety_cross_tu_this_suggestion, - diag::warn_lifetime_safety_intra_tu_this_suggestion}; + diag::warn_lifetime_safety_intra_tu_this_suggestion, + diag::warn_lifetime_safety_inapplicable_lifetimebound}; for (unsigned DiagID : DiagIDs) if (!Diags.isIgnored(DiagID, D->getBeginLoc())) return true; @@ -343,6 +344,15 @@ class LifetimeSafetySemaHelperImpl : public LifetimeSafetySemaHelper { << Attr->getRange(); } + void reportInapplicableLifetimebound(const ParmVarDecl *PVD) override { + assert(PVD->hasAttr<LifetimeBoundAttr>() && + "Expected parameter to have lifetimebound attribute"); + const auto *Attr = PVD->getAttr<LifetimeBoundAttr>(); + S.Diag(Attr->getLocation(), + diag::warn_lifetime_safety_inapplicable_lifetimebound) + << PVD->getType() << Attr->getRange(); + } + void suggestLifetimeboundToImplicitThis(WarningScope Scope, const CXXMethodDecl *MD, const Expr *EscapeExpr) override { diff --git a/clang/test/Sema/LifetimeSafety/annotation-suggestions-fixits.cpp b/clang/test/Sema/LifetimeSafety/annotation-suggestions-fixits.cpp index d9c7e8d3f0519..18be627211975 100644 --- a/clang/test/Sema/LifetimeSafety/annotation-suggestions-fixits.cpp +++ b/clang/test/Sema/LifetimeSafety/annotation-suggestions-fixits.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -std=c++17 -flifetime-safety-inference \ // RUN: -fexperimental-lifetime-safety-tu-analysis \ -// RUN: -Wlifetime-safety-suggestions -Wno-dangling \ +// RUN: -Wlifetime-safety-suggestions -Wlifetime-safety-annotation-placement -Wno-dangling \ // RUN: -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s // RUN: cp %s %t.cpp // RUN: %clang_cc1 -std=c++17 -flifetime-safety-inference \ diff --git a/clang/test/Sema/LifetimeSafety/annotation-suggestions.cpp b/clang/test/Sema/LifetimeSafety/annotation-suggestions.cpp index f5a3cf89e4c8d..1f6832e824e37 100644 --- a/clang/test/Sema/LifetimeSafety/annotation-suggestions.cpp +++ b/clang/test/Sema/LifetimeSafety/annotation-suggestions.cpp @@ -1,6 +1,6 @@ // RUN: rm -rf %t // RUN: split-file %s %t -// RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference -fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety-suggestions -Wlifetime-safety -Wno-dangling -I%t -I%S -verify %t/test_source.cpp +// RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference -fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety-suggestions -Wlifetime-safety -Wlifetime-safety-annotation-placement -Wno-dangling -I%t -I%S -verify %t/test_source.cpp // RUN: %clang_cc1 -fsyntax-only -std=c++23 -flifetime-safety-inference -fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety-suggestions -Wlifetime-safety -Wno-dangling -I%t -I%S -verify %t/test_source.cpp // RUN: %clang_cc1 -flifetime-safety-inference -fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety-suggestions -Wlifetime-safety -Wno-dangling -I%t -I%S -fixit %t/test_source.cpp // RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference -fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety-suggestions -Wno-dangling -I%t -I%S -Werror=lifetime-safety-suggestions %t/test_source.cpp diff --git a/clang/test/Sema/LifetimeSafety/dangling-field.cpp b/clang/test/Sema/LifetimeSafety/dangling-field.cpp index cb13f51b41355..ab7c49d9c7bfd 100644 --- a/clang/test/Sema/LifetimeSafety/dangling-field.cpp +++ b/clang/test/Sema/LifetimeSafety/dangling-field.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety -Wno-dangling -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety -Wlifetime-safety-annotation-placement -Wno-dangling -verify %s // RUN: %clang_cc1 -fsyntax-only -fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety -Wno-dangling -verify=expected,tu %s #include "Inputs/lifetime-analysis.h" diff --git a/clang/test/Sema/LifetimeSafety/inapplicable-lifetimebound.cpp b/clang/test/Sema/LifetimeSafety/inapplicable-lifetimebound.cpp new file mode 100644 index 0000000000000..624a8e9bb00cc --- /dev/null +++ b/clang/test/Sema/LifetimeSafety/inapplicable-lifetimebound.cpp @@ -0,0 +1,92 @@ +// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-annotation-placement -Wno-dangling -verify %s + +#include "Inputs/lifetime-analysis.h" + +struct [[gsl::Owner]] Owner {}; + +struct [[gsl::Pointer()]] View { + View(); + View(const Owner &o [[clang::lifetimebound]]); +}; + +struct Plain {}; + +enum Enum { Enumerator }; + +struct Mixed { + Mixed(const int &i [[clang::lifetimebound]]); +}; + +using IntAlias = int; + +Owner *owner_value(Owner o [[clang::lifetimebound]]) { // expected-warning {{'lifetimebound' attribute has no effect on parameter of type 'Owner'}} + return {}; +} + +Owner *const_owner_value(const Owner o [[clang::lifetimebound]]) { // expected-warning {{'lifetimebound' attribute has no effect on parameter of type 'const Owner'}} + return {}; +} + +Owner *owner_ref(Owner &o [[clang::lifetimebound]]) { + return &o; +} + +const Owner *const_owner_ref(const Owner &o [[clang::lifetimebound]]) { + return &o; +} + +Owner *owner_ptr(Owner *o [[clang::lifetimebound]]) { + return o; +} + +int *scalar_ptr(int *p [[clang::lifetimebound]]) { + return p; +} + +int *scalar_value(int i [[clang::lifetimebound]]) { // expected-warning {{'lifetimebound' attribute has no effect on parameter of type 'int'}} + return {}; +} + +int *scalar_alias_value(IntAlias i [[clang::lifetimebound]]) { // expected-warning {{'lifetimebound' attribute has no effect on parameter of type 'IntAlias' (aka 'int')}} + return {}; +} + +int *enum_value(Enum e [[clang::lifetimebound]]) { // expected-warning {{'lifetimebound' attribute has no effect on parameter of type 'Enum'}} + return {}; +} + +View view_value(View v [[clang::lifetimebound]]) { + return v; +} + +Plain *plain_value(Plain p [[clang::lifetimebound]]) { // expected-warning {{'lifetimebound' attribute has no effect on parameter of type 'Plain'}} + return {}; +} + +Mixed *mixed_value(Mixed m [[clang::lifetimebound]]) { // expected-warning {{'lifetimebound' attribute has no effect on parameter of type 'Mixed'}} + return {}; +} + +template <class T> +Owner *template_value(T t [[clang::lifetimebound]]) { + return {}; +} + +void instantiate_template() { + Owner o; + (void)template_value(o); +} + +struct S { + Owner* foo() [[clang::lifetimebound]] { return {}; } +}; + +std::vector<int *> lifetime_annotated_return( + const int &i [[clang::lifetimebound]]); + +int *context_sensitive_origin_type( + std::vector<int *> v [[clang::lifetimebound]]) { // expected-warning {{'lifetimebound' attribute has no effect on parameter of type 'std::vector<int *>'}} + int i = 0; + lifetime_annotated_return(i); + return v[0]; +} diff --git a/clang/test/Sema/LifetimeSafety/lifetime-facts.cpp b/clang/test/Sema/LifetimeSafety/lifetime-facts.cpp index 2cfec824b0866..d655bf7391203 100644 --- a/clang/test/Sema/LifetimeSafety/lifetime-facts.cpp +++ b/clang/test/Sema/LifetimeSafety/lifetime-facts.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -mllvm -debug-only=LifetimeFacts -Wlifetime-safety %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -mllvm -debug-only=LifetimeFacts -Wlifetime-safety -Wlifetime-safety-annotation-placement %s 2>&1 | FileCheck %s // REQUIRES: asserts struct MyObj { diff --git a/clang/test/Sema/LifetimeSafety/lifetimebound-violation.cpp b/clang/test/Sema/LifetimeSafety/lifetimebound-violation.cpp index b0320bcbf4334..09b2a231efffe 100644 --- a/clang/test/Sema/LifetimeSafety/lifetimebound-violation.cpp +++ b/clang/test/Sema/LifetimeSafety/lifetimebound-violation.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-lifetimebound-violation -Wno-dangling -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-lifetimebound-violation -Wlifetime-safety-annotation-placement -Wno-dangling -verify %s #include "Inputs/lifetime-analysis.h" diff --git a/clang/test/Sema/LifetimeSafety/misplaced-lifetimebound-cross-tu.cpp b/clang/test/Sema/LifetimeSafety/misplaced-lifetimebound-cross-tu.cpp index 1705da44bdf19..cade7c7a81105 100644 --- a/clang/test/Sema/LifetimeSafety/misplaced-lifetimebound-cross-tu.cpp +++ b/clang/test/Sema/LifetimeSafety/misplaced-lifetimebound-cross-tu.cpp @@ -1,6 +1,6 @@ // RUN: rm -rf %t // RUN: split-file %s %t -// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-cross-tu-misplaced-lifetimebound -Wno-dangling -I%t -verify %t/cross.cpp +// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-cross-tu-misplaced-lifetimebound -Wlifetime-safety-annotation-placement -Wno-dangling -I%t -verify %t/cross.cpp // RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-cross-tu-misplaced-lifetimebound -Wno-dangling -I%t -fdiagnostics-parseable-fixits %t/cross.cpp 2>&1 | FileCheck %s // RUN: %clang_cc1 -Wlifetime-safety-cross-tu-misplaced-lifetimebound -Wno-dangling -I%t -fixit %t/cross.cpp // RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-cross-tu-misplaced-lifetimebound -Wno-dangling -I%t -Werror %t/cross.cpp diff --git a/clang/test/Sema/LifetimeSafety/misplaced-lifetimebound-intra-tu.cpp b/clang/test/Sema/LifetimeSafety/misplaced-lifetimebound-intra-tu.cpp index e92d5c7a2d90a..7fa4cae100509 100644 --- a/clang/test/Sema/LifetimeSafety/misplaced-lifetimebound-intra-tu.cpp +++ b/clang/test/Sema/LifetimeSafety/misplaced-lifetimebound-intra-tu.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-intra-tu-misplaced-lifetimebound -Wno-dangling -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-intra-tu-misplaced-lifetimebound -Wlifetime-safety-annotation-placement -Wno-dangling -verify %s // RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-intra-tu-misplaced-lifetimebound -Wno-dangling -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s // RUN: cp %s %t.intra.cpp // RUN: %clang_cc1 -Wlifetime-safety-intra-tu-misplaced-lifetimebound -Wno-dangling -fixit %t.intra.cpp diff --git a/clang/test/Sema/LifetimeSafety/misplaced-lifetimebound-macro.cpp b/clang/test/Sema/LifetimeSafety/misplaced-lifetimebound-macro.cpp index ccda9aed01832..789a0d687ef27 100644 --- a/clang/test/Sema/LifetimeSafety/misplaced-lifetimebound-macro.cpp +++ b/clang/test/Sema/LifetimeSafety/misplaced-lifetimebound-macro.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-intra-tu-misplaced-lifetimebound -Wno-dangling -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-intra-tu-misplaced-lifetimebound -Wlifetime-safety-annotation-placement -Wno-dangling -verify %s // RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety-intra-tu-misplaced-lifetimebound -Wno-dangling -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s // CHECK-NOT: fix-it: diff --git a/clang/test/Sema/LifetimeSafety/nocfg.cpp b/clang/test/Sema/LifetimeSafety/nocfg.cpp index 41b07771c52c1..e2a340401ac87 100644 --- a/clang/test/Sema/LifetimeSafety/nocfg.cpp +++ b/clang/test/Sema/LifetimeSafety/nocfg.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -Wdangling -Wdangling-field -Wreturn-stack-address -verify %s -// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety -Wno-dangling -verify=cfg %s -// RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference -fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety -Wno-dangling -verify=cfg,tu %s +// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety -Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -verify=cfg %s +// RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference -fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety -Wlifetime-safety-inapplicable-lifetimebound -Wno-dangling -verify=cfg,tu %s #include "Inputs/lifetime-analysis.h" diff --git a/clang/test/Sema/LifetimeSafety/noescape-violation.cpp b/clang/test/Sema/LifetimeSafety/noescape-violation.cpp index 4bb57e6b9df95..048c500239b4f 100644 --- a/clang/test/Sema/LifetimeSafety/noescape-violation.cpp +++ b/clang/test/Sema/LifetimeSafety/noescape-violation.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference -Wlifetime-safety-noescape -verify %s +// RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference -Wlifetime-safety-noescape -Wlifetime-safety-annotation-placement -verify %s #include "Inputs/lifetime-analysis.h" diff --git a/clang/test/Sema/LifetimeSafety/safety.cpp b/clang/test/Sema/LifetimeSafety/safety.cpp index f6dab33f8476c..580e1b2639ee1 100644 --- a/clang/test/Sema/LifetimeSafety/safety.cpp +++ b/clang/test/Sema/LifetimeSafety/safety.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety -Wno-dangling -verify=expected,function %s +// RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety -Wlifetime-safety-annotation-placement -Wno-dangling -verify=expected,function %s // RUN: %clang_cc1 -fsyntax-only -flifetime-safety-inference -fexperimental-lifetime-safety-tu-analysis -Wlifetime-safety -Wno-dangling -verify=expected,tu %s // RUN: %clang_cc1 -fsyntax-only -Wlifetime-safety -Wno-dangling -fcxx-exceptions -verify=expected,function %s _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
