Coverage Report

Created: 2021-08-24 07:12

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/AST/ASTConcept.cpp
Line
Count
Source
1
//===--- ASTConcept.cpp - Concepts Related AST Data Structures --*- C++ -*-===//
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
/// \file
10
/// \brief This file defines AST data structures related to concepts.
11
///
12
//===----------------------------------------------------------------------===//
13
14
#include "clang/AST/ASTConcept.h"
15
#include "clang/AST/ASTContext.h"
16
#include "clang/AST/Decl.h"
17
#include "clang/AST/TemplateBase.h"
18
#include "llvm/ADT/ArrayRef.h"
19
#include "llvm/ADT/FoldingSet.h"
20
using namespace clang;
21
22
ASTConstraintSatisfaction::ASTConstraintSatisfaction(const ASTContext &C,
23
    const ConstraintSatisfaction &Satisfaction):
24
    NumRecords{Satisfaction.Details.size()},
25
641
    IsSatisfied{Satisfaction.IsSatisfied} {
26
822
  for (unsigned I = 0; I < NumRecords; 
++I181
) {
27
181
    auto &Detail = Satisfaction.Details[I];
28
181
    if (Detail.second.is<Expr *>())
29
169
      new (getTrailingObjects<UnsatisfiedConstraintRecord>() + I)
30
169
         UnsatisfiedConstraintRecord{Detail.first,
31
169
                                     UnsatisfiedConstraintRecord::second_type(
32
169
                                         Detail.second.get<Expr *>())};
33
12
    else {
34
12
      auto &SubstitutionDiagnostic =
35
12
          *Detail.second.get<std::pair<SourceLocation, StringRef> *>();
36
12
      unsigned MessageSize = SubstitutionDiagnostic.second.size();
37
12
      char *Mem = new (C) char[MessageSize];
38
12
      memcpy(Mem, SubstitutionDiagnostic.second.data(), MessageSize);
39
12
      auto *NewSubstDiag = new (C) std::pair<SourceLocation, StringRef>(
40
12
          SubstitutionDiagnostic.first, StringRef(Mem, MessageSize));
41
12
      new (getTrailingObjects<UnsatisfiedConstraintRecord>() + I)
42
12
         UnsatisfiedConstraintRecord{Detail.first,
43
12
                                     UnsatisfiedConstraintRecord::second_type(
44
12
                                         NewSubstDiag)};
45
12
    }
46
181
  }
47
641
}
48
49
50
ASTConstraintSatisfaction *
51
ASTConstraintSatisfaction::Create(const ASTContext &C,
52
641
                                  const ConstraintSatisfaction &Satisfaction) {
53
641
  std::size_t size =
54
641
      totalSizeToAlloc<UnsatisfiedConstraintRecord>(
55
641
          Satisfaction.Details.size());
56
641
  void *Mem = C.Allocate(size, alignof(ASTConstraintSatisfaction));
57
641
  return new (Mem) ASTConstraintSatisfaction(C, Satisfaction);
58
641
}
59
60
void ConstraintSatisfaction::Profile(
61
    llvm::FoldingSetNodeID &ID, const ASTContext &C,
62
3.09k
    const NamedDecl *ConstraintOwner, ArrayRef<TemplateArgument> TemplateArgs) {
63
3.09k
  ID.AddPointer(ConstraintOwner);
64
3.09k
  ID.AddInteger(TemplateArgs.size());
65
3.09k
  for (auto &Arg : TemplateArgs)
66
3.44k
    Arg.Profile(ID, C);
67
3.09k
}