summaryrefslogtreecommitdiffstats
path: root/clang/test/AST/ast-dump-attr.cpp
diff options
context:
space:
mode:
authorMatthias Gehre <M.Gehre@gmx.de>2019-07-25 17:50:51 +0000
committerMatthias Gehre <M.Gehre@gmx.de>2019-07-25 17:50:51 +0000
commitd293cbd5fd44549bb48314499bc3b266d8967249 (patch)
treeab6670feffca7c33388bc45e9dba4f3aa4bef18b /clang/test/AST/ast-dump-attr.cpp
parent393094859e45f7a6ccbade1c919dee2c2e2f3a7e (diff)
downloadbcm5719-llvm-d293cbd5fd44549bb48314499bc3b266d8967249.tar.gz
bcm5719-llvm-d293cbd5fd44549bb48314499bc3b266d8967249.zip
Add lifetime categories attributes
Summary: This is the first part of work announced in "[RFC] Adding lifetime analysis to clang" [0], i.e. the addition of the [[gsl::Owner(T)]] and [[gsl::Pointer(T)]] attributes, which will enable user-defined types to participate in the lifetime analysis (which will be part of the next PR). The type `T` here is called "DerefType" in the paper, and denotes the type that an Owner owns and a Pointer points to. E.g. `std::vector<int>` should be annotated with `[[gsl::Owner(int)]]` and a `std::vector<int>::iterator` with `[[gsl::Pointer(int)]]`. [0] http://lists.llvm.org/pipermail/cfe-dev/2018-November/060355.html Reviewers: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63954 llvm-svn: 367040
Diffstat (limited to 'clang/test/AST/ast-dump-attr.cpp')
-rw-r--r--clang/test/AST/ast-dump-attr.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/test/AST/ast-dump-attr.cpp b/clang/test/AST/ast-dump-attr.cpp
index 8f67b9934e1..83c4a6342db 100644
--- a/clang/test/AST/ast-dump-attr.cpp
+++ b/clang/test/AST/ast-dump-attr.cpp
@@ -211,6 +211,23 @@ namespace TestSuppress {
}
}
+namespace TestLifetimeCategories {
+class [[gsl::Owner(int)]] AOwner{};
+// CHECK: CXXRecordDecl{{.*}} class AOwner
+// CHECK: OwnerAttr {{.*}} int
+class [[gsl::Pointer(int)]] APointer{};
+// CHECK: CXXRecordDecl{{.*}} class APointer
+// CHECK: PointerAttr {{.*}} int
+
+class [[gsl::Pointer]] PointerWithoutArgument{};
+// CHECK: CXXRecordDecl{{.*}} class PointerWithoutArgument
+// CHECK: PointerAttr
+
+class [[gsl::Owner]] OwnerWithoutArgument{};
+// CHECK: CXXRecordDecl{{.*}} class OwnerWithoutArgument
+// CHECK: OwnerAttr
+} // namespace TestLifetimeCategories
+
// Verify the order of attributes in the Ast. It must reflect the order
// in the parsed source.
int mergeAttrTest() __attribute__((deprecated)) __attribute__((warn_unused_result));
OpenPOWER on IntegriCloud