brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · f6eb7c5 Raw
62 lines · cpp
1// RUN: %check_clang_tidy %s abseil-no-internal-dependencies %t,  -- -header-filter='' -- -I %S/Inputs2// RUN: clang-tidy -checks='-*, abseil-no-internal-dependencies' -header-filter='.*' %s -- -I %S/Inputs 2>&1 | FileCheck %s3 4#include "absl/strings/internal-file.h"5#include "absl/flags/internal-file.h"6// CHECK-NOT: warning:7 8#include "absl/external-file.h"9// CHECK: absl/external-file.h:6:24: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil [abseil-no-internal-dependencies]10 11void DirectAcess() {12  absl::strings_internal::InternalFunction();13  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil14 15  absl::strings_internal::InternalTemplateFunction<std::string>("a");16  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil17}18 19class FriendUsage {20  friend struct absl::container_internal::InternalStruct;21  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil22};23 24namespace absl {25void OpeningNamespace() {26  strings_internal::InternalFunction();27  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil28}29} // namespace absl30 31// should not trigger warnings32void CorrectUsage() {33  std::string Str = absl::StringsFunction("a");34  absl::SomeContainer b;35}36 37namespace absl {38SomeContainer b;39std::string Str = absl::StringsFunction("a");40} // namespace absl41 42#define USE_EXTERNAL(x) absl::strings_internal::Internal##x()43 44void MacroUse() {45  USE_INTERNAL(Function); // no-warning46  USE_EXTERNAL(Function);47  // CHECK-MESSAGES: :[[@LINE-5]]:25: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil48}49 50class A : absl::container_internal::InternalStruct {};51// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil52 53template <typename T>54class B : absl::container_internal::InternalTemplate<T> {};55// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil56 57template <typename T> class C : absl::container_internal::InternalTemplate<T> {58public:59  template <typename U> static C Make(U *p) { return C{}; }60};61// CHECK-MESSAGES: :[[@LINE-4]]:33: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil62