[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / unittests / Sema / GslOwnerPointerInference.cpp
blob5d86a8806cbdd2fcbf332d31a4ff505c56004fb2
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 //===----------------------------------------------------------------------===//
9 #include "../ASTMatchers/ASTMatchersTest.h"
10 #include "clang/ASTMatchers/ASTMatchers.h"
11 #include "gtest/gtest.h"
13 namespace clang {
14 using namespace ast_matchers;
16 TEST(OwnerPointer, BothHaveAttributes) {
17 EXPECT_TRUE(matches("template<class T>"
18 "class [[gsl::Owner]] C;"
20 "template<class T>"
21 "class [[gsl::Owner]] C {};"
23 "C<int> c;",
24 classTemplateSpecializationDecl(
25 hasName("C"), hasAttr(clang::attr::Owner))));
28 TEST(OwnerPointer, ForwardDeclOnly) {
29 EXPECT_TRUE(matches("template<class T>"
30 "class [[gsl::Owner]] C;"
32 "template<class T>"
33 "class C {};"
35 "C<int> c;",
36 classTemplateSpecializationDecl(
37 hasName("C"), hasAttr(clang::attr::Owner))));
40 TEST(OwnerPointer, LateForwardDeclOnly) {
41 EXPECT_TRUE(matches("template<class T>"
42 "class C;"
44 "template<class T>"
45 "class C {};"
47 "template<class T>"
48 "class [[gsl::Owner]] C;"
50 "C<int> c;",
51 classTemplateSpecializationDecl(
52 hasName("C"), hasAttr(clang::attr::Owner))));
55 } // namespace clang