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