Coverage Report

Created: 2020-10-24 06:27

/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
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
///
10
/// \file
11
/// \brief This file defines AST data structures related to concepts.
12
///
13
//===----------------------------------------------------------------------===//
14
15
#include "clang/AST/ASTConcept.h"
16
#include "clang/AST/ASTContext.h"
17
#include "clang/AST/Decl.h"
18
#include "clang/AST/TemplateBase.h"
19
#include "llvm/ADT/ArrayRef.h"
20
#include "llvm/ADT/FoldingSet.h"
21
using namespace clang;
22
23
ASTConstraintSatisfaction::ASTConstraintSatisfaction(const ASTContext &C,
24
    const ConstraintSatisfaction &Satisfaction):
25
    NumRecords{Satisfaction.Details.size()},
26
599
    IsSatisfied{Satisfaction.IsSatisfied} {
27
762
  for (unsigned I = 0; I < NumRecords; 
++I163
) {
28
163
    auto &Detail = Satisfaction.Details[I];
29
163
    if (Detail.second.is<Expr *>())
30
151
      new (getTrailingObjects<UnsatisfiedConstraintRecord>() + I)
31
151
         UnsatisfiedConstraintRecord{Detail.first,
32
151
                                     UnsatisfiedConstraintRecord::second_type(
33
151
                                         Detail.second.get<Expr *>())};
34
12
    else {
35
12
      auto &SubstitutionDiagnostic =
36
12
          *Detail.second.get<std::pair<SourceLocation, StringRef> *>();
37
12
      unsigned MessageSize = SubstitutionDiagnostic.second.size();
38
12
      char *Mem = new (C) char[MessageSize];
39
12
      memcpy(Mem, SubstitutionDiagnostic.second.data(), MessageSize);
40
12
      auto *NewSubstDiag = new (C) std::pair<SourceLocation, StringRef>(
41
12
          SubstitutionDiagnostic.first, StringRef(Mem, MessageSize));
42
12
      new (getTrailingObjects<UnsatisfiedConstraintRecord>() + I)
43
12
         UnsatisfiedConstraintRecord{Detail.first,
44
12
                                     UnsatisfiedConstraintRecord::second_type(
45
12
                                         NewSubstDiag)};
46
12
    }
47
163
  }
48
599
}
49
50
51
ASTConstraintSatisfaction *
52
ASTConstraintSatisfaction::Create(const ASTContext &C,
53
599
                                  const ConstraintSatisfaction &Satisfaction) {
54
599
  std::size_t size =
55
599
      totalSizeToAlloc<UnsatisfiedConstraintRecord>(
56
599
          Satisfaction.Details.size());
57
599
  void *Mem = C.Allocate(size, alignof(ASTConstraintSatisfaction));
58
599
  return new (Mem) ASTConstraintSatisfaction(C, Satisfaction);
59
599
}
60
61
void ConstraintSatisfaction::Profile(
62
    llvm::FoldingSetNodeID &ID, const ASTContext &C,
63
2.83k
    const NamedDecl *ConstraintOwner, ArrayRef<TemplateArgument> TemplateArgs) {
64
2.83k
  ID.AddPointer(ConstraintOwner);
65
2.83k
  ID.AddInteger(TemplateArgs.size());
66
2.83k
  for (auto &Arg : TemplateArgs)
67
3.12k
    Arg.Profile(ID, C);
68
2.83k
}