1 //== unittests/Sema/GslOwnerPointerInference.cpp - gsl::Owner/Pointer ========//
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
7 //===----------------------------------------------------------------------===//
9 #include "../ASTMatchers/ASTMatchersTest.h"
10 #include "clang/ASTMatchers/ASTMatchers.h"
11 #include "gtest/gtest.h"
14 using namespace ast_matchers
;
16 TEST(OwnerPointer
, BothHaveAttributes
) {
17 EXPECT_TRUE(matches("template<class T>"
18 "class [[gsl::Owner]] C;"
21 "class [[gsl::Owner]] 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;"
36 classTemplateSpecializationDecl(
37 hasName("C"), hasAttr(clang::attr::Owner
))));
40 TEST(OwnerPointer
, LateForwardDeclOnly
) {
41 EXPECT_TRUE(matches("template<class T>"
48 "class [[gsl::Owner]] C;"
51 classTemplateSpecializationDecl(
52 hasName("C"), hasAttr(clang::attr::Owner
))));