1//== unittests/Sema/GslOwnerPointerInference.cpp - gsl::Owner/Pointer ========//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "../ASTMatchers/ASTMatchersTest.h"
10#include "clang/ASTMatchers/ASTMatchers.h"
11#include "gtest/gtest.h"
12
13namespace clang {
14using namespace ast_matchers;
15
16TEST(OwnerPointer, BothHaveAttributes) {
17 EXPECT_TRUE(matches("template<class T>"
18 "class [[gsl::Owner]] C;"
19
20 "template<class T>"
21 "class [[gsl::Owner]] C {};"
22
23 "C<int> c;",
24 classTemplateSpecializationDecl(
25 hasName("C"), hasAttr(clang::attr::Owner))));
26}
27
28TEST(OwnerPointer, ForwardDeclOnly) {
29 EXPECT_TRUE(matches("template<class T>"
30 "class [[gsl::Owner]] C;"
31
32 "template<class T>"
33 "class C {};"
34
35 "C<int> c;",
36 classTemplateSpecializationDecl(
37 hasName("C"), hasAttr(clang::attr::Owner))));
38}
39
40TEST(OwnerPointer, LateForwardDeclOnly) {
41 EXPECT_TRUE(matches("template<class T>"
42 "class C;"
43
44 "template<class T>"
45 "class C {};"
46
47 "template<class T>"
48 "class [[gsl::Owner]] C;"
49
50 "C<int> c;",
51 classTemplateSpecializationDecl(
52 hasName("C"), hasAttr(clang::attr::Owner))));
53}
54
55} // namespace clang
56

source code of clang/unittests/Sema/GslOwnerPointerInference.cpp