clang 10.0.0git

ASTConcept.cpp
Go to the documentation of this file.
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 IsSatisfied{Satisfaction.IsSatisfied} {
27 for (unsigned I = 0; I < NumRecords; ++I) {
28 auto &Detail = Satisfaction.Details[I];
29 if (Detail.second.is<Expr *>())
30 new (getTrailingObjects<UnsatisfiedConstraintRecord>() + I)
31 UnsatisfiedConstraintRecord{Detail.first,
32 UnsatisfiedConstraintRecord::second_type(
33 Detail.second.get<Expr *>())};
34 else {
35 auto &SubstitutionDiagnostic =
36 *Detail.second.get<std::pair<SourceLocation, StringRef> *>();
37 unsigned MessageSize = SubstitutionDiagnostic.second.size();
38 char *Mem = new (C) char[MessageSize];
39 memcpy(Mem, SubstitutionDiagnostic.second.data(), MessageSize);
40 auto *NewSubstDiag = new (C) std::pair<SourceLocation, StringRef>(
41 SubstitutionDiagnostic.first, StringRef(Mem, MessageSize));
42 new (getTrailingObjects<UnsatisfiedConstraintRecord>() + I)
43 UnsatisfiedConstraintRecord{Detail.first,
44 UnsatisfiedConstraintRecord::second_type(
45 NewSubstDiag)};
46 }
47 }
48 }
49
50
51 ASTConstraintSatisfaction *
52 ASTConstraintSatisfaction::Create(const ASTContext &C,
53 const ConstraintSatisfaction &Satisfaction) {
54 std::size_t size =
55 totalSizeToAlloc<UnsatisfiedConstraintRecord>(
56 Satisfaction.Details.size());
57 void *Mem = C.Allocate(size, alignof(ASTConstraintSatisfaction));
58 return new (Mem) ASTConstraintSatisfaction(C, Satisfaction);
59 }
60
61 void ConstraintSatisfaction::Profile(
62 llvm::FoldingSetNodeID &ID, const ASTContext &C,
63 const NamedDecl *ConstraintOwner, ArrayRef<TemplateArgument> TemplateArgs) {
64 ID.AddPointer(ConstraintOwner);
65 ID.AddInteger(TemplateArgs.size());
66 for (auto &Arg : TemplateArgs)
67 Arg.Profile(ID, C);
68 }
clang::Builtin::ID
ID
Definition: Builtins.h:46
ASTContext.h
Defines the clang::ASTContext interface.
clang::UnsatisfiedConstraintRecord
std::pair< const Expr *, llvm::PointerUnion< Expr *, std::pair< SourceLocation, StringRef > * > > UnsatisfiedConstraintRecord
Pairs of unsatisfied atomic constraint expressions along with the substituted constraint expr...
Definition: ASTConcept.h:71
clang::ASTConstraintSatisfaction::NumRecords
std::size_t NumRecords
Definition: ASTConcept.h:80
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:168
size_t
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
Definition: opencl-c-base.h:40
llvm::ArrayRef
Definition: LLVM.h:31
clang::ConstraintSatisfaction
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition: ASTConcept.h:29
clang::Expr
This represents one expression.
Definition: Expr.h:108
clang::ConstraintSatisfaction::Profile
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &C)
Definition: ASTConcept.h:55
clang::ASTConstraintSatisfaction::IsSatisfied
bool IsSatisfied
Definition: ASTConcept.h:81
memcpy
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Definition: __clang_cuda_device_functions.h:1632
clang::ASTContext::Allocate
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:686
Decl.h
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::ASTConstraintSatisfaction::ASTConstraintSatisfaction
ASTConstraintSatisfaction(const ASTContext &C, const ConstraintSatisfaction &Satisfaction)
Definition: ASTConcept.cpp:23
clang::ConstraintSatisfaction::Details
llvm::SmallVector< std::pair< const Expr *, Detail >, 4 > Details
Pairs of unsatisfied atomic constraint expressions along with the substituted constraint expr...
Definition: ASTConcept.h:53
TemplateBase.h
clang::ASTConstraintSatisfaction
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition: ASTConcept.h:77
clang::ASTConstraintSatisfaction::Create
static ASTConstraintSatisfaction * Create(const ASTContext &C, const ConstraintSatisfaction &Satisfaction)
Definition: ASTConcept.cpp:52
clang::AttrSyntax::C
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:223
ASTConcept.h
This file provides AST data structures related to concepts.