Coverage Report

Created: 2021-09-21 08:58

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/AST/AbstractBasicWriter.h
Line
Count
Source (jump to first uncovered line)
1
//==--- AbstractBasicWriter.h - Abstract basic value serialization --------===//
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
#ifndef CLANG_AST_ABSTRACTBASICWRITER_H
10
#define CLANG_AST_ABSTRACTBASICWRITER_H
11
12
#include "clang/AST/ASTContext.h"
13
#include "clang/AST/DeclTemplate.h"
14
15
namespace clang {
16
namespace serialization {
17
18
template <class T>
19
131k
inline llvm::Optional<T> makeOptionalFromNullable(const T &value) {
20
131k
  return (value.isNull()
21
131k
            ? 
llvm::Optional<T>()82
22
131k
            : 
llvm::Optional<T>(value)131k
);
23
131k
}
llvm::Optional<clang::QualType> clang::serialization::makeOptionalFromNullable<clang::QualType>(clang::QualType const&)
Line
Count
Source
19
131k
inline llvm::Optional<T> makeOptionalFromNullable(const T &value) {
20
131k
  return (value.isNull()
21
131k
            ? 
llvm::Optional<T>()82
22
131k
            : 
llvm::Optional<T>(value)131k
);
23
131k
}
llvm::Optional<clang::TemplateName> clang::serialization::makeOptionalFromNullable<clang::TemplateName>(clang::TemplateName const&)
Line
Count
Source
19
16
inline llvm::Optional<T> makeOptionalFromNullable(const T &value) {
20
16
  return (value.isNull()
21
16
            ? 
llvm::Optional<T>()0
22
16
            : llvm::Optional<T>(value));
23
16
}
24
25
template <class T>
26
217k
inline llvm::Optional<T*> makeOptionalFromPointer(T *value) {
27
217k
  return (value ? 
llvm::Optional<T*>(value)173k
:
llvm::Optional<T*>()44.4k
);
28
217k
}
llvm::Optional<clang::ConceptDecl const*> clang::serialization::makeOptionalFromPointer<clang::ConceptDecl const>(clang::ConceptDecl const*)
Line
Count
Source
26
454
inline llvm::Optional<T*> makeOptionalFromPointer(T *value) {
27
454
  return (value ? 
llvm::Optional<T*>(value)0
: llvm::Optional<T*>());
28
454
}
llvm::Optional<clang::IdentifierInfo const*> clang::serialization::makeOptionalFromPointer<clang::IdentifierInfo const>(clang::IdentifierInfo const*)
Line
Count
Source
26
30
inline llvm::Optional<T*> makeOptionalFromPointer(T *value) {
27
30
  return (value ? llvm::Optional<T*>(value) : 
llvm::Optional<T*>()0
);
28
30
}
llvm::Optional<clang::TagDecl const*> clang::serialization::makeOptionalFromPointer<clang::TagDecl const>(clang::TagDecl const*)
Line
Count
Source
26
72.0k
inline llvm::Optional<T*> makeOptionalFromPointer(T *value) {
27
72.0k
  return (value ? 
llvm::Optional<T*>(value)30.0k
:
llvm::Optional<T*>()41.9k
);
28
72.0k
}
llvm::Optional<clang::TemplateTypeParmDecl const*> clang::serialization::makeOptionalFromPointer<clang::TemplateTypeParmDecl const>(clang::TemplateTypeParmDecl const*)
Line
Count
Source
26
145k
inline llvm::Optional<T*> makeOptionalFromPointer(T *value) {
27
145k
  return (value ? 
llvm::Optional<T*>(value)143k
:
llvm::Optional<T*>()1.96k
);
28
145k
}
29
30
// PropertyWriter is a class concept that requires the following method:
31
//   BasicWriter find(llvm::StringRef propertyName);
32
// where BasicWriter is some class conforming to the BasicWriter concept.
33
// An abstract AST-node writer is created with a PropertyWriter and
34
// performs a sequence of calls like so:
35
//   propertyWriter.find(propertyName).write##TypeName(value)
36
// to write the properties of the node it is serializing.
37
38
// BasicWriter is a class concept that requires methods like:
39
//   void write##TypeName(ValueType value);
40
// where TypeName is the name of a PropertyType node from PropertiesBase.td
41
// and ValueType is the corresponding C++ type name.
42
//
43
// In addition to the concrete property types, BasicWriter is expected
44
// to implement these methods:
45
//
46
//   template <class EnumType>
47
//   void writeEnum(T value);
48
//
49
//     Writes an enum value as the current property.  EnumType will always
50
//     be an enum type.  Only necessary if the BasicWriter doesn't provide
51
//     type-specific writers for all the enum types.
52
//
53
//   template <class ValueType>
54
//   void writeOptional(Optional<ValueType> value);
55
//
56
//     Writes an optional value as the current property.
57
//
58
//   template <class ValueType>
59
//   void writeArray(ArrayRef<ValueType> value);
60
//
61
//     Writes an array of values as the current property.
62
//
63
//   PropertyWriter writeObject();
64
//
65
//     Writes an object as the current property; the returned property
66
//     writer will be subjected to a sequence of property writes and then
67
//     discarded before any other properties are written to the "outer"
68
//     property writer (which need not be the same type).  The sub-writer
69
//     will be used as if with the following code:
70
//
71
//       {
72
//         auto &&widget = W.find("widget").writeObject();
73
//         widget.find("kind").writeWidgetKind(...);
74
//         widget.find("declaration").writeDeclRef(...);
75
//       }
76
77
// WriteDispatcher is a template which does type-based forwarding to one
78
// of the write methods of the BasicWriter passed in:
79
//
80
// template <class ValueType>
81
// struct WriteDispatcher {
82
//   template <class BasicWriter>
83
//   static void write(BasicWriter &W, ValueType value);
84
// };
85
86
// BasicWriterBase provides convenience implementations of the write
87
// methods for EnumPropertyType and SubclassPropertyType types that just
88
// defer to the "underlying" implementations (for UInt32 and the base class,
89
// respectively).
90
//
91
// template <class Impl>
92
// class BasicWriterBase {
93
// protected:
94
//   Impl &asImpl();
95
// public:
96
//   ...
97
// };
98
99
// The actual classes are auto-generated; see ClangASTPropertiesEmitter.cpp.
100
#include "clang/AST/AbstractBasicWriter.inc"
101
102
/// DataStreamBasicWriter provides convenience implementations for many
103
/// BasicWriter methods based on the assumption that the
104
/// ultimate writer implementation is based on a variable-length stream
105
/// of unstructured data (like Clang's module files).  It is designed
106
/// to pair with DataStreamBasicReader.
107
///
108
/// This class can also act as a PropertyWriter, implementing find("...")
109
/// by simply forwarding to itself.
110
///
111
/// Unimplemented methods:
112
///   writeBool
113
///   writeUInt32
114
///   writeUInt64
115
///   writeIdentifier
116
///   writeSelector
117
///   writeSourceLocation
118
///   writeQualType
119
///   writeStmtRef
120
///   writeDeclRef
121
template <class Impl>
122
class DataStreamBasicWriter : public BasicWriterBase<Impl> {
123
protected:
124
  using BasicWriterBase<Impl>::asImpl;
125
10.0M
  DataStreamBasicWriter(ASTContext &ctx) : BasicWriterBase<Impl>(ctx) {}
126
127
public:
128
  /// Implement property-find by ignoring it.  We rely on properties being
129
  /// serialized and deserialized in a reliable order instead.
130
16.5M
  Impl &find(const char *propertyName) {
131
16.5M
    return asImpl();
132
16.5M
  }
133
134
  // Implement object writing by forwarding to this, collapsing the
135
  // structure into a single data stream.
136
4.27M
  Impl &writeObject() { return asImpl(); }
137
138
  template <class T>
139
5.19M
  void writeEnum(T value) {
140
5.19M
    asImpl().writeUInt32(uint32_t(value));
141
5.19M
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::ArrayType::ArraySizeModifier>(clang::ArrayType::ArraySizeModifier)
Line
Count
Source
139
16.2k
  void writeEnum(T value) {
140
16.2k
    asImpl().writeUInt32(uint32_t(value));
141
16.2k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::attr::Kind>(clang::attr::Kind)
Line
Count
Source
139
14.8k
  void writeEnum(T value) {
140
14.8k
    asImpl().writeUInt32(uint32_t(value));
141
14.8k
  }
Unexecuted instantiation: void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::BuiltinType::Kind>(clang::BuiltinType::Kind)
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::AutoTypeKeyword>(clang::AutoTypeKeyword)
Line
Count
Source
139
454
  void writeEnum(T value) {
140
454
    asImpl().writeUInt32(uint32_t(value));
141
454
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::TemplateArgument::ArgKind>(clang::TemplateArgument::ArgKind)
Line
Count
Source
139
722k
  void writeEnum(T value) {
140
722k
    asImpl().writeUInt32(uint32_t(value));
141
722k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::TemplateName::NameKind>(clang::TemplateName::NameKind)
Line
Count
Source
139
341k
  void writeEnum(T value) {
140
341k
    asImpl().writeUInt32(uint32_t(value));
141
341k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::DeclarationName::NameKind>(clang::DeclarationName::NameKind)
Line
Count
Source
139
3.20M
  void writeEnum(T value) {
140
3.20M
    asImpl().writeUInt32(uint32_t(value));
141
3.20M
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::NestedNameSpecifier::SpecifierKind>(clang::NestedNameSpecifier::SpecifierKind)
Line
Count
Source
139
95.5k
  void writeEnum(T value) {
140
95.5k
    asImpl().writeUInt32(uint32_t(value));
141
95.5k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::OverloadedOperatorKind>(clang::OverloadedOperatorKind)
Line
Count
Source
139
122k
  void writeEnum(T value) {
140
122k
    asImpl().writeUInt32(uint32_t(value));
141
122k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::ElaboratedTypeKeyword>(clang::ElaboratedTypeKeyword)
Line
Count
Source
139
135k
  void writeEnum(T value) {
140
135k
    asImpl().writeUInt32(uint32_t(value));
141
135k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::VectorType::VectorKind>(clang::VectorType::VectorKind)
Line
Count
Source
139
1.86k
  void writeEnum(T value) {
140
1.86k
    asImpl().writeUInt32(uint32_t(value));
141
1.86k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::CallingConv>(clang::CallingConv)
Line
Count
Source
139
267k
  void writeEnum(T value) {
140
267k
    asImpl().writeUInt32(uint32_t(value));
141
267k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::RefQualifierKind>(clang::RefQualifierKind)
Line
Count
Source
139
267k
  void writeEnum(T value) {
140
267k
    asImpl().writeUInt32(uint32_t(value));
141
267k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::UnaryTransformType::UTTKind>(clang::UnaryTransformType::UTTKind)
Line
Count
Source
139
78
  void writeEnum(T value) {
140
78
    asImpl().writeUInt32(uint32_t(value));
141
78
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::OpenMPDeviceClauseModifier>(clang::OpenMPDeviceClauseModifier)
Line
Count
Source
139
337
  void writeEnum(T value) {
140
337
    asImpl().writeUInt32(uint32_t(value));
141
337
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::OpenMPLastprivateModifier>(clang::OpenMPLastprivateModifier)
Line
Count
Source
139
442
  void writeEnum(T value) {
140
442
    asImpl().writeUInt32(uint32_t(value));
141
442
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::OpenMPOrderClauseKind>(clang::OpenMPOrderClauseKind)
Line
Count
Source
139
49
  void writeEnum(T value) {
140
49
    asImpl().writeUInt32(uint32_t(value));
141
49
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::OpenMPReductionClauseModifier>(clang::OpenMPReductionClauseModifier)
Line
Count
Source
139
936
  void writeEnum(T value) {
140
936
    asImpl().writeUInt32(uint32_t(value));
141
936
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::OpenMPDependClauseKind>(clang::OpenMPDependClauseKind)
Line
Count
Source
139
8
  void writeEnum(T value) {
140
8
    asImpl().writeUInt32(uint32_t(value));
141
8
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<llvm::omp::TraitSet>(llvm::omp::TraitSet)
Line
Count
Source
139
687
  void writeEnum(T value) {
140
687
    asImpl().writeUInt32(uint32_t(value));
141
687
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<llvm::omp::TraitSelector>(llvm::omp::TraitSelector)
Line
Count
Source
139
719
  void writeEnum(T value) {
140
719
    asImpl().writeUInt32(uint32_t(value));
141
719
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<llvm::omp::TraitProperty>(llvm::omp::TraitProperty)
Line
Count
Source
139
1.11k
  void writeEnum(T value) {
140
1.11k
    asImpl().writeUInt32(uint32_t(value));
141
1.11k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<clang::APValue::ValueKind>(clang::APValue::ValueKind)
Line
Count
Source
139
190
  void writeEnum(T value) {
140
190
    asImpl().writeUInt32(uint32_t(value));
141
190
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeEnum<llvm::omp::Directive>(llvm::omp::Directive)
Line
Count
Source
139
232
  void writeEnum(T value) {
140
232
    asImpl().writeUInt32(uint32_t(value));
141
232
  }
142
143
  template <class T>
144
888k
  void writeArray(llvm::ArrayRef<T> array) {
145
888k
    asImpl().writeUInt32(array.size());
146
1.11M
    for (const T &elt : array) {
147
1.11M
      WriteDispatcher<T>::write(asImpl(), elt);
148
1.11M
    }
149
888k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeArray<clang::TemplateArgument>(llvm::ArrayRef<clang::TemplateArgument>)
Line
Count
Source
144
348k
  void writeArray(llvm::ArrayRef<T> array) {
145
348k
    asImpl().writeUInt32(array.size());
146
585k
    for (const T &elt : array) {
147
585k
      WriteDispatcher<T>::write(asImpl(), elt);
148
585k
    }
149
348k
  }
Unexecuted instantiation: void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeArray<clang::NamedDecl const*>(llvm::ArrayRef<clang::NamedDecl const*>)
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeArray<clang::QualType>(llvm::ArrayRef<clang::QualType>)
Line
Count
Source
144
269k
  void writeArray(llvm::ArrayRef<T> array) {
145
269k
    asImpl().writeUInt32(array.size());
146
524k
    for (const T &elt : array) {
147
524k
      WriteDispatcher<T>::write(asImpl(), elt);
148
524k
    }
149
269k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeArray<clang::FunctionType::ExtParameterInfo>(llvm::ArrayRef<clang::FunctionType::ExtParameterInfo>)
Line
Count
Source
144
267k
  void writeArray(llvm::ArrayRef<T> array) {
145
267k
    asImpl().writeUInt32(array.size());
146
267k
    for (const T &elt : array) {
147
775
      WriteDispatcher<T>::write(asImpl(), elt);
148
775
    }
149
267k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeArray<clang::ObjCProtocolDecl const*>(llvm::ArrayRef<clang::ObjCProtocolDecl const*>)
Line
Count
Source
144
3.25k
  void writeArray(llvm::ArrayRef<T> array) {
145
3.25k
    asImpl().writeUInt32(array.size());
146
3.25k
    for (const T &elt : array) {
147
901
      WriteDispatcher<T>::write(asImpl(), elt);
148
901
    }
149
3.25k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeArray<clang::APValue>(llvm::ArrayRef<clang::APValue>)
Line
Count
Source
144
69
  void writeArray(llvm::ArrayRef<T> array) {
145
69
    asImpl().writeUInt32(array.size());
146
142
    for (const T &elt : array) {
147
142
      WriteDispatcher<T>::write(asImpl(), elt);
148
142
    }
149
69
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeArray<clang::CXXRecordDecl const*>(llvm::ArrayRef<clang::CXXRecordDecl const*>)
Line
Count
Source
144
6
  void writeArray(llvm::ArrayRef<T> array) {
145
6
    asImpl().writeUInt32(array.size());
146
6
    for (const T &elt : array) {
147
0
      WriteDispatcher<T>::write(asImpl(), elt);
148
0
    }
149
6
  }
150
151
  template <class T>
152
759k
  void writeOptional(llvm::Optional<T> value) {
153
759k
    WriteDispatcher<T>::write(asImpl(), PackOptionalValue<T>::pack(value));
154
759k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeOptional<clang::QualType>(llvm::Optional<clang::QualType>)
Line
Count
Source
152
532k
  void writeOptional(llvm::Optional<T> value) {
153
532k
    WriteDispatcher<T>::write(asImpl(), PackOptionalValue<T>::pack(value));
154
532k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeOptional<clang::ConceptDecl const*>(llvm::Optional<clang::ConceptDecl const*>)
Line
Count
Source
152
454
  void writeOptional(llvm::Optional<T> value) {
153
454
    WriteDispatcher<T>::write(asImpl(), PackOptionalValue<T>::pack(value));
154
454
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeOptional<clang::IdentifierInfo const*>(llvm::Optional<clang::IdentifierInfo const*>)
Line
Count
Source
152
30
  void writeOptional(llvm::Optional<T> value) {
153
30
    WriteDispatcher<T>::write(asImpl(), PackOptionalValue<T>::pack(value));
154
30
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeOptional<unsigned int>(llvm::Optional<unsigned int>)
Line
Count
Source
152
9.52k
  void writeOptional(llvm::Optional<T> value) {
153
9.52k
    WriteDispatcher<T>::write(asImpl(), PackOptionalValue<T>::pack(value));
154
9.52k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeOptional<clang::TemplateName>(llvm::Optional<clang::TemplateName>)
Line
Count
Source
152
16
  void writeOptional(llvm::Optional<T> value) {
153
16
    WriteDispatcher<T>::write(asImpl(), PackOptionalValue<T>::pack(value));
154
16
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeOptional<clang::TagDecl const*>(llvm::Optional<clang::TagDecl const*>)
Line
Count
Source
152
72.0k
  void writeOptional(llvm::Optional<T> value) {
153
72.0k
    WriteDispatcher<T>::write(asImpl(), PackOptionalValue<T>::pack(value));
154
72.0k
  }
void clang::serialization::DataStreamBasicWriter<clang::ASTRecordWriter>::writeOptional<clang::TemplateTypeParmDecl const*>(llvm::Optional<clang::TemplateTypeParmDecl const*>)
Line
Count
Source
152
145k
  void writeOptional(llvm::Optional<T> value) {
153
145k
    WriteDispatcher<T>::write(asImpl(), PackOptionalValue<T>::pack(value));
154
145k
  }
155
156
160k
  void writeAPSInt(const llvm::APSInt &value) {
157
160k
    asImpl().writeBool(value.isUnsigned());
158
160k
    asImpl().writeAPInt(value);
159
160k
  }
160
161
546k
  void writeAPInt(const llvm::APInt &value) {
162
546k
    asImpl().writeUInt32(value.getBitWidth());
163
546k
    const uint64_t *words = value.getRawData();
164
1.09M
    for (size_t i = 0, e = value.getNumWords(); i != e; 
++i546k
)
165
546k
      asImpl().writeUInt64(words[i]);
166
546k
  }
167
168
0
  void writeFixedPointSemantics(const llvm::FixedPointSemantics &sema) {
169
0
    asImpl().writeUInt32(sema.getWidth());
170
0
    asImpl().writeUInt32(sema.getScale());
171
0
    asImpl().writeUInt32(sema.isSigned() | sema.isSaturated() << 1 |
172
0
                         sema.hasUnsignedPadding() << 2);
173
0
  }
174
175
  void writeLValuePathSerializationHelper(
176
19
      APValue::LValuePathSerializationHelper lvaluePath) {
177
19
    ArrayRef<APValue::LValuePathEntry> path = lvaluePath.Path;
178
19
    QualType elemTy = lvaluePath.getType();
179
19
    asImpl().writeQualType(elemTy);
180
19
    asImpl().writeUInt32(path.size());
181
19
    auto &ctx = ((BasicWriterBase<Impl> *)this)->getASTContext();
182
19
    for (auto elem : path) {
183
15
      if (elemTy->getAs<RecordType>()) {
184
9
        asImpl().writeUInt32(elem.getAsBaseOrMember().getInt());
185
9
        const Decl *baseOrMember = elem.getAsBaseOrMember().getPointer();
186
9
        if (const auto *recordDecl = dyn_cast<CXXRecordDecl>(baseOrMember)) {
187
1
          asImpl().writeDeclRef(recordDecl);
188
1
          elemTy = ctx.getRecordType(recordDecl);
189
8
        } else {
190
8
          const auto *valueDecl = cast<ValueDecl>(baseOrMember);
191
8
          asImpl().writeDeclRef(valueDecl);
192
8
          elemTy = valueDecl->getType();
193
8
        }
194
9
      } else {
195
6
        asImpl().writeUInt32(elem.getAsArrayIndex());
196
6
        elemTy = ctx.getAsArrayType(elemTy)->getElementType();
197
6
      }
198
15
    }
199
19
  }
200
201
289k
  void writeQualifiers(Qualifiers value) {
202
289k
    static_assert(sizeof(value.getAsOpaqueValue()) <= sizeof(uint32_t),
203
289k
                  "update this if the value size changes");
204
289k
    asImpl().writeUInt32(value.getAsOpaqueValue());
205
289k
  }
206
207
  void writeExceptionSpecInfo(
208
267k
                        const FunctionProtoType::ExceptionSpecInfo &esi) {
209
267k
    asImpl().writeUInt32(uint32_t(esi.Type));
210
267k
    if (esi.Type == EST_Dynamic) {
211
3
      asImpl().writeArray(esi.Exceptions);
212
267k
    } else if (isComputedNoexcept(esi.Type)) {
213
7.09k
      asImpl().writeExprRef(esi.NoexceptExpr);
214
259k
    } else if (esi.Type == EST_Uninstantiated) {
215
1.12k
      asImpl().writeDeclRef(esi.SourceDecl);
216
1.12k
      asImpl().writeDeclRef(esi.SourceTemplate);
217
258k
    } else if (esi.Type == EST_Unevaluated) {
218
14.9k
      asImpl().writeDeclRef(esi.SourceDecl);
219
14.9k
    }
220
267k
  }
221
222
775
  void writeExtParameterInfo(FunctionProtoType::ExtParameterInfo epi) {
223
775
    static_assert(sizeof(epi.getOpaqueValue()) <= sizeof(uint32_t),
224
775
                  "opaque value doesn't fit into uint32_t");
225
775
    asImpl().writeUInt32(epi.getOpaqueValue());
226
775
  }
227
228
135k
  void writeNestedNameSpecifier(NestedNameSpecifier *NNS) {
229
    // Nested name specifiers usually aren't too long. I think that 8 would
230
    // typically accommodate the vast majority.
231
135k
    SmallVector<NestedNameSpecifier *, 8> nestedNames;
232
233
    // Push each of the NNS's onto a stack for serialization in reverse order.
234
230k
    while (NNS) {
235
95.5k
      nestedNames.push_back(NNS);
236
95.5k
      NNS = NNS->getPrefix();
237
95.5k
    }
238
239
135k
    asImpl().writeUInt32(nestedNames.size());
240
230k
    while (!nestedNames.empty()) {
241
95.5k
      NNS = nestedNames.pop_back_val();
242
95.5k
      NestedNameSpecifier::SpecifierKind kind = NNS->getKind();
243
95.5k
      asImpl().writeNestedNameSpecifierKind(kind);
244
95.5k
      switch (kind) {
245
624
      case NestedNameSpecifier::Identifier:
246
624
        asImpl().writeIdentifier(NNS->getAsIdentifier());
247
624
        continue;
248
249
5.75k
      case NestedNameSpecifier::Namespace:
250
5.75k
        asImpl().writeNamespaceDeclRef(NNS->getAsNamespace());
251
5.75k
        continue;
252
253
4
      case NestedNameSpecifier::NamespaceAlias:
254
4
        asImpl().writeNamespaceAliasDeclRef(NNS->getAsNamespaceAlias());
255
4
        continue;
256
257
89.1k
      case NestedNameSpecifier::TypeSpec:
258
89.1k
      case NestedNameSpecifier::TypeSpecWithTemplate:
259
89.1k
        asImpl().writeQualType(QualType(NNS->getAsType(), 0));
260
89.1k
        continue;
261
262
17
      case NestedNameSpecifier::Global:
263
        // Don't need to write an associated value.
264
17
        continue;
265
266
0
      case NestedNameSpecifier::Super:
267
0
        asImpl().writeDeclRef(NNS->getAsRecordDecl());
268
0
        continue;
269
95.5k
      }
270
0
      llvm_unreachable("bad nested name specifier kind");
271
0
    }
272
135k
  }
273
};
274
275
} // end namespace serialization
276
} // end namespace clang
277
278
#endif