 |
|
 |
|
| Files: |
1 |
|
Branches Taken: |
57.3% |
956 / 1668 |
| Generated: |
2010-02-10 01:31 |
|
Branches Executed: |
86.6% |
1444 / 1668 |
| |
|
Line Coverage: |
74.5% |
1459 / 1959 |
| |
 |
|
 |
1 : //===------- TreeTransform.h - Semantic Tree Transformation -----*- 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 : // This file implements a semantic tree transformation that takes a given
10 : // AST and rebuilds it, possibly transforming some nodes in the process.
11 : //
12 : //===----------------------------------------------------------------------===/
13 : #ifndef LLVM_CLANG_SEMA_TREETRANSFORM_H
14 : #define LLVM_CLANG_SEMA_TREETRANSFORM_H
15 :
16 : #include "Sema.h"
17 : #include "Lookup.h"
18 : #include "clang/Sema/SemaDiagnostic.h"
19 : #include "clang/AST/Decl.h"
20 : #include "clang/AST/Expr.h"
21 : #include "clang/AST/ExprCXX.h"
22 : #include "clang/AST/ExprObjC.h"
23 : #include "clang/AST/Stmt.h"
24 : #include "clang/AST/StmtCXX.h"
25 : #include "clang/AST/StmtObjC.h"
26 : #include "clang/AST/TypeLocBuilder.h"
27 : #include "clang/Parse/Ownership.h"
28 : #include "clang/Parse/Designator.h"
29 : #include "clang/Lex/Preprocessor.h"
30 : #include "llvm/Support/ErrorHandling.h"
31 : #include <algorithm>
32 :
33 : namespace clang {
34 :
35 : /// \brief A semantic tree transformation that allows one to transform one
36 : /// abstract syntax tree into another.
37 : ///
38 : /// A new tree transformation is defined by creating a new subclass \c X of
39 : /// \c TreeTransform<X> and then overriding certain operations to provide
40 : /// behavior specific to that transformation. For example, template
41 : /// instantiation is implemented as a tree transformation where the
42 : /// transformation of TemplateTypeParmType nodes involves substituting the
43 : /// template arguments for their corresponding template parameters; a similar
44 : /// transformation is performed for non-type template parameters and
45 : /// template template parameters.
46 : ///
47 : /// This tree-transformation template uses static polymorphism to allow
48 : /// subclasses to customize any of its operations. Thus, a subclass can
49 : /// override any of the transformation or rebuild operators by providing an
50 : /// operation with the same signature as the default implementation. The
51 : /// overridding function should not be virtual.
52 : ///
53 : /// Semantic tree transformations are split into two stages, either of which
54 : /// can be replaced by a subclass. The "transform" step transforms an AST node
55 : /// or the parts of an AST node using the various transformation functions,
56 : /// then passes the pieces on to the "rebuild" step, which constructs a new AST
57 : /// node of the appropriate kind from the pieces. The default transformation
58 : /// routines recursively transform the operands to composite AST nodes (e.g.,
59 : /// the pointee type of a PointerType node) and, if any of those operand nodes
60 : /// were changed by the transformation, invokes the rebuild operation to create
61 : /// a new AST node.
62 : ///
63 : /// Subclasses can customize the transformation at various levels. The
64 : /// most coarse-grained transformations involve replacing TransformType(),
65 : /// TransformExpr(), TransformDecl(), TransformNestedNameSpecifier(),
66 : /// TransformTemplateName(), or TransformTemplateArgument() with entirely
67 : /// new implementations.
68 : ///
69 : /// For more fine-grained transformations, subclasses can replace any of the
70 : /// \c TransformXXX functions (where XXX is the name of an AST node, e.g.,
71 : /// PointerType, StmtExpr) to alter the transformation. As mentioned previously,
72 : /// replacing TransformTemplateTypeParmType() allows template instantiation
73 : /// to substitute template arguments for their corresponding template
74 : /// parameters. Additionally, subclasses can override the \c RebuildXXX
75 : /// functions to control how AST nodes are rebuilt when their operands change.
76 : /// By default, \c TreeTransform will invoke semantic analysis to rebuild
77 : /// AST nodes. However, certain other tree transformations (e.g, cloning) may
78 : /// be able to use more efficient rebuild steps.
79 : ///
80 : /// There are a handful of other functions that can be overridden, allowing one
81 : /// to avoid traversing nodes that don't need any transformation
82 : /// (\c AlreadyTransformed()), force rebuilding AST nodes even when their
83 : /// operands have not changed (\c AlwaysRebuild()), and customize the
84 : /// default locations and entity names used for type-checking
85 : /// (\c getBaseLocation(), \c getBaseEntity()).
86 : template<typename Derived>
87 : class TreeTransform {
88 : protected:
89 : Sema &SemaRef;
90 :
91 : public:
92 : typedef Sema::OwningStmtResult OwningStmtResult;
93 : typedef Sema::OwningExprResult OwningExprResult;
94 : typedef Sema::StmtArg StmtArg;
95 : typedef Sema::ExprArg ExprArg;
96 : typedef Sema::MultiExprArg MultiExprArg;
97 : typedef Sema::MultiStmtArg MultiStmtArg;
98 : typedef Sema::DeclPtrTy DeclPtrTy;
99 :
100 : /// \brief Initializes a new tree transformer.
101 4192: TreeTransform(Sema &SemaRef) : SemaRef(SemaRef) { }
102 :
103 : /// \brief Retrieves a reference to the derived class.
104 64143: Derived &getDerived() { return static_cast<Derived&>(*this); }
105 :
106 : /// \brief Retrieves a reference to the derived class.
107 : const Derived &getDerived() const {
108 : return static_cast<const Derived&>(*this);
109 : }
110 :
111 : /// \brief Retrieves a reference to the semantic analysis object used for
112 : /// this tree transform.
113 11739: Sema &getSema() const { return SemaRef; }
114 :
115 : /// \brief Whether the transformation should always rebuild AST nodes, even
116 : /// if none of the children have changed.
117 : ///
118 : /// Subclasses may override this function to specify when the transformation
119 : /// should rebuild all AST nodes.
120 6697: bool AlwaysRebuild() { return false; }
121 :
122 : /// \brief Returns the location of the entity being transformed, if that
123 : /// information was not available elsewhere in the AST.
124 : ///
125 : /// By default, returns no source-location information. Subclasses can
126 : /// provide an alternative implementation that provides better location
127 : /// information.
128 : SourceLocation getBaseLocation() { return SourceLocation(); }
129 :
130 : /// \brief Returns the name of the entity being transformed, if that
131 : /// information was not available elsewhere in the AST.
132 : ///
133 : /// By default, returns an empty name. Subclasses can provide an alternative
134 : /// implementation with a more precise name.
135 : DeclarationName getBaseEntity() { return DeclarationName(); }
136 :
137 : /// \brief Sets the "base" location and entity when that
138 : /// information is known based on another transformation.
139 : ///
140 : /// By default, the source location and entity are ignored. Subclasses can
141 : /// override this function to provide a customized implementation.
142 : void setBase(SourceLocation Loc, DeclarationName Entity) { }
143 :
144 : /// \brief RAII object that temporarily sets the base location and entity
145 : /// used for reporting diagnostics in types.
146 : class TemporaryBase {
147 : TreeTransform &Self;
148 : SourceLocation OldLocation;
149 : DeclarationName OldEntity;
150 :
151 : public:
152 : TemporaryBase(TreeTransform &Self, SourceLocation Location,
153 1140: DeclarationName Entity) : Self(Self) {
154 1140: OldLocation = Self.getDerived().getBaseLocation();
155 1140: OldEntity = Self.getDerived().getBaseEntity();
156 1140: Self.getDerived().setBase(Location, Entity);
157 1140: }
158 :
159 1140: ~TemporaryBase() {
160 1140: Self.getDerived().setBase(OldLocation, OldEntity);
161 1140: }
162 : };
163 :
164 : /// \brief Determine whether the given type \p T has already been
165 : /// transformed.
166 : ///
167 : /// Subclasses can provide an alternative implementation of this routine
168 : /// to short-circuit evaluation when it is known that a given type will
169 : /// not change. For example, template instantiation need not traverse
170 : /// non-dependent types.
171 : bool AlreadyTransformed(QualType T) {
172 : return T.isNull();
173 : }
174 :
175 : /// \brief Determine whether the given call argument should be dropped, e.g.,
176 : /// because it is a default argument.
177 : ///
178 : /// Subclasses can provide an alternative implementation of this routine to
179 : /// determine which kinds of call arguments get dropped. By default,
180 : /// CXXDefaultArgument nodes are dropped (prior to transformation).
181 11: bool DropCallArgument(Expr *E) {
182 11: return E->isDefaultArgument();
183 : }
184 :
185 : /// \brief Transforms the given type into another type.
186 : ///
187 : /// By default, this routine transforms a type by creating a
188 : /// TypeSourceInfo for it and delegating to the appropriate
189 : /// function. This is expensive, but we don't mind, because
190 : /// this method is deprecated anyway; all users should be
191 : /// switched to storing TypeSourceInfos.
192 : ///
193 : /// \returns the transformed type.
194 : QualType TransformType(QualType T);
195 :
196 : /// \brief Transforms the given type-with-location into a new
197 : /// type-with-location.
198 : ///
199 : /// By default, this routine transforms a type by delegating to the
200 : /// appropriate TransformXXXType to build a new type. Subclasses
201 : /// may override this function (to take over all type
202 : /// transformations) or some set of the TransformXXXType functions
203 : /// to alter the transformation.
204 : TypeSourceInfo *TransformType(TypeSourceInfo *DI);
205 :
206 : /// \brief Transform the given type-with-location into a new
207 : /// type, collecting location information in the given builder
208 : /// as necessary.
209 : ///
210 : QualType TransformType(TypeLocBuilder &TLB, TypeLoc TL);
211 :
212 : /// \brief Transform the given statement.
213 : ///
214 : /// By default, this routine transforms a statement by delegating to the
215 : /// appropriate TransformXXXStmt function to transform a specific kind of
216 : /// statement or the TransformExpr() function to transform an expression.
217 : /// Subclasses may override this function to transform statements using some
218 : /// other mechanism.
219 : ///
220 : /// \returns the transformed statement.
221 : OwningStmtResult TransformStmt(Stmt *S);
222 :
223 : /// \brief Transform the given expression.
224 : ///
225 : /// By default, this routine transforms an expression by delegating to the
226 : /// appropriate TransformXXXExpr function to build a new expression.
227 : /// Subclasses may override this function to transform expressions using some
228 : /// other mechanism.
229 : ///
230 : /// \returns the transformed expression.
231 : OwningExprResult TransformExpr(Expr *E);
232 :
233 : /// \brief Transform the given declaration, which is referenced from a type
234 : /// or expression.
235 : ///
236 : /// By default, acts as the identity function on declarations. Subclasses
237 : /// may override this function to provide alternate behavior.
238 13: Decl *TransformDecl(Decl *D) { return D; }
239 :
240 : /// \brief Transform the definition of the given declaration.
241 : ///
242 : /// By default, invokes TransformDecl() to transform the declaration.
243 : /// Subclasses may override this function to provide alternate behavior.
244 : Decl *TransformDefinition(Decl *D) { return getDerived().TransformDecl(D); }
245 :
246 : /// \brief Transform the given declaration, which was the first part of a
247 : /// nested-name-specifier in a member access expression.
248 : ///
249 : /// This specific declaration transformation only applies to the first
250 : /// identifier in a nested-name-specifier of a member access expression, e.g.,
251 : /// the \c T in \c x->T::member
252 : ///
253 : /// By default, invokes TransformDecl() to transform the declaration.
254 : /// Subclasses may override this function to provide alternate behavior.
255 : NamedDecl *TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc) {
256 : return cast_or_null<NamedDecl>(getDerived().TransformDecl(D));
257 : }
258 :
259 : /// \brief Transform the given nested-name-specifier.
260 : ///
261 : /// By default, transforms all of the types and declarations within the
262 : /// nested-name-specifier. Subclasses may override this function to provide
263 : /// alternate behavior.
264 : NestedNameSpecifier *TransformNestedNameSpecifier(NestedNameSpecifier *NNS,
265 : SourceRange Range,
266 : QualType ObjectType = QualType(),
267 : NamedDecl *FirstQualifierInScope = 0);
268 :
269 : /// \brief Transform the given declaration name.
270 : ///
271 : /// By default, transforms the types of conversion function, constructor,
272 : /// and destructor names and then (if needed) rebuilds the declaration name.
273 : /// Identifiers and selectors are returned unmodified. Sublcasses may
274 : /// override this function to provide alternate behavior.
275 : DeclarationName TransformDeclarationName(DeclarationName Name,
276 : SourceLocation Loc,
277 : QualType ObjectType = QualType());
278 :
279 : /// \brief Transform the given template name.
280 : ///
281 : /// By default, transforms the template name by transforming the declarations
282 : /// and nested-name-specifiers that occur within the template name.
283 : /// Subclasses may override this function to provide alternate behavior.
284 : TemplateName TransformTemplateName(TemplateName Name,
285 : QualType ObjectType = QualType());
286 :
287 : /// \brief Transform the given template argument.
288 : ///
289 : /// By default, this operation transforms the type, expression, or
290 : /// declaration stored within the template argument and constructs a
291 : /// new template argument from the transformed result. Subclasses may
292 : /// override this function to provide alternate behavior.
293 : ///
294 : /// Returns true if there was an error.
295 : bool TransformTemplateArgument(const TemplateArgumentLoc &Input,
296 : TemplateArgumentLoc &Output);
297 :
298 : /// \brief Fakes up a TemplateArgumentLoc for a given TemplateArgument.
299 : void InventTemplateArgumentLoc(const TemplateArgument &Arg,
300 : TemplateArgumentLoc &ArgLoc);
301 :
302 : /// \brief Fakes up a TypeSourceInfo for a type.
303 737: TypeSourceInfo *InventTypeSourceInfo(QualType T) {
304 : return SemaRef.Context.getTrivialTypeSourceInfo(T,
305 737: getDerived().getBaseLocation());
306 : }
307 :
308 : #define ABSTRACT_TYPELOC(CLASS, PARENT)
309 : #define TYPELOC(CLASS, PARENT) \
310 : QualType Transform##CLASS##Type(TypeLocBuilder &TLB, CLASS##TypeLoc T);
311 : #include "clang/AST/TypeLocNodes.def"
312 :
313 : QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL);
314 :
315 : QualType
316 : TransformTemplateSpecializationType(const TemplateSpecializationType *T,
317 : QualType ObjectType);
318 :
319 : QualType
320 : TransformTemplateSpecializationType(TypeLocBuilder &TLB,
321 : TemplateSpecializationTypeLoc TL,
322 : QualType ObjectType);
323 :
324 : OwningStmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr);
325 :
326 : #define STMT(Node, Parent) \
327 : OwningStmtResult Transform##Node(Node *S);
328 : #define EXPR(Node, Parent) \
329 : OwningExprResult Transform##Node(Node *E);
330 : #define ABSTRACT_EXPR(Node, Parent)
331 : #include "clang/AST/StmtNodes.def"
332 :
333 : /// \brief Build a new pointer type given its pointee type.
334 : ///
335 : /// By default, performs semantic analysis when building the pointer type.
336 : /// Subclasses may override this routine to provide different behavior.
337 : QualType RebuildPointerType(QualType PointeeType, SourceLocation Sigil);
338 :
339 : /// \brief Build a new block pointer type given its pointee type.
340 : ///
341 : /// By default, performs semantic analysis when building the block pointer
342 : /// type. Subclasses may override this routine to provide different behavior.
343 : QualType RebuildBlockPointerType(QualType PointeeType, SourceLocation Sigil);
344 :
345 : /// \brief Build a new reference type given the type it references.
346 : ///
347 : /// By default, performs semantic analysis when building the
348 : /// reference type. Subclasses may override this routine to provide
349 : /// different behavior.
350 : ///
351 : /// \param LValue whether the type was written with an lvalue sigil
352 : /// or an rvalue sigil.
353 : QualType RebuildReferenceType(QualType ReferentType,
354 : bool LValue,
355 : SourceLocation Sigil);
356 :
357 : /// \brief Build a new member pointer type given the pointee type and the
358 : /// class type it refers into.
359 : ///
360 : /// By default, performs semantic analysis when building the member pointer
361 : /// type. Subclasses may override this routine to provide different behavior.
362 : QualType RebuildMemberPointerType(QualType PointeeType, QualType ClassType,
363 : SourceLocation Sigil);
364 :
365 : /// \brief Build a new Objective C object pointer type.
366 : QualType RebuildObjCObjectPointerType(QualType PointeeType,
367 : SourceLocation Sigil);
368 :
369 : /// \brief Build a new array type given the element type, size
370 : /// modifier, size of the array (if known), size expression, and index type
371 : /// qualifiers.
372 : ///
373 : /// By default, performs semantic analysis when building the array type.
374 : /// Subclasses may override this routine to provide different behavior.
375 : /// Also by default, all of the other Rebuild*Array
376 : QualType RebuildArrayType(QualType ElementType,
377 : ArrayType::ArraySizeModifier SizeMod,
378 : const llvm::APInt *Size,
379 : Expr *SizeExpr,
380 : unsigned IndexTypeQuals,
381 : SourceRange BracketsRange);
382 :
383 : /// \brief Build a new constant array type given the element type, size
384 : /// modifier, (known) size of the array, and index type qualifiers.
385 : ///
386 : /// By default, performs semantic analysis when building the array type.
387 : /// Subclasses may override this routine to provide different behavior.
388 : QualType RebuildConstantArrayType(QualType ElementType,
389 : ArrayType::ArraySizeModifier SizeMod,
390 : const llvm::APInt &Size,
391 : unsigned IndexTypeQuals,
392 : SourceRange BracketsRange);
393 :
394 : /// \brief Build a new incomplete array type given the element type, size
395 : /// modifier, and index type qualifiers.
396 : ///
397 : /// By default, performs semantic analysis when building the array type.
398 : /// Subclasses may override this routine to provide different behavior.
399 : QualType RebuildIncompleteArrayType(QualType ElementType,
400 : ArrayType::ArraySizeModifier SizeMod,
401 : unsigned IndexTypeQuals,
402 : SourceRange BracketsRange);
403 :
404 : /// \brief Build a new variable-length array type given the element type,
405 : /// size modifier, size expression, and index type qualifiers.
406 : ///
407 : /// By default, performs semantic analysis when building the array type.
408 : /// Subclasses may override this routine to provide different behavior.
409 : QualType RebuildVariableArrayType(QualType ElementType,
410 : ArrayType::ArraySizeModifier SizeMod,
411 : ExprArg SizeExpr,
412 : unsigned IndexTypeQuals,
413 : SourceRange BracketsRange);
414 :
415 : /// \brief Build a new dependent-sized array type given the element type,
416 : /// size modifier, size expression, and index type qualifiers.
417 : ///
418 : /// By default, performs semantic analysis when building the array type.
419 : /// Subclasses may override this routine to provide different behavior.
420 : QualType RebuildDependentSizedArrayType(QualType ElementType,
421 : ArrayType::ArraySizeModifier SizeMod,
422 : ExprArg SizeExpr,
423 : unsigned IndexTypeQuals,
424 : SourceRange BracketsRange);
425 :
426 : /// \brief Build a new vector type given the element type and
427 : /// number of elements.
428 : ///
429 : /// By default, performs semantic analysis when building the vector type.
430 : /// Subclasses may override this routine to provide different behavior.
431 : QualType RebuildVectorType(QualType ElementType, unsigned NumElements,
432 : bool IsAltiVec, bool IsPixel);
433 :
434 : /// \brief Build a new extended vector type given the element type and
435 : /// number of elements.
436 : ///
437 : /// By default, performs semantic analysis when building the vector type.
438 : /// Subclasses may override this routine to provide different behavior.
439 : QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements,
440 : SourceLocation AttributeLoc);
441 :
442 : /// \brief Build a new potentially dependently-sized extended vector type
443 : /// given the element type and number of elements.
444 : ///
445 : /// By default, performs semantic analysis when building the vector type.
446 : /// Subclasses may override this routine to provide different behavior.
447 : QualType RebuildDependentSizedExtVectorType(QualType ElementType,
448 : ExprArg SizeExpr,
449 : SourceLocation AttributeLoc);
450 :
451 : /// \brief Build a new function type.
452 : ///
453 : /// By default, performs semantic analysis when building the function type.
454 : /// Subclasses may override this routine to provide different behavior.
455 : QualType RebuildFunctionProtoType(QualType T,
456 : QualType *ParamTypes,
457 : unsigned NumParamTypes,
458 : bool Variadic, unsigned Quals);
459 :
460 : /// \brief Build a new unprototyped function type.
461 : QualType RebuildFunctionNoProtoType(QualType ResultType);
462 :
463 : /// \brief Rebuild an unresolved typename type, given the decl that
464 : /// the UnresolvedUsingTypenameDecl was transformed to.
465 : QualType RebuildUnresolvedUsingType(Decl *D);
466 :
467 : /// \brief Build a new typedef type.
468 66: QualType RebuildTypedefType(TypedefDecl *Typedef) {
469 66: return SemaRef.Context.getTypeDeclType(Typedef);
470 : }
471 :
472 : /// \brief Build a new class/struct/union type.
473 38: QualType RebuildRecordType(RecordDecl *Record) {
474 38: return SemaRef.Context.getTypeDeclType(Record);
475 : }
476 :
477 : /// \brief Build a new Enum type.
478 11: QualType RebuildEnumType(EnumDecl *Enum) {
479 11: return SemaRef.Context.getTypeDeclType(Enum);
480 : }
481 :
482 : /// \brief Build a new elaborated type.
483 23: QualType RebuildElaboratedType(QualType T, ElaboratedType::TagKind Tag) {
484 23: return SemaRef.Context.getElaboratedType(T, Tag);
485 : }
486 :
487 : /// \brief Build a new typeof(expr) type.
488 : ///
489 : /// By default, performs semantic analysis when building the typeof type.
490 : /// Subclasses may override this routine to provide different behavior.
491 : QualType RebuildTypeOfExprType(ExprArg Underlying);
492 :
493 : /// \brief Build a new typeof(type) type.
494 : ///
495 : /// By default, builds a new TypeOfType with the given underlying type.
496 : QualType RebuildTypeOfType(QualType Underlying);
497 :
498 : /// \brief Build a new C++0x decltype type.
499 : ///
500 : /// By default, performs semantic analysis when building the decltype type.
501 : /// Subclasses may override this routine to provide different behavior.
502 : QualType RebuildDecltypeType(ExprArg Underlying);
503 :
504 : /// \brief Build a new template specialization type.
505 : ///
506 : /// By default, performs semantic analysis when building the template
507 : /// specialization type. Subclasses may override this routine to provide
508 : /// different behavior.
509 : QualType RebuildTemplateSpecializationType(TemplateName Template,
510 : SourceLocation TemplateLoc,
511 : const TemplateArgumentListInfo &Args);
512 :
513 : /// \brief Build a new qualified name type.
514 : ///
515 : /// By default, builds a new QualifiedNameType type from the
516 : /// nested-name-specifier and the named type. Subclasses may override
517 : /// this routine to provide different behavior.
518 0: QualType RebuildQualifiedNameType(NestedNameSpecifier *NNS, QualType Named) {
519 0: return SemaRef.Context.getQualifiedNameType(NNS, Named);
520 : }
521 :
522 : /// \brief Build a new typename type that refers to a template-id.
523 : ///
524 : /// By default, builds a new TypenameType type from the nested-name-specifier
525 : /// and the given type. Subclasses may override this routine to provide
526 : /// different behavior.
527 5: QualType RebuildTypenameType(NestedNameSpecifier *NNS, QualType T) {
0: branch 1 not taken
5: branch 2 taken
528 5: if (NNS->isDependent())
529 : return SemaRef.Context.getTypenameType(NNS,
530 0: cast<TemplateSpecializationType>(T));
531 :
532 5: return SemaRef.Context.getQualifiedNameType(NNS, T);
533 : }
534 :
535 : /// \brief Build a new typename type that refers to an identifier.
536 : ///
537 : /// By default, performs semantic analysis when building the typename type
538 : /// (or qualified name type). Subclasses may override this routine to provide
539 : /// different behavior.
540 : QualType RebuildTypenameType(NestedNameSpecifier *NNS,
541 : const IdentifierInfo *Id,
542 133: SourceRange SR) {
543 133: return SemaRef.CheckTypenameType(NNS, *Id, SR);
544 : }
545 :
546 : /// \brief Build a new nested-name-specifier given the prefix and an
547 : /// identifier that names the next step in the nested-name-specifier.
548 : ///
549 : /// By default, performs semantic analysis when building the new
550 : /// nested-name-specifier. Subclasses may override this routine to provide
551 : /// different behavior.
552 : NestedNameSpecifier *RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix,
553 : SourceRange Range,
554 : IdentifierInfo &II,
555 : QualType ObjectType,
556 : NamedDecl *FirstQualifierInScope);
557 :
558 : /// \brief Build a new nested-name-specifier given the prefix and the
559 : /// namespace named in the next step in the nested-name-specifier.
560 : ///
561 : /// By default, performs semantic analysis when building the new
562 : /// nested-name-specifier. Subclasses may override this routine to provide
563 : /// different behavior.
564 : NestedNameSpecifier *RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix,
565 : SourceRange Range,
566 : NamespaceDecl *NS);
567 :
568 : /// \brief Build a new nested-name-specifier given the prefix and the
569 : /// type named in the next step in the nested-name-specifier.
570 : ///
571 : /// By default, performs semantic analysis when building the new
572 : /// nested-name-specifier. Subclasses may override this routine to provide
573 : /// different behavior.
574 : NestedNameSpecifier *RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix,
575 : SourceRange Range,
576 : bool TemplateKW,
577 : QualType T);
578 :
579 : /// \brief Build a new template name given a nested name specifier, a flag
580 : /// indicating whether the "template" keyword was provided, and the template
581 : /// that the template name refers to.
582 : ///
583 : /// By default, builds the new template name directly. Subclasses may override
584 : /// this routine to provide different behavior.
585 : TemplateName RebuildTemplateName(NestedNameSpecifier *Qualifier,
586 : bool TemplateKW,
587 : TemplateDecl *Template);
588 :
589 : /// \brief Build a new template name given a nested name specifier and the
590 : /// name that is referred to as a template.
591 : ///
592 : /// By default, performs semantic analysis to determine whether the name can
593 : /// be resolved to a specific template, then builds the appropriate kind of
594 : /// template name. Subclasses may override this routine to provide different
595 : /// behavior.
596 : TemplateName RebuildTemplateName(NestedNameSpecifier *Qualifier,
597 : const IdentifierInfo &II,
598 : QualType ObjectType);
599 :
600 : /// \brief Build a new template name given a nested name specifier and the
601 : /// overloaded operator name that is referred to as a template.
602 : ///
603 : /// By default, performs semantic analysis to determine whether the name can
604 : /// be resolved to a specific template, then builds the appropriate kind of
605 : /// template name. Subclasses may override this routine to provide different
606 : /// behavior.
607 : TemplateName RebuildTemplateName(NestedNameSpecifier *Qualifier,
608 : OverloadedOperatorKind Operator,
609 : QualType ObjectType);
610 :
611 : /// \brief Build a new compound statement.
612 : ///
613 : /// By default, performs semantic analysis to build the new statement.
614 : /// Subclasses may override this routine to provide different behavior.
615 : OwningStmtResult RebuildCompoundStmt(SourceLocation LBraceLoc,
616 : MultiStmtArg Statements,
617 : SourceLocation RBraceLoc,
618 329: bool IsStmtExpr) {
619 : return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, move(Statements),
620 329: IsStmtExpr);
621 : }
622 :
623 : /// \brief Build a new case statement.
624 : ///
625 : /// By default, performs semantic analysis to build the new statement.
626 : /// Subclasses may override this routine to provide different behavior.
627 : OwningStmtResult RebuildCaseStmt(SourceLocation CaseLoc,
628 : ExprArg LHS,
629 : SourceLocation EllipsisLoc,
630 : ExprArg RHS,
631 19: SourceLocation ColonLoc) {
632 : return getSema().ActOnCaseStmt(CaseLoc, move(LHS), EllipsisLoc, move(RHS),
633 19: ColonLoc);
634 : }
635 :
636 : /// \brief Attach the body to a new case statement.
637 : ///
638 : /// By default, performs semantic analysis to build the new statement.
639 : /// Subclasses may override this routine to provide different behavior.
640 19: OwningStmtResult RebuildCaseStmtBody(StmtArg S, StmtArg Body) {
641 19: getSema().ActOnCaseStmtBody(S.get(), move(Body));
642 19: return move(S);
643 : }
644 :
645 : /// \brief Build a new default statement.
646 : ///
647 : /// By default, performs semantic analysis to build the new statement.
648 : /// Subclasses may override this routine to provide different behavior.
649 : OwningStmtResult RebuildDefaultStmt(SourceLocation DefaultLoc,
650 : SourceLocation ColonLoc,
651 3: StmtArg SubStmt) {
652 : return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, move(SubStmt),
653 3: /*CurScope=*/0);
654 : }
655 :
656 : /// \brief Build a new label statement.
657 : ///
658 : /// By default, performs semantic analysis to build the new statement.
659 : /// Subclasses may override this routine to provide different behavior.
660 : OwningStmtResult RebuildLabelStmt(SourceLocation IdentLoc,
661 : IdentifierInfo *Id,
662 : SourceLocation ColonLoc,
663 3: StmtArg SubStmt) {
664 3: return SemaRef.ActOnLabelStmt(IdentLoc, Id, ColonLoc, move(SubStmt));
665 : }
666 :
667 : /// \brief Build a new "if" statement.
668 : ///
669 : /// By default, performs semantic analysis to build the new statement.
670 : /// Subclasses may override this routine to provide different behavior.
671 : OwningStmtResult RebuildIfStmt(SourceLocation IfLoc, Sema::FullExprArg Cond,
672 : VarDecl *CondVar, StmtArg Then,
673 18: SourceLocation ElseLoc, StmtArg Else) {
674 : return getSema().ActOnIfStmt(IfLoc, Cond, DeclPtrTy::make(CondVar),
675 18: move(Then), ElseLoc, move(Else));
676 : }
677 :
678 : /// \brief Start building a new switch statement.
679 : ///
680 : /// By default, performs semantic analysis to build the new statement.
681 : /// Subclasses may override this routine to provide different behavior.
682 : OwningStmtResult RebuildSwitchStmtStart(Sema::FullExprArg Cond,
683 5: VarDecl *CondVar) {
684 5: return getSema().ActOnStartOfSwitchStmt(Cond, DeclPtrTy::make(CondVar));
685 : }
686 :
687 : /// \brief Attach the body to the switch statement.
688 : ///
689 : /// By default, performs semantic analysis to build the new statement.
690 : /// Subclasses may override this routine to provide different behavior.
691 : OwningStmtResult RebuildSwitchStmtBody(SourceLocation SwitchLoc,
692 5: StmtArg Switch, StmtArg Body) {
693 : return getSema().ActOnFinishSwitchStmt(SwitchLoc, move(Switch),
694 5: move(Body));
695 : }
696 :
697 : /// \brief Build a new while statement.
698 : ///
699 : /// By default, performs semantic analysis to build the new statement.
700 : /// Subclasses may override this routine to provide different behavior.
701 : OwningStmtResult RebuildWhileStmt(SourceLocation WhileLoc,
702 : Sema::FullExprArg Cond,
703 : VarDecl *CondVar,
704 2: StmtArg Body) {
705 : return getSema().ActOnWhileStmt(WhileLoc, Cond, DeclPtrTy::make(CondVar),
706 2: move(Body));
707 : }
708 :
709 : /// \brief Build a new do-while statement.
710 : ///
711 : /// By default, performs semantic analysis to build the new statement.
712 : /// Subclasses may override this routine to provide different behavior.
713 : OwningStmtResult RebuildDoStmt(SourceLocation DoLoc, StmtArg Body,
714 : SourceLocation WhileLoc,
715 : SourceLocation LParenLoc,
716 : ExprArg Cond,
717 2: SourceLocation RParenLoc) {
718 : return getSema().ActOnDoStmt(DoLoc, move(Body), WhileLoc, LParenLoc,
719 2: move(Cond), RParenLoc);
720 : }
721 :
722 : /// \brief Build a new for statement.
723 : ///
724 : /// By default, performs semantic analysis to build the new statement.
725 : /// Subclasses may override this routine to provide different behavior.
726 : OwningStmtResult RebuildForStmt(SourceLocation ForLoc,
727 : SourceLocation LParenLoc,
728 : StmtArg Init, Sema::FullExprArg Cond,
729 : VarDecl *CondVar, Sema::FullExprArg Inc,
730 14: SourceLocation RParenLoc, StmtArg Body) {
731 : return getSema().ActOnForStmt(ForLoc, LParenLoc, move(Init), Cond,
732 : DeclPtrTy::make(CondVar),
733 14: Inc, RParenLoc, move(Body));
734 : }
735 :
736 : /// \brief Build a new goto statement.
737 : ///
738 : /// By default, performs semantic analysis to build the new statement.
739 : /// Subclasses may override this routine to provide different behavior.
740 : OwningStmtResult RebuildGotoStmt(SourceLocation GotoLoc,
741 : SourceLocation LabelLoc,
742 1: LabelStmt *Label) {
743 1: return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label->getID());
744 : }
745 :
746 : /// \brief Build a new indirect goto statement.
747 : ///
748 : /// By default, performs semantic analysis to build the new statement.
749 : /// Subclasses may override this routine to provide different behavior.
750 : OwningStmtResult RebuildIndirectGotoStmt(SourceLocation GotoLoc,
751 : SourceLocation StarLoc,
752 2: ExprArg Target) {
753 2: return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, move(Target));
754 : }
755 :
756 : /// \brief Build a new return statement.
757 : ///
758 : /// By default, performs semantic analysis to build the new statement.
759 : /// Subclasses may override this routine to provide different behavior.
760 : OwningStmtResult RebuildReturnStmt(SourceLocation ReturnLoc,
761 133: ExprArg Result) {
762 :
763 133: return getSema().ActOnReturnStmt(ReturnLoc, move(Result));
764 : }
765 :
766 : /// \brief Build a new declaration statement.
767 : ///
768 : /// By default, performs semantic analysis to build the new statement.
769 : /// Subclasses may override this routine to provide different behavior.
770 : OwningStmtResult RebuildDeclStmt(Decl **Decls, unsigned NumDecls,
771 : SourceLocation StartLoc,
772 174: SourceLocation EndLoc) {
773 : return getSema().Owned(
774 : new (getSema().Context) DeclStmt(
775 : DeclGroupRef::Create(getSema().Context,
776 : Decls, NumDecls),
174: branch 4 taken
0: branch 5 not taken
777 174: StartLoc, EndLoc));
778 : }
779 :
780 : /// \brief Build a new inline asm statement.
781 : ///
782 : /// By default, performs semantic analysis to build the new statement.
783 : /// Subclasses may override this routine to provide different behavior.
784 : OwningStmtResult RebuildAsmStmt(SourceLocation AsmLoc,
785 : bool IsSimple,
786 : bool IsVolatile,
787 : unsigned NumOutputs,
788 : unsigned NumInputs,
789 : IdentifierInfo **Names,
790 : MultiExprArg Constraints,
791 : MultiExprArg Exprs,
792 : ExprArg AsmString,
793 : MultiExprArg Clobbers,
794 : SourceLocation RParenLoc,
795 1: bool MSAsm) {
796 : return getSema().ActOnAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs,
797 : NumInputs, Names, move(Constraints),
798 : move(Exprs), move(AsmString), move(Clobbers),
799 1: RParenLoc, MSAsm);
800 : }
801 :
802 : /// \brief Build a new C++ exception declaration.
803 : ///
804 : /// By default, performs semantic analysis to build the new decaration.
805 : /// Subclasses may override this routine to provide different behavior.
806 : VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl, QualType T,
807 : TypeSourceInfo *Declarator,
808 : IdentifierInfo *Name,
809 : SourceLocation Loc,
810 6: SourceRange TypeRange) {
811 : return getSema().BuildExceptionDeclaration(0, T, Declarator, Name, Loc,
812 6: TypeRange);
813 : }
814 :
815 : /// \brief Build a new C++ catch statement.
816 : ///
817 : /// By default, performs semantic analysis to build the new statement.
818 : /// Subclasses may override this routine to provide different behavior.
819 : OwningStmtResult RebuildCXXCatchStmt(SourceLocation CatchLoc,
820 : VarDecl *ExceptionDecl,
821 2: StmtArg Handler) {
822 : return getSema().Owned(
823 : new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
2: branch 3 taken
0: branch 4 not taken
824 2: Handler.takeAs<Stmt>()));
825 : }
826 :
827 : /// \brief Build a new C++ try statement.
828 : ///
829 : /// By default, performs semantic analysis to build the new statement.
830 : /// Subclasses may override this routine to provide different behavior.
831 : OwningStmtResult RebuildCXXTryStmt(SourceLocation TryLoc,
832 : StmtArg TryBlock,
833 2: MultiStmtArg Handlers) {
834 2: return getSema().ActOnCXXTryBlock(TryLoc, move(TryBlock), move(Handlers));
835 : }
836 :
837 : /// \brief Build a new expression that references a declaration.
838 : ///
839 : /// By default, performs semantic analysis to build the new expression.
840 : /// Subclasses may override this routine to provide different behavior.
841 : OwningExprResult RebuildDeclarationNameExpr(const CXXScopeSpec &SS,
842 : LookupResult &R,
843 93: bool RequiresADL) {
844 93: return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL);
845 : }
846 :
847 :
848 : /// \brief Build a new expression that references a declaration.
849 : ///
850 : /// By default, performs semantic analysis to build the new expression.
851 : /// Subclasses may override this routine to provide different behavior.
852 : OwningExprResult RebuildDeclRefExpr(NestedNameSpecifier *Qualifier,
853 : SourceRange QualifierRange,
854 : ValueDecl *VD, SourceLocation Loc,
855 525: TemplateArgumentListInfo *TemplateArgs) {
856 525: CXXScopeSpec SS;
857 525: SS.setScopeRep(Qualifier);
858 525: SS.setRange(QualifierRange);
859 :
860 : // FIXME: loses template args.
861 :
862 525: return getSema().BuildDeclarationNameExpr(SS, Loc, VD);
863 : }
864 :
865 : /// \brief Build a new expression in parentheses.
866 : ///
867 : /// By default, performs semantic analysis to build the new expression.
868 : /// Subclasses may override this routine to provide different behavior.
869 : OwningExprResult RebuildParenExpr(ExprArg SubExpr, SourceLocation LParen,
870 56: SourceLocation RParen) {
871 56: return getSema().ActOnParenExpr(LParen, RParen, move(SubExpr));
872 : }
873 :
874 : /// \brief Build a new pseudo-destructor expression.
875 : ///
876 : /// By default, performs semantic analysis to build the new expression.
877 : /// Subclasses may override this routine to provide different behavior.
878 : OwningExprResult RebuildCXXPseudoDestructorExpr(ExprArg Base,
879 : SourceLocation OperatorLoc,
880 : bool isArrow,
881 : SourceLocation DestroyedTypeLoc,
882 : QualType DestroyedType,
883 : NestedNameSpecifier *Qualifier,
884 0: SourceRange QualifierRange) {
885 0: CXXScopeSpec SS;
0: branch 0 not taken
0: branch 1 not taken
886 0: if (Qualifier) {
887 0: SS.setRange(QualifierRange);
888 0: SS.setScopeRep(Qualifier);
889 : }
890 :
891 0: QualType BaseType = ((Expr*) Base.get())->getType();
892 :
893 : DeclarationName Name
894 : = SemaRef.Context.DeclarationNames.getCXXDestructorName(
895 0: SemaRef.Context.getCanonicalType(DestroyedType));
896 :
897 : return getSema().BuildMemberReferenceExpr(move(Base), BaseType,
898 : OperatorLoc, isArrow,
899 : SS, /*FIXME: FirstQualifier*/ 0,
900 : Name, DestroyedTypeLoc,
901 0: /*TemplateArgs*/ 0);
902 : }
903 :
904 : /// \brief Build a new unary operator expression.
905 : ///
906 : /// By default, performs semantic analysis to build the new expression.
907 : /// Subclasses may override this routine to provide different behavior.
908 : OwningExprResult RebuildUnaryOperator(SourceLocation OpLoc,
909 : UnaryOperator::Opcode Opc,
910 19: ExprArg SubExpr) {
911 19: return getSema().BuildUnaryOp(/*Scope=*/0, OpLoc, Opc, move(SubExpr));
912 : }
913 :
914 : /// \brief Build a new sizeof or alignof expression with a type argument.
915 : ///
916 : /// By default, performs semantic analysis to build the new expression.
917 : /// Subclasses may override this routine to provide different behavior.
918 : OwningExprResult RebuildSizeOfAlignOf(TypeSourceInfo *TInfo,
919 : SourceLocation OpLoc,
920 29: bool isSizeOf, SourceRange R) {
921 29: return getSema().CreateSizeOfAlignOfExpr(TInfo, OpLoc, isSizeOf, R);
922 : }
923 :
924 : /// \brief Build a new sizeof or alignof expression with an expression
925 : /// argument.
926 : ///
927 : /// By default, performs semantic analysis to build the new expression.
928 : /// Subclasses may override this routine to provide different behavior.
929 : OwningExprResult RebuildSizeOfAlignOf(ExprArg SubExpr, SourceLocation OpLoc,
930 30: bool isSizeOf, SourceRange R) {
931 : OwningExprResult Result
932 : = getSema().CreateSizeOfAlignOfExpr((Expr *)SubExpr.get(),
933 30: OpLoc, isSizeOf, R);
0: branch 1 not taken
30: branch 2 taken
934 30: if (Result.isInvalid())
935 0: return getSema().ExprError();
936 :
937 30: SubExpr.release();
938 30: return move(Result);
939 : }
940 :
941 : /// \brief Build a new array subscript expression.
942 : ///
943 : /// By default, performs semantic analysis to build the new expression.
944 : /// Subclasses may override this routine to provide different behavior.
945 : OwningExprResult RebuildArraySubscriptExpr(ExprArg LHS,
946 : SourceLocation LBracketLoc,
947 : ExprArg RHS,
948 19: SourceLocation RBracketLoc) {
949 : return getSema().ActOnArraySubscriptExpr(/*Scope=*/0, move(LHS),
950 : LBracketLoc, move(RHS),
951 19: RBracketLoc);
952 : }
953 :
954 : /// \brief Build a new call expression.
955 : ///
956 : /// By default, performs semantic analysis to build the new expression.
957 : /// Subclasses may override this routine to provide different behavior.
958 : OwningExprResult RebuildCallExpr(ExprArg Callee, SourceLocation LParenLoc,
959 : MultiExprArg Args,
960 : SourceLocation *CommaLocs,
961 166: SourceLocation RParenLoc) {
962 : return getSema().ActOnCallExpr(/*Scope=*/0, move(Callee), LParenLoc,
963 166: move(Args), CommaLocs, RParenLoc);
964 : }
965 :
966 : /// \brief Build a new member access expression.
967 : ///
968 : /// By default, performs semantic analysis to build the new expression.
969 : /// Subclasses may override this routine to provide different behavior.
970 : OwningExprResult RebuildMemberExpr(ExprArg Base, SourceLocation OpLoc,
971 : bool isArrow,
972 : NestedNameSpecifier *Qualifier,
973 : SourceRange QualifierRange,
974 : SourceLocation MemberLoc,
975 : ValueDecl *Member,
976 : const TemplateArgumentListInfo *ExplicitTemplateArgs,
977 103: NamedDecl *FirstQualifierInScope) {
1: branch 2 taken
102: branch 3 taken
978 103: if (!Member->getDeclName()) {
979 : // We have a reference to an unnamed field.
0: branch 0 not taken
1: branch 1 taken
980 1: assert(!Qualifier && "Can't have an unnamed field with a qualifier!");
981 :
982 1: Expr *BaseExpr = Base.takeAs<Expr>();
1: branch 2 taken
0: branch 3 not taken
983 1: if (getSema().PerformObjectMemberConversion(BaseExpr, Member))
984 1: return getSema().ExprError();
985 :
986 : MemberExpr *ME =
987 : new (getSema().Context) MemberExpr(BaseExpr, isArrow,
988 : Member, MemberLoc,
0: branch 4 not taken
0: branch 5 not taken
989 0: cast<FieldDecl>(Member)->getType());
990 0: return getSema().Owned(ME);
991 : }
992 :
993 102: CXXScopeSpec SS;
1: branch 0 taken
101: branch 1 taken
994 102: if (Qualifier) {
995 1: SS.setRange(QualifierRange);
996 1: SS.setScopeRep(Qualifier);
997 : }
998 :
999 102: QualType BaseType = ((Expr*) Base.get())->getType();
1000 :
1001 : LookupResult R(getSema(), Member->getDeclName(), MemberLoc,
1002 102: Sema::LookupMemberName);
1003 102: R.addDecl(Member);
1004 102: R.resolveKind();
1005 :
1006 : return getSema().BuildMemberReferenceExpr(move(Base), BaseType,
1007 : OpLoc, isArrow,
1008 : SS, FirstQualifierInScope,
1009 102: R, ExplicitTemplateArgs);
1010 : }
1011 :
1012 : /// \brief Build a new binary operator expression.
1013 : ///
1014 : /// By default, performs semantic analysis to build the new expression.
1015 : /// Subclasses may override this routine to provide different behavior.
1016 : OwningExprResult RebuildBinaryOperator(SourceLocation OpLoc,
1017 : BinaryOperator::Opcode Opc,
1018 836: ExprArg LHS, ExprArg RHS) {
1019 : return getSema().BuildBinOp(/*Scope=*/0, OpLoc, Opc,
1020 836: LHS.takeAs<Expr>(), RHS.takeAs<Expr>());
1021 : }
1022 :
1023 : /// \brief Build a new conditional operator expression.
1024 : ///
1025 : /// By default, performs semantic analysis to build the new expression.
1026 : /// Subclasses may override this routine to provide different behavior.
1027 : OwningExprResult RebuildConditionalOperator(ExprArg Cond,
1028 : SourceLocation QuestionLoc,
1029 : ExprArg LHS,
1030 : SourceLocation ColonLoc,
1031 20: ExprArg RHS) {
1032 : return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, move(Cond),
1033 20: move(LHS), move(RHS));
1034 : }
1035 :
1036 : /// \brief Build a new C-style cast expression.
1037 : ///
1038 : /// By default, performs semantic analysis to build the new expression.
1039 : /// Subclasses may override this routine to provide different behavior.
1040 : OwningExprResult RebuildCStyleCastExpr(SourceLocation LParenLoc,
1041 : TypeSourceInfo *TInfo,
1042 : SourceLocation RParenLoc,
1043 50: ExprArg SubExpr) {
1044 : return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
1045 50: move(SubExpr));
1046 : }
1047 :
1048 : /// \brief Build a new compound literal expression.
1049 : ///
1050 : /// By default, performs semantic analysis to build the new expression.
1051 : /// Subclasses may override this routine to provide different behavior.
1052 : OwningExprResult RebuildCompoundLiteralExpr(SourceLocation LParenLoc,
1053 : TypeSourceInfo *TInfo,
1054 : SourceLocation RParenLoc,
1055 1: ExprArg Init) {
1056 : return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc,
1057 1: move(Init));
1058 : }
1059 :
1060 : /// \brief Build a new extended vector element access expression.
1061 : ///
1062 : /// By default, performs semantic analysis to build the new expression.
1063 : /// Subclasses may override this routine to provide different behavior.
1064 : OwningExprResult RebuildExtVectorElementExpr(ExprArg Base,
1065 : SourceLocation OpLoc,
1066 : SourceLocation AccessorLoc,
1067 2: IdentifierInfo &Accessor) {
1068 :
1069 2: CXXScopeSpec SS;
1070 2: QualType BaseType = ((Expr*) Base.get())->getType();
1071 : return getSema().BuildMemberReferenceExpr(move(Base), BaseType,
1072 : OpLoc, /*IsArrow*/ false,
1073 : SS, /*FirstQualifierInScope*/ 0,
1074 : DeclarationName(&Accessor),
1075 : AccessorLoc,
1076 2: /* TemplateArgs */ 0);
1077 : }
1078 :
1079 : /// \brief Build a new initializer list expression.
1080 : ///
1081 : /// By default, performs semantic analysis to build the new expression.
1082 : /// Subclasses may override this routine to provide different behavior.
1083 : OwningExprResult RebuildInitList(SourceLocation LBraceLoc,
1084 : MultiExprArg Inits,
1085 : SourceLocation RBraceLoc,
1086 16: QualType ResultTy) {
1087 : OwningExprResult Result
1088 16: = SemaRef.ActOnInitList(LBraceLoc, move(Inits), RBraceLoc);
16: branch 1 taken
0: branch 2 not taken
0: branch 5 not taken
16: branch 6 taken
0: branch 7 not taken
16: branch 8 taken
1089 16: if (Result.isInvalid() || ResultTy->isDependentType())
1090 0: return move(Result);
1091 :
1092 : // Patch in the result type we were given, which may have been computed
1093 : // when the initial InitListExpr was built.
1094 16: InitListExpr *ILE = cast<InitListExpr>((Expr *)Result.get());
1095 16: ILE->setType(ResultTy);
1096 16: return move(Result);
1097 : }
1098 :
1099 : /// \brief Build a new designated initializer expression.
1100 : ///
1101 : /// By default, performs semantic analysis to build the new expression.
1102 : /// Subclasses may override this routine to provide different behavior.
1103 : OwningExprResult RebuildDesignatedInitExpr(Designation &Desig,
1104 : MultiExprArg ArrayExprs,
1105 : SourceLocation EqualOrColonLoc,
1106 : bool GNUSyntax,
1107 14: ExprArg Init) {
1108 : OwningExprResult Result
1109 : = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
1110 14: move(Init));
0: branch 1 not taken
14: branch 2 taken
1111 14: if (Result.isInvalid())
1112 0: return SemaRef.ExprError();
1113 :
1114 14: ArrayExprs.release();
1115 14: return move(Result);
1116 : }
1117 :
1118 : /// \brief Build a new value-initialized expression.
1119 : ///
1120 : /// By default, builds the implicit value initialization without performing
1121 : /// any semantic analysis. Subclasses may override this routine to provide
1122 : /// different behavior.
1123 0: OwningExprResult RebuildImplicitValueInitExpr(QualType T) {
0: branch 1 not taken
0: branch 2 not taken
1124 0: return SemaRef.Owned(new (SemaRef.Context) ImplicitValueInitExpr(T));
1125 : }
1126 :
1127 : /// \brief Build a new \c va_arg expression.
1128 : ///
1129 : /// By default, performs semantic analysis to build the new expression.
1130 : /// Subclasses may override this routine to provide different behavior.
1131 : OwningExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc, ExprArg SubExpr,
1132 2: QualType T, SourceLocation RParenLoc) {
1133 : return getSema().ActOnVAArg(BuiltinLoc, move(SubExpr), T.getAsOpaquePtr(),
1134 2: RParenLoc);
1135 : }
1136 :
1137 : /// \brief Build a new expression list in parentheses.
1138 : ///
1139 : /// By default, performs semantic analysis to build the new expression.
1140 : /// Subclasses may override this routine to provide different behavior.
1141 : OwningExprResult RebuildParenListExpr(SourceLocation LParenLoc,
1142 : MultiExprArg SubExprs,
1143 0: SourceLocation RParenLoc) {
1144 : return getSema().ActOnParenOrParenListExpr(LParenLoc, RParenLoc,
1145 0: move(SubExprs));
1146 : }
1147 :
1148 : /// \brief Build a new address-of-label expression.
1149 : ///
1150 : /// By default, performs semantic analysis, using the name of the label
1151 : /// rather than attempting to map the label statement itself.
1152 : /// Subclasses may override this routine to provide different behavior.
1153 : OwningExprResult RebuildAddrLabelExpr(SourceLocation AmpAmpLoc,
1154 : SourceLocation LabelLoc,
1155 2: LabelStmt *Label) {
1156 2: return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label->getID());
1157 : }
1158 :
1159 : /// \brief Build a new GNU statement expression.
1160 : ///
1161 : /// By default, performs semantic analysis to build the new expression.
1162 : /// Subclasses may override this routine to provide different behavior.
1163 : OwningExprResult RebuildStmtExpr(SourceLocation LParenLoc,
1164 : StmtArg SubStmt,
1165 1: SourceLocation RParenLoc) {
1166 1: return getSema().ActOnStmtExpr(LParenLoc, move(SubStmt), RParenLoc);
1167 : }
1168 :
1169 : /// \brief Build a new __builtin_types_compatible_p expression.
1170 : ///
1171 : /// By default, performs semantic analysis to build the new expression.
1172 : /// Subclasses may override this routine to provide different behavior.
1173 : OwningExprResult RebuildTypesCompatibleExpr(SourceLocation BuiltinLoc,
1174 : QualType T1, QualType T2,
1175 0: SourceLocation RParenLoc) {
1176 : return getSema().ActOnTypesCompatibleExpr(BuiltinLoc,
1177 : T1.getAsOpaquePtr(),
1178 : T2.getAsOpaquePtr(),
1179 0: RParenLoc);
1180 : }
1181 :
1182 : /// \brief Build a new __builtin_choose_expr expression.
1183 : ///
1184 : /// By default, performs semantic analysis to build the new expression.
1185 : /// Subclasses may override this routine to provide different behavior.
1186 : OwningExprResult RebuildChooseExpr(SourceLocation BuiltinLoc,
1187 : ExprArg Cond, ExprArg LHS, ExprArg RHS,
1188 3: SourceLocation RParenLoc) {
1189 : return SemaRef.ActOnChooseExpr(BuiltinLoc,
1190 : move(Cond), move(LHS), move(RHS),
1191 3: RParenLoc);
1192 : }
1193 :
1194 : /// \brief Build a new overloaded operator call expression.
1195 : ///
1196 : /// By default, performs semantic analysis to build the new expression.
1197 : /// The semantic analysis provides the behavior of template instantiation,
1198 : /// copying with transformations that turn what looks like an overloaded
1199 : /// operator call into a use of a builtin operator, performing
1200 : /// argument-dependent lookup, etc. Subclasses may override this routine to
1201 : /// provide different behavior.
1202 : OwningExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op,
1203 : SourceLocation OpLoc,
1204 : ExprArg Callee,
1205 : ExprArg First,
1206 : ExprArg Second);
1207 :
1208 : /// \brief Build a new C++ "named" cast expression, such as static_cast or
1209 : /// reinterpret_cast.
1210 : ///
1211 : /// By default, this routine dispatches to one of the more-specific routines
1212 : /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
1213 : /// Subclasses may override this routine to provide different behavior.
1214 : OwningExprResult RebuildCXXNamedCastExpr(SourceLocation OpLoc,
1215 : Stmt::StmtClass Class,
1216 : SourceLocation LAngleLoc,
1217 : TypeSourceInfo *TInfo,
1218 : SourceLocation RAngleLoc,
1219 : SourceLocation LParenLoc,
1220 : ExprArg SubExpr,
1221 17: SourceLocation RParenLoc) {
9: branch 0 taken
2: branch 1 taken
4: branch 2 taken
2: branch 3 taken
0: branch 4 not taken
1222 17: switch (Class) {
1223 : case Stmt::CXXStaticCastExprClass:
1224 : return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
1225 : RAngleLoc, LParenLoc,
1226 9: move(SubExpr), RParenLoc);
1227 :
1228 : case Stmt::CXXDynamicCastExprClass:
1229 : return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
1230 : RAngleLoc, LParenLoc,
1231 2: move(SubExpr), RParenLoc);
1232 :
1233 : case Stmt::CXXReinterpretCastExprClass:
1234 : return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
1235 : RAngleLoc, LParenLoc,
1236 : move(SubExpr),
1237 4: RParenLoc);
1238 :
1239 : case Stmt::CXXConstCastExprClass:
1240 : return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
1241 : RAngleLoc, LParenLoc,
1242 2: move(SubExpr), RParenLoc);
1243 :
1244 : default:
1245 0: assert(false && "Invalid C++ named cast");
1246 : break;
1247 : }
1248 :
1249 : return getSema().ExprError();
1250 : }
1251 :
1252 : /// \brief Build a new C++ static_cast expression.
1253 : ///
1254 : /// By default, performs semantic analysis to build the new expression.
1255 : /// Subclasses may override this routine to provide different behavior.
1256 : OwningExprResult RebuildCXXStaticCastExpr(SourceLocation OpLoc,
1257 : SourceLocation LAngleLoc,
1258 : TypeSourceInfo *TInfo,
1259 : SourceLocation RAngleLoc,
1260 : SourceLocation LParenLoc,
1261 : ExprArg SubExpr,
1262 9: SourceLocation RParenLoc) {
1263 : return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast,
1264 : TInfo, move(SubExpr),
1265 : SourceRange(LAngleLoc, RAngleLoc),
1266 9: SourceRange(LParenLoc, RParenLoc));
1267 : }
1268 :
1269 : /// \brief Build a new C++ dynamic_cast expression.
1270 : ///
1271 : /// By default, performs semantic analysis to build the new expression.
1272 : /// Subclasses may override this routine to provide different behavior.
1273 : OwningExprResult RebuildCXXDynamicCastExpr(SourceLocation OpLoc,
1274 : SourceLocation LAngleLoc,
1275 : TypeSourceInfo *TInfo,
1276 : SourceLocation RAngleLoc,
1277 : SourceLocation LParenLoc,
1278 : ExprArg SubExpr,
1279 2: SourceLocation RParenLoc) {
1280 : return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
1281 : TInfo, move(SubExpr),
1282 : SourceRange(LAngleLoc, RAngleLoc),
1283 2: SourceRange(LParenLoc, RParenLoc));
1284 : }
1285 :
1286 : /// \brief Build a new C++ reinterpret_cast expression.
1287 : ///
1288 : /// By default, performs semantic analysis to build the new expression.
1289 : /// Subclasses may override this routine to provide different behavior.
1290 : OwningExprResult RebuildCXXReinterpretCastExpr(SourceLocation OpLoc,
1291 : SourceLocation LAngleLoc,
1292 : TypeSourceInfo *TInfo,
1293 : SourceLocation RAngleLoc,
1294 : SourceLocation LParenLoc,
1295 : ExprArg SubExpr,
1296 4: SourceLocation RParenLoc) {
1297 : return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
1298 : TInfo, move(SubExpr),
1299 : SourceRange(LAngleLoc, RAngleLoc),
1300 4: SourceRange(LParenLoc, RParenLoc));
1301 : }
1302 :
1303 : /// \brief Build a new C++ const_cast expression.
1304 : ///
1305 : /// By default, performs semantic analysis to build the new expression.
1306 : /// Subclasses may override this routine to provide different behavior.
1307 : OwningExprResult RebuildCXXConstCastExpr(SourceLocation OpLoc,
1308 : SourceLocation LAngleLoc,
1309 : TypeSourceInfo *TInfo,
1310 : SourceLocation RAngleLoc,
1311 : SourceLocation LParenLoc,
1312 : ExprArg SubExpr,
1313 2: SourceLocation RParenLoc) {
1314 : return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
1315 : TInfo, move(SubExpr),
1316 : SourceRange(LAngleLoc, RAngleLoc),
1317 2: SourceRange(LParenLoc, RParenLoc));
1318 : }
1319 :
1320 : /// \brief Build a new C++ functional-style cast expression.
1321 : ///
1322 : /// By default, performs semantic analysis to build the new expression.
1323 : /// Subclasses may override this routine to provide different behavior.
1324 : OwningExprResult RebuildCXXFunctionalCastExpr(SourceRange TypeRange,
1325 : TypeSourceInfo *TInfo,
1326 : SourceLocation LParenLoc,
1327 : ExprArg SubExpr,
1328 3: SourceLocation RParenLoc) {
1329 3: void *Sub = SubExpr.takeAs<Expr>();
1330 : return getSema().ActOnCXXTypeConstructExpr(TypeRange,
1331 : TInfo->getType().getAsOpaquePtr(),
1332 : LParenLoc,
1333 : Sema::MultiExprArg(getSema(), &Sub, 1),
1334 : /*CommaLocs=*/0,
1335 3: RParenLoc);
1336 : }
1337 :
1338 : /// \brief Build a new C++ typeid(type) expression.
1339 : ///
1340 : /// By default, performs semantic analysis to build the new expression.
1341 : /// Subclasses may override this routine to provide different behavior.
1342 : OwningExprResult RebuildCXXTypeidExpr(SourceLocation TypeidLoc,
1343 : SourceLocation LParenLoc,
1344 : QualType T,
1345 3: SourceLocation RParenLoc) {
1346 : return getSema().ActOnCXXTypeid(TypeidLoc, LParenLoc, true,
1347 3: T.getAsOpaquePtr(), RParenLoc);
1348 : }
1349 :
1350 : /// \brief Build a new C++ typeid(expr) expression.
1351 : ///
1352 : /// By default, performs semantic analysis to build the new expression.
1353 : /// Subclasses may override this routine to provide different behavior.
1354 : OwningExprResult RebuildCXXTypeidExpr(SourceLocation TypeidLoc,
1355 : SourceLocation LParenLoc,
1356 : ExprArg Operand,
1357 8: SourceLocation RParenLoc) {
1358 : OwningExprResult Result
1359 : = getSema().ActOnCXXTypeid(TypeidLoc, LParenLoc, false, Operand.get(),
1360 8: RParenLoc);
0: branch 1 not taken
8: branch 2 taken
1361 8: if (Result.isInvalid())
1362 0: return getSema().ExprError();
1363 :
1364 8: Operand.release(); // FIXME: since ActOnCXXTypeid silently took ownership
1365 8: return move(Result);
1366 : }
1367 :
1368 : /// \brief Build a new C++ "this" expression.
1369 : ///
1370 : /// By default, builds a new "this" expression without performing any
1371 : /// semantic analysis. Subclasses may override this routine to provide
1372 : /// different behavior.
1373 : OwningExprResult RebuildCXXThisExpr(SourceLocation ThisLoc,
1374 : QualType ThisType,
1375 110: bool isImplicit) {
1376 : return getSema().Owned(
1377 : new (getSema().Context) CXXThisExpr(ThisLoc, ThisType,
110: branch 2 taken
0: branch 3 not taken
1378 110: isImplicit));
1379 : }
1380 :
1381 : /// \brief Build a new C++ throw expression.
1382 : ///
1383 : /// By default, performs semantic analysis to build the new expression.
1384 : /// Subclasses may override this routine to provide different behavior.
1385 3: OwningExprResult RebuildCXXThrowExpr(SourceLocation ThrowLoc, ExprArg Sub) {
1386 3: return getSema().ActOnCXXThrow(ThrowLoc, move(Sub));
1387 : }
1388 :
1389 : /// \brief Build a new C++ default-argument expression.
1390 : ///
1391 : /// By default, builds a new default-argument expression, which does not
1392 : /// require any semantic analysis. Subclasses may override this routine to
1393 : /// provide different behavior.
1394 : OwningExprResult RebuildCXXDefaultArgExpr(SourceLocation Loc,
1395 : ParmVarDecl *Param) {
1396 : return getSema().Owned(CXXDefaultArgExpr::Create(getSema().Context, Loc,
1397 : Param));
1398 : }
1399 :
1400 : /// \brief Build a new C++ zero-initialization expression.
1401 : ///
1402 : /// By default, performs semantic analysis to build the new expression.
1403 : /// Subclasses may override this routine to provide different behavior.
1404 : OwningExprResult RebuildCXXZeroInitValueExpr(SourceLocation TypeStartLoc,
1405 : SourceLocation LParenLoc,
1406 : QualType T,
1407 0: SourceLocation RParenLoc) {
1408 : return getSema().ActOnCXXTypeConstructExpr(SourceRange(TypeStartLoc),
1409 : T.getAsOpaquePtr(), LParenLoc,
1410 : MultiExprArg(getSema(), 0, 0),
1411 0: 0, RParenLoc);
1412 : }
1413 :
1414 : /// \brief Build a new C++ "new" expression.
1415 : ///
1416 : /// By default, performs semantic analysis to build the new expression.
1417 : /// Subclasses may override this routine to provide different behavior.
1418 : OwningExprResult RebuildCXXNewExpr(SourceLocation StartLoc,
1419 : bool UseGlobal,
1420 : SourceLocation PlacementLParen,
1421 : MultiExprArg PlacementArgs,
1422 : SourceLocation PlacementRParen,
1423 : bool ParenTypeId,
1424 : QualType AllocType,
1425 : SourceLocation TypeLoc,
1426 : SourceRange TypeRange,
1427 : ExprArg ArraySize,
1428 : SourceLocation ConstructorLParen,
1429 : MultiExprArg ConstructorArgs,
1430 18: SourceLocation ConstructorRParen) {
1431 : return getSema().BuildCXXNew(StartLoc, UseGlobal,
1432 : PlacementLParen,
1433 : move(PlacementArgs),
1434 : PlacementRParen,
1435 : ParenTypeId,
1436 : AllocType,
1437 : TypeLoc,
1438 : TypeRange,
1439 : move(ArraySize),
1440 : ConstructorLParen,
1441 : move(ConstructorArgs),
1442 18: ConstructorRParen);
1443 : }
1444 :
1445 : /// \brief Build a new C++ "delete" expression.
1446 : ///
1447 : /// By default, performs semantic analysis to build the new expression.
1448 : /// Subclasses may override this routine to provide different behavior.
1449 : OwningExprResult RebuildCXXDeleteExpr(SourceLocation StartLoc,
1450 : bool IsGlobalDelete,
1451 : bool IsArrayForm,
1452 9: ExprArg Operand) {
1453 : return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
1454 9: move(Operand));
1455 : }
1456 :
1457 : /// \brief Build a new unary type trait expression.
1458 : ///
1459 : /// By default, performs semantic analysis to build the new expression.
1460 : /// Subclasses may override this routine to provide different behavior.
1461 : OwningExprResult RebuildUnaryTypeTrait(UnaryTypeTrait Trait,
1462 : SourceLocation StartLoc,
1463 : SourceLocation LParenLoc,
1464 : QualType T,
1465 2: SourceLocation RParenLoc) {
1466 : return getSema().ActOnUnaryTypeTrait(Trait, StartLoc, LParenLoc,
1467 2: T.getAsOpaquePtr(), RParenLoc);
1468 : }
1469 :
1470 : /// \brief Build a new (previously unresolved) declaration reference
1471 : /// expression.
1472 : ///
1473 : /// By default, performs semantic analysis to build the new expression.
1474 : /// Subclasses may override this routine to provide different behavior.
1475 : OwningExprResult RebuildDependentScopeDeclRefExpr(NestedNameSpecifier *NNS,
1476 : SourceRange QualifierRange,
1477 : DeclarationName Name,
1478 : SourceLocation Location,
1479 487: const TemplateArgumentListInfo *TemplateArgs) {
1480 487: CXXScopeSpec SS;
1481 487: SS.setRange(QualifierRange);
1482 487: SS.setScopeRep(NNS);
1483 :
1: branch 0 taken
486: branch 1 taken
1484 487: if (TemplateArgs)
1485 : return getSema().BuildQualifiedTemplateIdExpr(SS, Name, Location,
1486 1: *TemplateArgs);
1487 :
1488 486: return getSema().BuildQualifiedDeclarationNameExpr(SS, Name, Location);
1489 : }
1490 :
1491 : /// \brief Build a new template-id expression.
1492 : ///
1493 : /// By default, performs semantic analysis to build the new expression.
1494 : /// Subclasses may override this routine to provide different behavior.
1495 : OwningExprResult RebuildTemplateIdExpr(const CXXScopeSpec &SS,
1496 : LookupResult &R,
1497 : bool RequiresADL,
1498 3: const TemplateArgumentListInfo &TemplateArgs) {
1499 3: return getSema().BuildTemplateIdExpr(SS, R, RequiresADL, TemplateArgs);
1500 : }
1501 :
1502 : /// \brief Build a new object-construction expression.
1503 : ///
1504 : /// By default, performs semantic analysis to build the new expression.
1505 : /// Subclasses may override this routine to provide different behavior.
1506 : OwningExprResult RebuildCXXConstructExpr(QualType T,
1507 : SourceLocation Loc,
1508 : CXXConstructorDecl *Constructor,
1509 : bool IsElidable,
1510 3: MultiExprArg Args) {
1511 3: ASTOwningVector<&ActionBase::DeleteExpr> ConvertedArgs(SemaRef);
0: branch 5 not taken
3: branch 6 taken
1512 3: if (getSema().CompleteConstructorCall(Constructor, move(Args), Loc,
1513 : ConvertedArgs))
1514 0: return getSema().ExprError();
1515 :
1516 : return getSema().BuildCXXConstructExpr(Loc, T, Constructor, IsElidable,
1517 3: move_arg(ConvertedArgs));
1518 : }
1519 :
1520 : /// \brief Build a new object-construction expression.
1521 : ///
1522 : /// By default, performs semantic analysis to build the new expression.
1523 : /// Subclasses may override this routine to provide different behavior.
1524 : OwningExprResult RebuildCXXTemporaryObjectExpr(SourceLocation TypeBeginLoc,
1525 : QualType T,
1526 : SourceLocation LParenLoc,
1527 : MultiExprArg Args,
1528 : SourceLocation *Commas,
1529 0: SourceLocation RParenLoc) {
1530 : return getSema().ActOnCXXTypeConstructExpr(SourceRange(TypeBeginLoc),
1531 : T.getAsOpaquePtr(),
1532 : LParenLoc,
1533 : move(Args),
1534 : Commas,
1535 0: RParenLoc);
1536 : }
1537 :
1538 : /// \brief Build a new object-construction expression.
1539 : ///
1540 : /// By default, performs semantic analysis to build the new expression.
1541 : /// Subclasses may override this routine to provide different behavior.
1542 : OwningExprResult RebuildCXXUnresolvedConstructExpr(SourceLocation TypeBeginLoc,
1543 : QualType T,
1544 : SourceLocation LParenLoc,
1545 : MultiExprArg Args,
1546 : SourceLocation *Commas,
1547 65: SourceLocation RParenLoc) {
1548 : return getSema().ActOnCXXTypeConstructExpr(SourceRange(TypeBeginLoc,
1549 : /*FIXME*/LParenLoc),
1550 : T.getAsOpaquePtr(),
1551 : LParenLoc,
1552 : move(Args),
1553 : Commas,
1554 65: RParenLoc);
1555 : }
1556 :
1557 : /// \brief Build a new member reference expression.
1558 : ///
1559 : /// By default, performs semantic analysis to build the new expression.
1560 : /// Subclasses may override this routine to provide different behavior.
1561 : OwningExprResult RebuildCXXDependentScopeMemberExpr(ExprArg BaseE,
1562 : QualType BaseType,
1563 : bool IsArrow,
1564 : SourceLocation OperatorLoc,
1565 : NestedNameSpecifier *Qualifier,
1566 : SourceRange QualifierRange,
1567 : NamedDecl *FirstQualifierInScope,
1568 : DeclarationName Name,
1569 : SourceLocation MemberLoc,
1570 95: const TemplateArgumentListInfo *TemplateArgs) {
1571 95: CXXScopeSpec SS;
1572 95: SS.setRange(QualifierRange);
1573 95: SS.setScopeRep(Qualifier);
1574 :
1575 : return SemaRef.BuildMemberReferenceExpr(move(BaseE), BaseType,
1576 : OperatorLoc, IsArrow,
1577 : SS, FirstQualifierInScope,
1578 95: Name, MemberLoc, TemplateArgs);
1579 : }
1580 :
1581 : /// \brief Build a new member reference expression.
1582 : ///
1583 : /// By default, performs semantic analysis to build the new expression.
1584 : /// Subclasses may override this routine to provide different behavior.
1585 : OwningExprResult RebuildUnresolvedMemberExpr(ExprArg BaseE,
1586 : QualType BaseType,
1587 : SourceLocation OperatorLoc,
1588 : bool IsArrow,
1589 : NestedNameSpecifier *Qualifier,
1590 : SourceRange QualifierRange,
1591 : NamedDecl *FirstQualifierInScope,
1592 : LookupResult &R,
1593 10: const TemplateArgumentListInfo *TemplateArgs) {
1594 10: CXXScopeSpec SS;
1595 10: SS.setRange(QualifierRange);
1596 10: SS.setScopeRep(Qualifier);
1597 :
1598 : return SemaRef.BuildMemberReferenceExpr(move(BaseE), BaseType,
1599 : OperatorLoc, IsArrow,
1600 : SS, FirstQualifierInScope,
1601 10: R, TemplateArgs);
1602 : }
1603 :
1604 : /// \brief Build a new Objective-C @encode expression.
1605 : ///
1606 : /// By default, performs semantic analysis to build the new expression.
1607 : /// Subclasses may override this routine to provide different behavior.
1608 : OwningExprResult RebuildObjCEncodeExpr(SourceLocation AtLoc,
1609 : QualType T,
1610 2: SourceLocation RParenLoc) {
1611 : return SemaRef.Owned(SemaRef.BuildObjCEncodeExpression(AtLoc, T,
1612 2: RParenLoc));
1613 : }
1614 :
1615 : /// \brief Build a new Objective-C protocol expression.
1616 : ///
1617 : /// By default, performs semantic analysis to build the new expression.
1618 : /// Subclasses may override this routine to provide different behavior.
1619 : OwningExprResult RebuildObjCProtocolExpr(ObjCProtocolDecl *Protocol,
1620 : SourceLocation AtLoc,
1621 : SourceLocation ProtoLoc,
1622 : SourceLocation LParenLoc,
1623 0: SourceLocation RParenLoc) {
1624 : return SemaRef.Owned(SemaRef.ParseObjCProtocolExpression(
1625 : Protocol->getIdentifier(),
1626 : AtLoc,
1627 : ProtoLoc,
1628 : LParenLoc,
1629 0: RParenLoc));
1630 : }
1631 :
1632 : /// \brief Build a new shuffle vector expression.
1633 : ///
1634 : /// By default, performs semantic analysis to build the new expression.
1635 : /// Subclasses may override this routine to provide different behavior.
1636 : OwningExprResult RebuildShuffleVectorExpr(SourceLocation BuiltinLoc,
1637 : MultiExprArg SubExprs,
1638 2: SourceLocation RParenLoc) {
1639 : // Find the declaration for __builtin_shufflevector
1640 : const IdentifierInfo &Name
1641 2: = SemaRef.Context.Idents.get("__builtin_shufflevector");
1642 2: TranslationUnitDecl *TUDecl = SemaRef.Context.getTranslationUnitDecl();
1643 2: DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
0: branch 0 not taken
2: branch 1 taken
1644 2: assert(Lookup.first != Lookup.second && "No __builtin_shufflevector?");
1645 :
1646 : // Build a reference to the __builtin_shufflevector builtin
1647 2: FunctionDecl *Builtin = cast<FunctionDecl>(*Lookup.first);
1648 : Expr *Callee
1649 : = new (SemaRef.Context) DeclRefExpr(Builtin, Builtin->getType(),
2: branch 2 taken
0: branch 3 not taken
1650 2: BuiltinLoc);
1651 2: SemaRef.UsualUnaryConversions(Callee);
1652 :
1653 : // Build the CallExpr
1654 2: unsigned NumSubExprs = SubExprs.size();
1655 2: Expr **Subs = (Expr **)SubExprs.release();
1656 : CallExpr *TheCall = new (SemaRef.Context) CallExpr(SemaRef.Context, Callee,
1657 : Subs, NumSubExprs,
1658 : Builtin->getResultType(),
2: branch 2 taken
0: branch 3 not taken
1659 2: RParenLoc);
1660 2: OwningExprResult OwnedCall(SemaRef.Owned(TheCall));
1661 :
1662 : // Type-check the __builtin_shufflevector expression.
1663 2: OwningExprResult Result = SemaRef.SemaBuiltinShuffleVector(TheCall);
0: branch 1 not taken
2: branch 2 taken
1664 2: if (Result.isInvalid())
1665 0: return SemaRef.ExprError();
1666 :
1667 2: OwnedCall.release();
1668 2: return move(Result);
1669 : }
1670 : };
1671 :
1672 : template<typename Derived>
1673 1249: Sema::OwningStmtResult TreeTransform<Derived>::TransformStmt(Stmt *S) {
13: branch 0 taken
1236: branch 1 taken
1674 1249: if (!S)
1675 13: return SemaRef.Owned(S);
1676 :
0: branch 1 not taken
5: branch 2 taken
567: branch 3 taken
19: branch 4 taken
3: branch 5 taken
3: branch 6 taken
23: branch 7 taken
5: branch 8 taken
2: branch 9 taken
2: branch 10 taken
14: branch 11 taken
1: branch 12 taken
2: branch 13 taken
1: branch 14 taken
1: branch 15 taken
147: branch 16 taken
181: branch 17 taken
0: branch 18 not taken
2: branch 19 taken
0: branch 20 not taken
0: branch 21 not taken
0: branch 22 not taken
0: branch 23 not taken
0: branch 24 not taken
0: branch 25 not taken
0: branch 26 not taken
6: branch 27 taken
252: branch 28 taken
0: branch 29 not taken
1677 1236: switch (S->getStmtClass()) {
1678 0: case Stmt::NoStmtClass: break;
1679 :
1680 : // Transform individual statement nodes
1681 : #define STMT(Node, Parent) \
1682 : case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
1683 : #define EXPR(Node, Parent)
1684 : #include "clang/AST/StmtNodes.def"
1685 :
1686 : // Transform expressions by calling TransformExpr.
1687 : #define STMT(Node, Parent)
1688 : #define ABSTRACT_EXPR(Node, Parent)
1689 : #define EXPR(Node, Parent) case Stmt::Node##Class:
1690 : #include "clang/AST/StmtNodes.def"
1691 : {
1692 252: Sema::OwningExprResult E = getDerived().TransformExpr(cast<Expr>(S));
47: branch 1 taken
205: branch 2 taken
1693 252: if (E.isInvalid())
1694 47: return getSema().StmtError();
1695 :
1696 205: return getSema().ActOnExprStmt(getSema().MakeFullExpr(E));
1697 : }
1698 : }
1699 :
1700 0: return SemaRef.Owned(S->Retain());
1701 : }
1702 :
1703 :
1704 : template<typename Derived>
1705 6120: Sema::OwningExprResult TreeTransform<Derived>::TransformExpr(Expr *E) {
43: branch 0 taken
6077: branch 1 taken
1706 6120: if (!E)
1707 43: return SemaRef.Owned(E);
1708 :
0: branch 1 not taken
0: branch 2 not taken
0: branch 3 not taken
0: branch 4 not taken
0: branch 5 not taken
0: branch 6 not taken
0: branch 7 not taken
0: branch 8 not taken
0: branch 9 not taken
0: branch 10 not taken
0: branch 11 not taken
0: branch 12 not taken
0: branch 13 not taken
0: branch 14 not taken
0: branch 15 not taken
0: branch 16 not taken
0: branch 17 not taken
0: branch 18 not taken
0: branch 19 not taken
0: branch 20 not taken
0: branch 21 not taken
0: branch 22 not taken
0: branch 23 not taken
0: branch 24 not taken
0: branch 25 not taken
0: branch 26 not taken
0: branch 27 not taken
17: branch 28 taken
1682: branch 29 taken
975: branch 30 taken
15: branch 31 taken
2: branch 32 taken
14: branch 33 taken
1: branch 34 taken
61: branch 35 taken
37: branch 36 taken
71: branch 37 taken
19: branch 38 taken
168: branch 39 taken
108: branch 40 taken
842: branch 41 taken
3: branch 42 taken
20: branch 43 taken
780: branch 44 taken
61: branch 45 taken
1: branch 46 taken
2: branch 47 taken
21: branch 48 taken
14: branch 49 taken
10: branch 50 taken
0: branch 51 not taken
2: branch 52 taken
2: branch 53 taken
2: branch 54 taken
0: branch 55 not taken
3: branch 56 taken
1: branch 57 taken
59: branch 58 taken
4: branch 59 taken
0: branch 60 not taken
9: branch 61 taken
2: branch 62 taken
4: branch 63 taken
2: branch 64 taken
3: branch 65 taken
11: branch 66 taken
109: branch 67 taken
1: branch 68 taken
114: branch 69 taken
6: branch 70 taken
3: branch 71 taken
9: branch 72 taken
18: branch 73 taken
9: branch 74 taken
0: branch 75 not taken
96: branch 76 taken
2: branch 77 taken
488: branch 78 taken
9: branch 79 taken
0: branch 80 not taken
0: branch 81 not taken
2: branch 82 taken
0: branch 83 not taken
65: branch 84 taken
96: branch 85 taken
10: branch 86 taken
2: branch 87 taken
2: branch 88 taken
0: branch 89 not taken
4: branch 90 taken
2: branch 91 taken
0: branch 92 not taken
0: branch 93 not taken
0: branch 94 not taken
0: branch 95 not taken
0: branch 96 not taken
2: branch 97 taken
0: branch 98 not taken
0: branch 99 not taken
0: branch 100 not taken
1709 6077: switch (E->getStmtClass()) {
1710 0: case Stmt::NoStmtClass: break;
1711 : #define STMT(Node, Parent) case Stmt::Node##Class: break;
1712 : #define ABSTRACT_EXPR(Node, Parent)
1713 : #define EXPR(Node, Parent) \
1714 : case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
1715 : #include "clang/AST/StmtNodes.def"
1716 : }
1717 :
1718 0: return SemaRef.Owned(E->Retain());
1719 : }
1720 :
1721 : template<typename Derived>
1722 : NestedNameSpecifier *
1723 : TreeTransform<Derived>::TransformNestedNameSpecifier(NestedNameSpecifier *NNS,
1724 : SourceRange Range,
1725 : QualType ObjectType,
1726 756: NamedDecl *FirstQualifierInScope) {
1: branch 0 taken
755: branch 1 taken
1727 756: if (!NNS)
1728 1: return 0;
1729 :
1730 : // Transform the prefix of this nested name specifier.
1731 755: NestedNameSpecifier *Prefix = NNS->getPrefix();
34: branch 0 taken
721: branch 1 taken
1732 755: if (Prefix) {
1733 34: Prefix = getDerived().TransformNestedNameSpecifier(Prefix, Range,
1734 : ObjectType,
1735 : FirstQualifierInScope);
1: branch 0 taken
33: branch 1 taken
1736 34: if (!Prefix)
1737 1: return 0;
1738 :
1739 : // Clear out the object type and the first qualifier in scope; they only
1740 : // apply to the first element in the nested-name-specifier.
1741 33: ObjectType = QualType();
1742 33: FirstQualifierInScope = 0;
1743 : }
1744 :
32: branch 1 taken
12: branch 2 taken
1: branch 3 taken
709: branch 4 taken
0: branch 5 not taken
1745 754: switch (NNS->getKind()) {
1746 : case NestedNameSpecifier::Identifier:
18: branch 0 taken
14: branch 1 taken
18: branch 3 taken
0: branch 4 not taken
1747 32: assert((Prefix || !ObjectType.isNull()) &&
1748 : "Identifier nested-name-specifier with no prefix or object type");
32: branch 2 taken
0: branch 3 not taken
18: branch 5 taken
14: branch 6 taken
0: branch 8 not taken
18: branch 9 taken
0: branch 10 not taken
32: branch 11 taken
1749 64: if (!getDerived().AlwaysRebuild() && Prefix == NNS->getPrefix() &&
1750 : ObjectType.isNull())
1751 0: return NNS;
1752 :
1753 : return getDerived().RebuildNestedNameSpecifier(Prefix, Range,
1754 : *NNS->getAsIdentifier(),
1755 : ObjectType,
1756 32: FirstQualifierInScope);
1757 :
1758 : case NestedNameSpecifier::Namespace: {
1759 : NamespaceDecl *NS
1760 : = cast_or_null<NamespaceDecl>(
1761 12: getDerived().TransformDecl(NNS->getAsNamespace()));
12: branch 2 taken
0: branch 3 not taken
12: branch 5 taken
0: branch 6 not taken
12: branch 8 taken
0: branch 9 not taken
12: branch 10 taken
0: branch 11 not taken
1762 12: if (!getDerived().AlwaysRebuild() &&
1763 : Prefix == NNS->getPrefix() &&
1764 : NS == NNS->getAsNamespace())
1765 12: return NNS;
1766 :
1767 0: return getDerived().RebuildNestedNameSpecifier(Prefix, Range, NS);
1768 : }
1769 :
1770 : case NestedNameSpecifier::Global:
1771 : // There is no meaningful transformation that one could perform on the
1772 : // global scope.
1773 1: return NNS;
1774 :
1775 : case NestedNameSpecifier::TypeSpecWithTemplate:
1776 : case NestedNameSpecifier::TypeSpec: {
1777 709: TemporaryBase Rebase(*this, Range.getBegin(), DeclarationName());
1778 709: QualType T = getDerived().TransformType(QualType(NNS->getAsType(), 0));
1: branch 1 taken
708: branch 2 taken
1779 709: if (T.isNull())
1780 1: return 0;
1781 :
708: branch 2 taken
0: branch 3 not taken
699: branch 5 taken
9: branch 6 taken
24: branch 10 taken
675: branch 11 taken
24: branch 12 taken
684: branch 13 taken
1782 708: if (!getDerived().AlwaysRebuild() &&
1783 : Prefix == NNS->getPrefix() &&
1784 : T == QualType(NNS->getAsType(), 0))
1785 24: return NNS;
1786 :
1787 : return getDerived().RebuildNestedNameSpecifier(Prefix, Range,
1788 : NNS->getKind() == NestedNameSpecifier::TypeSpecWithTemplate,
1789 684: T);
1790 : }
1791 : }
1792 :
1793 : // Required to silence a GCC warning
1794 0: return 0;
1795 : }
1796 :
1797 : template<typename Derived>
1798 : DeclarationName
1799 : TreeTransform<Derived>::TransformDeclarationName(DeclarationName Name,
1800 : SourceLocation Loc,
1801 582: QualType ObjectType) {
0: branch 1 not taken
582: branch 2 taken
1802 582: if (!Name)
1803 0: return Name;
1804 :
567: branch 1 taken
15: branch 2 taken
0: branch 3 not taken
1805 582: switch (Name.getNameKind()) {
1806 : case DeclarationName::Identifier:
1807 : case DeclarationName::ObjCZeroArgSelector:
1808 : case DeclarationName::ObjCOneArgSelector:
1809 : case DeclarationName::ObjCMultiArgSelector:
1810 : case DeclarationName::CXXOperatorName:
1811 : case DeclarationName::CXXLiteralOperatorName:
1812 : case DeclarationName::CXXUsingDirective:
1813 567: return Name;
1814 :
1815 : case DeclarationName::CXXConstructorName:
1816 : case DeclarationName::CXXDestructorName:
1817 : case DeclarationName::CXXConversionFunctionName: {
1818 15: TemporaryBase Rebase(*this, Loc, Name);
1819 15: QualType T;
8: branch 1 taken
7: branch 2 taken
1: branch 5 taken
7: branch 6 taken
1: branch 7 taken
14: branch 8 taken
1820 15: if (!ObjectType.isNull() &&
1821 : isa<TemplateSpecializationType>(Name.getCXXNameType())) {
1822 : TemplateSpecializationType *SpecType
1823 1: = cast<TemplateSpecializationType>(Name.getCXXNameType());
1824 1: T = TransformTemplateSpecializationType(SpecType, ObjectType);
1825 : } else
1826 14: T = getDerived().TransformType(Name.getCXXNameType());
0: branch 1 not taken
15: branch 2 taken
1827 15: if (T.isNull())
1828 0: return DeclarationName();
1829 :
1830 : return SemaRef.Context.DeclarationNames.getCXXSpecialName(
1831 : Name.getNameKind(),
1832 15: SemaRef.Context.getCanonicalType(T));
1833 : }
1834 : }
1835 :
1836 0: return DeclarationName();
1837 : }
1838 :
1839 : template<typename Derived>
1840 : TemplateName
1841 : TreeTransform<Derived>::TransformTemplateName(TemplateName Name,
1842 1328: QualType ObjectType) {
15: branch 1 taken
1313: branch 2 taken
1843 1328: if (QualifiedTemplateName *QTN = Name.getAsQualifiedTemplateName()) {
1844 : NestedNameSpecifier *NNS
1845 : = getDerived().TransformNestedNameSpecifier(QTN->getQualifier(),
1846 15: /*FIXME:*/SourceRange(getDerived().getBaseLocation()));
0: branch 0 not taken
15: branch 1 taken
1847 15: if (!NNS)
1848 0: return TemplateName();
1849 :
15: branch 1 taken
0: branch 2 not taken
1850 15: if (TemplateDecl *Template = QTN->getTemplateDecl()) {
1851 : TemplateDecl *TransTemplate
1852 15: = cast_or_null<TemplateDecl>(getDerived().TransformDecl(Template));
0: branch 0 not taken
15: branch 1 taken
1853 15: if (!TransTemplate)
1854 0: return TemplateName();
1855 :
15: branch 2 taken
0: branch 3 not taken
12: branch 5 taken
3: branch 6 taken
15: branch 7 taken
3: branch 8 taken
12: branch 9 taken
3: branch 10 taken
1856 15: if (!getDerived().AlwaysRebuild() &&
1857 : NNS == QTN->getQualifier() &&
1858 : TransTemplate == Template)
1859 12: return Name;
1860 :
1861 : return getDerived().RebuildTemplateName(NNS, QTN->hasTemplateKeyword(),
1862 3: TransTemplate);
1863 : }
1864 :
1865 : // These should be getting filtered out before they make it into the AST.
1866 0: assert(false && "overloaded template name survived to here");
1867 : }
1868 :
15: branch 1 taken
1298: branch 2 taken
1869 1313: if (DependentTemplateName *DTN = Name.getAsDependentTemplateName()) {
1870 : NestedNameSpecifier *NNS
1871 : = getDerived().TransformNestedNameSpecifier(DTN->getQualifier(),
1872 15: /*FIXME:*/SourceRange(getDerived().getBaseLocation()));
1: branch 0 taken
14: branch 1 taken
0: branch 3 not taken
1: branch 4 taken
0: branch 5 not taken
15: branch 6 taken
1873 15: if (!NNS && DTN->getQualifier())
1874 0: return TemplateName();
1875 :
15: branch 2 taken
0: branch 3 not taken
1: branch 5 taken
14: branch 6 taken
0: branch 8 not taken
1: branch 9 taken
0: branch 10 not taken
15: branch 11 taken
1876 15: if (!getDerived().AlwaysRebuild() &&
1877 : NNS == DTN->getQualifier() &&
1878 : ObjectType.isNull())
1879 0: return Name;
1880 :
15: branch 1 taken
0: branch 2 not taken
1881 15: if (DTN->isIdentifier())
1882 : return getDerived().RebuildTemplateName(NNS, *DTN->getIdentifier(),
1883 15: ObjectType);
1884 :
1885 : return getDerived().RebuildTemplateName(NNS, DTN->getOperator(),
1886 0: ObjectType);
1887 : }
1888 :
1298: branch 1 taken
0: branch 2 not taken
1889 1298: if (TemplateDecl *Template = Name.getAsTemplateDecl()) {
1890 : TemplateDecl *TransTemplate
1891 1298: = cast_or_null<TemplateDecl>(getDerived().TransformDecl(Template));
0: branch 0 not taken
1298: branch 1 taken
1892 1298: if (!TransTemplate)
1893 0: return TemplateName();
1894 :
1298: branch 2 taken
0: branch 3 not taken
1263: branch 4 taken
35: branch 5 taken
1263: branch 6 taken
35: branch 7 taken
1895 1298: if (!getDerived().AlwaysRebuild() &&
1896 : TransTemplate == Template)
1897 1263: return Name;
1898 :
1899 35: return TemplateName(TransTemplate);
1900 : }
1901 :
1902 : // These should be getting filtered out before they reach the AST.
1903 0: assert(false && "overloaded function decl survived to here");
1904 : return TemplateName();
1905 : }
1906 :
1907 : template<typename Derived>
1908 : void TreeTransform<Derived>::InventTemplateArgumentLoc(
1909 : const TemplateArgument &Arg,
1910 1: TemplateArgumentLoc &Output) {
1911 1: SourceLocation Loc = getDerived().getBaseLocation();
0: branch 1 not taken
1: branch 2 taken
0: branch 3 not taken
0: branch 4 not taken
0: branch 5 not taken
0: branch 6 not taken
1912 1: switch (Arg.getKind()) {
1913 : case TemplateArgument::Null:
1914 0: llvm_unreachable("null template argument in TreeTransform");
1915 : break;
1916 :
1917 : case TemplateArgument::Type:
1918 1: Output = TemplateArgumentLoc(Arg,
1919 : SemaRef.Context.getTrivialTypeSourceInfo(Arg.getAsType(), Loc));
1920 :
1921 1: break;
1922 :
1923 : case TemplateArgument::Template:
1924 0: Output = TemplateArgumentLoc(Arg, SourceRange(), Loc);
1925 0: break;
1926 :
1927 : case TemplateArgument::Expression:
1928 0: Output = TemplateArgumentLoc(Arg, Arg.getAsExpr());
1929 0: break;
1930 :
1931 : case TemplateArgument::Declaration:
1932 : case TemplateArgument::Integral:
1933 : case TemplateArgument::Pack:
1934 0: Output = TemplateArgumentLoc(Arg, TemplateArgumentLocInfo());
1935 : break;
1936 : }
1937 1: }
1938 :
1939 : template<typename Derived>
1940 : bool TreeTransform<Derived>::TransformTemplateArgument(
1941 : const TemplateArgumentLoc &Input,
1942 2300: TemplateArgumentLoc &Output) {
1943 2300: const TemplateArgument &Arg = Input.getArgument();
0: branch 1 not taken
1113: branch 2 taken
0: branch 3 not taken
3: branch 4 taken
1184: branch 5 taken
0: branch 6 not taken
0: branch 7 not taken
1944 2300: switch (Arg.getKind()) {
1945 : case TemplateArgument::Null:
1946 : case TemplateArgument::Integral:
1947 0: Output = Input;
1948 0: return false;
1949 :
1950 : case TemplateArgument::Type: {
1951 1113: TypeSourceInfo *DI = Input.getTypeSourceInfo();
737: branch 0 taken
376: branch 1 taken
1952 1113: if (DI == NULL)
1953 737: DI = InventTypeSourceInfo(Input.getArgument().getAsType());
1954 :
1955 1113: DI = getDerived().TransformType(DI);
1: branch 0 taken
1112: branch 1 taken
1956 1113: if (!DI) return true;
1957 :
1958 1112: Output = TemplateArgumentLoc(TemplateArgument(DI->getType()), DI);
1959 1112: return false;
1960 : }
1961 :
1962 : case TemplateArgument::Declaration: {
1963 : // FIXME: we should never have to transform one of these.
1964 0: DeclarationName Name;
0: branch 2 not taken
0: branch 3 not taken
1965 0: if (NamedDecl *ND = dyn_cast<NamedDecl>(Arg.getAsDecl()))
1966 0: Name = ND->getDeclName();
1967 0: TemporaryBase Rebase(*this, Input.getLocation(), Name);
1968 0: Decl *D = getDerived().TransformDecl(Arg.getAsDecl());
0: branch 0 not taken
0: branch 1 not taken
1969 0: if (!D) return true;
1970 :
1971 0: Expr *SourceExpr = Input.getSourceDeclExpression();
0: branch 0 not taken
0: branch 1 not taken
1972 0: if (SourceExpr) {
1973 : EnterExpressionEvaluationContext Unevaluated(getSema(),
1974 0: Action::Unevaluated);
1975 0: Sema::OwningExprResult E = getDerived().TransformExpr(SourceExpr);
0: branch 1 not taken
0: branch 2 not taken
1976 0: if (E.isInvalid())
1977 0: SourceExpr = NULL;
1978 : else {
1979 0: SourceExpr = E.takeAs<Expr>();
1980 0: SourceExpr->Retain();
1981 : }
1982 : }
1983 :
1984 0: Output = TemplateArgumentLoc(TemplateArgument(D), SourceExpr);
1985 0: return false;
1986 : }
1987 :
1988 : case TemplateArgument::Template: {
1989 3: TemporaryBase Rebase(*this, Input.getLocation(), DeclarationName());
1990 : TemplateName Template
1991 3: = getDerived().TransformTemplateName(Arg.getAsTemplate());
0: branch 1 not taken
3: branch 2 taken
1992 3: if (Template.isNull())
1993 0: return true;
1994 :
1995 3: Output = TemplateArgumentLoc(TemplateArgument(Template),
1996 : Input.getTemplateQualifierRange(),
1997 : Input.getTemplateNameLoc());
1998 3: return false;
1999 : }
2000 :
2001 : case TemplateArgument::Expression: {
2002 : // Template argument expressions are not potentially evaluated.
2003 : EnterExpressionEvaluationContext Unevaluated(getSema(),
2004 1184: Action::Unevaluated);
2005 :
2006 1184: Expr *InputExpr = Input.getSourceExpression();
895: branch 0 taken
289: branch 1 taken
2007 1184: if (!InputExpr) InputExpr = Input.getArgument().getAsExpr();
2008 :
2009 : Sema::OwningExprResult E
2010 1184: = getDerived().TransformExpr(InputExpr);
0: branch 1 not taken
1184: branch 2 taken
2011 1184: if (E.isInvalid()) return true;
2012 :
2013 1184: Expr *ETaken = E.takeAs<Expr>();
2014 1184: ETaken->Retain();
2015 1184: Output = TemplateArgumentLoc(TemplateArgument(ETaken), ETaken);
2016 1184: return false;
2017 : }
2018 :
2019 : case TemplateArgument::Pack: {
2020 0: llvm::SmallVector<TemplateArgument, 4> TransformedArgs;
2021 0: TransformedArgs.reserve(Arg.pack_size());
0: branch 2 not taken
0: branch 3 not taken
0: branch 5 not taken
0: branch 6 not taken
0: branch 7 not taken
0: branch 8 not taken
2022 0: for (TemplateArgument::pack_iterator A = Arg.pack_begin(),
2023 0: AEnd = Arg.pack_end();
2024 : A != AEnd; ++A) {
2025 :
2026 : // FIXME: preserve source information here when we start
2027 : // caring about parameter packs.
2028 :
2029 0: TemplateArgumentLoc InputArg;
2030 0: TemplateArgumentLoc OutputArg;
2031 0: getDerived().InventTemplateArgumentLoc(*A, InputArg);
0: branch 2 not taken
0: branch 3 not taken
2032 0: if (getDerived().TransformTemplateArgument(InputArg, OutputArg))
2033 0: return true;
2034 :
2035 0: TransformedArgs.push_back(OutputArg.getArgument());
2036 : }
2037 0: TemplateArgument Result;
2038 0: Result.setArgumentPack(TransformedArgs.data(), TransformedArgs.size(),
2039 : true);
2040 0: Output = TemplateArgumentLoc(Result, Input.getLocInfo());
2041 0: return false;
2042 : }
2043 : }
2044 :
2045 : // Work around bogus GCC warning
2046 0: return true;
2047 : }
2048 :
2049 : //===----------------------------------------------------------------------===//
2050 : // Type transformation
2051 : //===----------------------------------------------------------------------===//
2052 :
2053 : template<typename Derived>
2054 1903: QualType TreeTransform<Derived>::TransformType(QualType T) {
60: branch 2 taken
1843: branch 3 taken
2055 1903: if (getDerived().AlreadyTransformed(T))
2056 60: return T;
2057 :
2058 : // Temporary workaround. All of these transformations should
2059 : // eventually turn into transformations on TypeLocs.
2060 1843: TypeSourceInfo *DI = getSema().Context.CreateTypeSourceInfo(T);
2061 1843: DI->getTypeLoc().initialize(getDerived().getBaseLocation());
2062 :
2063 1843: TypeSourceInfo *NewDI = getDerived().TransformType(DI);
2064 :
5: branch 0 taken
1838: branch 1 taken
2065 1843: if (!NewDI)
2066 5: return QualType();
2067 :
2068 1838: return NewDI->getType();
2069 : }
2070 :
2071 : template<typename Derived>
2072 4606: TypeSourceInfo *TreeTransform<Derived>::TransformType(TypeSourceInfo *DI) {
88: branch 3 taken
4518: branch 4 taken
2073 4606: if (getDerived().AlreadyTransformed(DI->getType()))
2074 88: return DI;
2075 :
2076 4518: TypeLocBuilder TLB;
2077 :
2078 4518: TypeLoc TL = DI->getTypeLoc();
2079 4518: TLB.reserve(TL.getFullDataSize());
2080 :
2081 4518: QualType Result = getDerived().TransformType(TLB, TL);
48: branch 1 taken
4470: branch 2 taken
2082 4518: if (Result.isNull())
2083 48: return 0;
2084 :
2085 4470: return TLB.getTypeSourceInfo(SemaRef.Context, Result);
2086 : }
2087 :
2088 : template<typename Derived>
2089 : QualType
2090 5560: TreeTransform<Derived>::TransformType(TypeLocBuilder &TLB, TypeLoc T) {
190: branch 1 taken
57: branch 2 taken
0: branch 3 not taken
443: branch 4 taken
3: branch 5 taken
283: branch 6 taken
3: branch 7 taken
28: branch 8 taken
7: branch 9 taken
5: branch 10 taken
0: branch 11 not taken
54: branch 12 taken
6: branch 13 taken
0: branch 14 not taken
0: branch 15 not taken
26: branch 16 taken
0: branch 17 not taken
1: branch 18 taken
68: branch 19 taken
2: branch 20 taken
2: branch 21 taken
2: branch 22 taken
38: branch 23 taken
11: branch 24 taken
24: branch 25 taken
2847: branch 26 taken
0: branch 27 not taken
1319: branch 28 taken
0: branch 29 not taken
141: branch 30 taken
0: branch 31 not taken
0: branch 32 not taken
0: branch 33 not taken
2091 5560: switch (T.getTypeLocClass()) {
2092 : #define ABSTRACT_TYPELOC(CLASS, PARENT)
2093 : #define TYPELOC(CLASS, PARENT) \
2094 : case TypeLoc::CLASS: \
2095 : return getDerived().Transform##CLASS##Type(TLB, cast<CLASS##TypeLoc>(T));
2096 : #include "clang/AST/TypeLocNodes.def"
2097 : }
2098 :
2099 0: llvm_unreachable("unhandled type loc!");
2100 : return QualType();
2101 : }
2102 :
2103 : /// FIXME: By default, this routine adds type qualifiers only to types
2104 : /// that can have qualifiers, and silently suppresses those qualifiers
2105 : /// that are not permitted (e.g., qualifiers on reference or function
2106 : /// types). This is the right thing for template instantiation, but
2107 : /// probably not for other clients.
2108 : template<typename Derived>
2109 : QualType
2110 : TreeTransform<Derived>::TransformQualifiedType(TypeLocBuilder &TLB,
2111 190: QualifiedTypeLoc T) {
2112 190: Qualifiers Quals = T.getType().getLocalQualifiers();
2113 :
2114 190: QualType Result = getDerived().TransformType(TLB, T.getUnqualifiedLoc());
0: branch 1 not taken
190: branch 2 taken
2115 190: if (Result.isNull())
2116 0: return QualType();
2117 :
2118 : // Silently suppress qualifiers if the result type can't be qualified.
2119 : // FIXME: this is the right thing for template instantiation, but
2120 : // probably not for other clients.
190: branch 2 taken
0: branch 3 not taken
2: branch 6 taken
188: branch 7 taken
2: branch 8 taken
188: branch 9 taken
2121 190: if (Result->isFunctionType() || Result->isReferenceType())
2122 2: return Result;
2123 :
2124 188: Result = SemaRef.Context.getQualifiedType(Result, Quals);
2125 :
2126 188: TLB.push<QualifiedTypeLoc>(Result);
2127 :
2128 : // No location information to preserve.
2129 :
2130 188: return Result;
2131 : }
2132 :
2133 : template <class TyLoc> static inline
2134 46: QualType TransformTypeSpecType(TypeLocBuilder &TLB, TyLoc T) {
2135 46: TyLoc NewT = TLB.push<TyLoc>(T.getType());
2136 46: NewT.setNameLoc(T.getNameLoc());
2137 46: return T.getType();
2138 : }
2139 :
2140 : // Ugly metaprogramming macros because I couldn't be bothered to make
2141 : // the equivalent template version work.
2142 : #define TransformPointerLikeType(TypeClass) do { \
2143 : QualType PointeeType \
2144 : = getDerived().TransformType(TLB, TL.getPointeeLoc()); \
2145 : if (PointeeType.isNull()) \
2146 : return QualType(); \
2147 : \
2148 : QualType Result = TL.getType(); \
2149 : if (getDerived().AlwaysRebuild() || \
2150 : PointeeType != TL.getPointeeLoc().getType()) { \
2151 : Result = getDerived().Rebuild##TypeClass(PointeeType, \
2152 : TL.getSigilLoc()); \
2153 : if (Result.isNull()) \
2154 : return QualType(); \
2155 : } \
2156 : \
2157 : TypeClass##Loc NewT = TLB.push<TypeClass##Loc>(Result); \
2158 : NewT.setSigilLoc(TL.getSigilLoc()); \
2159 : \
2160 : return Result; \
2161 : } while(0)
2162 :
2163 : template<typename Derived>
2164 : QualType TreeTransform<Derived>::TransformBuiltinType(TypeLocBuilder &TLB,
2165 57: BuiltinTypeLoc T) {
2166 57: BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
2167 57: NewT.setBuiltinLoc(T.getBuiltinLoc());
41: branch 1 taken
16: branch 2 taken
2168 57: if (T.needsExtraLocalData())
2169 41: NewT.getWrittenBuiltinSpecs() = T.getWrittenBuiltinSpecs();
2170 57: return T.getType();
2171 : }
2172 :
2173 : template<typename Derived>
2174 : QualType TreeTransform<Derived>::TransformComplexType(TypeLocBuilder &TLB,
2175 0: ComplexTypeLoc T) {
2176 : // FIXME: recurse?
2177 0: return TransformTypeSpecType(TLB, T);
2178 : }
2179 :
2180 : template<typename Derived>
2181 : QualType TreeTransform<Derived>::TransformPointerType(TypeLocBuilder &TLB,
2182 443: PointerTypeLoc TL) {
3: branch 4 taken
440: branch 5 taken
440: branch 10 taken
0: branch 11 not taken
439: branch 15 taken
1: branch 16 taken
439: branch 17 taken
1: branch 18 taken
12: branch 23 taken
427: branch 24 taken
2183 443: TransformPointerLikeType(PointerType);
2184 : }
2185 :
2186 : template<typename Derived>
2187 : QualType
2188 : TreeTransform<Derived>::TransformBlockPointerType(TypeLocBuilder &TLB,
2189 3: BlockPointerTypeLoc TL) {
0: branch 4 not taken
3: branch 5 taken
3: branch 10 taken
0: branch 11 not taken
3: branch 15 taken
0: branch 16 not taken
3: branch 17 taken
0: branch 18 not taken
0: branch 23 not taken
3: branch 24 taken
2190 3: TransformPointerLikeType(BlockPointerType);
2191 : }
2192 :
2193 : /// Transforms a reference type. Note that somewhat paradoxically we
2194 : /// don't care whether the type itself is an l-value type or an r-value
2195 : /// type; we only care if the type was *written* as an l-value type
2196 : /// or an r-value type.
2197 : template<typename Derived>
2198 : QualType
2199 : TreeTransform<Derived>::TransformReferenceType(TypeLocBuilder &TLB,
2200 286: ReferenceTypeLoc TL) {
2201 286: const ReferenceType *T = TL.getTypePtr();
2202 :
2203 : // Note that this works with the pointee-as-written.
2204 286: QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
0: branch 1 not taken
286: branch 2 taken
2205 286: if (PointeeType.isNull())
2206 0: return QualType();
2207 :
2208 286: QualType Result = TL.getType();
286: branch 2 taken
0: branch 3 not taken
283: branch 6 taken
3: branch 7 taken
283: branch 8 taken
3: branch 9 taken
2209 286: if (getDerived().AlwaysRebuild() ||
2210 : PointeeType != T->getPointeeTypeAsWritten()) {
2211 283: Result = getDerived().RebuildReferenceType(PointeeType,
2212 : T->isSpelledAsLValue(),
2213 : TL.getSigilLoc());
2: branch 1 taken
281: branch 2 taken
2214 283: if (Result.isNull())
2215 2: return QualType();
2216 : }
2217 :
2218 : // r-value references can be rebuilt as l-value references.
2219 284: ReferenceTypeLoc NewTL;
282: branch 1 taken
2: branch 2 taken
2220 284: if (isa<LValueReferenceType>(Result))
2221 282: NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
2222 : else
2223 2: NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
2224 284: NewTL.setSigilLoc(TL.getSigilLoc());
2225 :
2226 284: return Result;
2227 : }
2228 :
2229 : template<typename Derived>
2230 : QualType
2231 : TreeTransform<Derived>::TransformLValueReferenceType(TypeLocBuilder &TLB,
2232 283: LValueReferenceTypeLoc TL) {
2233 283: return TransformReferenceType(TLB, TL);
2234 : }
2235 :
2236 : template<typename Derived>
2237 : QualType
2238 : TreeTransform<Derived>::TransformRValueReferenceType(TypeLocBuilder &TLB,
2239 3: RValueReferenceTypeLoc TL) {
2240 3: return TransformReferenceType(TLB, TL);
2241 : }
2242 :
2243 : template<typename Derived>
2244 : QualType
2245 : TreeTransform<Derived>::TransformMemberPointerType(TypeLocBuilder &TLB,
2246 28: MemberPointerTypeLoc TL) {
2247 28: MemberPointerType *T = TL.getTypePtr();
2248 :
2249 28: QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
0: branch 1 not taken
28: branch 2 taken
2250 28: if (PointeeType.isNull())
2251 0: return QualType();
2252 :
2253 : // TODO: preserve source information for this.
2254 : QualType ClassType
2255 28: = getDerived().TransformType(QualType(T->getClass(), 0));
0: branch 1 not taken
28: branch 2 taken
2256 28: if (ClassType.isNull())
2257 0: return QualType();
2258 :
2259 28: QualType Result = TL.getType();
28: branch 2 taken
0: branch 3 not taken
9: branch 6 taken
19: branch 7 taken
9: branch 11 taken
0: branch 12 not taken
28: branch 13 taken
0: branch 14 not taken
2260 28: if (getDerived().AlwaysRebuild() ||
2261 : PointeeType != T->getPointeeType() ||
2262 : ClassType != QualType(T->getClass(), 0)) {
2263 28: Result = getDerived().RebuildMemberPointerType(PointeeType, ClassType,
2264 : TL.getStarLoc());
5: branch 1 taken
23: branch 2 taken
2265 28: if (Result.isNull())
2266 5: return QualType();
2267 : }
2268 :
2269 23: MemberPointerTypeLoc NewTL = TLB.push<MemberPointerTypeLoc>(Result);
2270 23: NewTL.setSigilLoc(TL.getSigilLoc());
2271 :
2272 23: return Result;
2273 : }
2274 :
2275 : template<typename Derived>
2276 : QualType
2277 : TreeTransform<Derived>::TransformConstantArrayType(TypeLocBuilder &TLB,
2278 7: ConstantArrayTypeLoc TL) {
2279 7: ConstantArrayType *T = TL.getTypePtr();
2280 7: QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
0: branch 1 not taken
7: branch 2 taken
2281 7: if (ElementType.isNull())
2282 0: return QualType();
2283 :
2284 7: QualType Result = TL.getType();
7: branch 2 taken
0: branch 3 not taken
7: branch 6 taken
0: branch 7 not taken
7: branch 8 taken
0: branch 9 not taken
2285 7: if (getDerived().AlwaysRebuild() ||
2286 : ElementType != T->getElementType()) {
2287 7: Result = getDerived().RebuildConstantArrayType(ElementType,
2288 : T->getSizeModifier(),
2289 : T->getSize(),
2290 : T->getIndexTypeCVRQualifiers(),
2291 : TL.getBracketsRange());
1: branch 1 taken
6: branch 2 taken
2292 7: if (Result.isNull())
2293 1: return QualType();
2294 : }
2295 :
2296 6: ConstantArrayTypeLoc NewTL = TLB.push<ConstantArrayTypeLoc>(Result);
2297 6: NewTL.setLBracketLoc(TL.getLBracketLoc());
2298 6: NewTL.setRBracketLoc(TL.getRBracketLoc());
2299 :
2300 6: Expr *Size = TL.getSizeExpr();
5: branch 0 taken
1: branch 1 taken
2301 6: if (Size) {
2302 5: EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
2303 5: Size = getDerived().TransformExpr(Size).template takeAs<Expr>();
2304 : }
2305 6: NewTL.setSizeExpr(Size);
2306 :
2307 6: return Result;
2308 : }
2309 :
2310 : template<typename Derived>
2311 : QualType TreeTransform<Derived>::TransformIncompleteArrayType(
2312 : TypeLocBuilder &TLB,
2313 5: IncompleteArrayTypeLoc TL) {
2314 5: IncompleteArrayType *T = TL.getTypePtr();
2315 5: QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
0: branch 1 not taken
5: branch 2 taken
2316 5: if (ElementType.isNull())
2317 0: return QualType();
2318 :
2319 5: QualType Result = TL.getType();
5: branch 2 taken
0: branch 3 not taken
5: branch 6 taken
0: branch 7 not taken
5: branch 8 taken
0: branch 9 not taken
2320 5: if (getDerived().AlwaysRebuild() ||
2321 : ElementType != T->getElementType()) {
2322 5: Result = getDerived().RebuildIncompleteArrayType(ElementType,
2323 : T->getSizeModifier(),
2324 : T->getIndexTypeCVRQualifiers(),
2325 : TL.getBracketsRange());
0: branch 1 not taken
5: branch 2 taken
2326 5: if (Result.isNull())
2327 0: return QualType();
2328 : }
2329 :
2330 5: IncompleteArrayTypeLoc NewTL = TLB.push<IncompleteArrayTypeLoc>(Result);
2331 5: NewTL.setLBracketLoc(TL.getLBracketLoc());
2332 5: NewTL.setRBracketLoc(TL.getRBracketLoc());
2333 5: NewTL.setSizeExpr(0);
2334 :
2335 5: return Result;
2336 : }
2337 :
2338 : template<typename Derived>
2339 : QualType
2340 : TreeTransform<Derived>::TransformVariableArrayType(TypeLocBuilder &TLB,
2341 0: VariableArrayTypeLoc TL) {
2342 0: VariableArrayType *T = TL.getTypePtr();
2343 0: QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
0: branch 1 not taken
0: branch 2 not taken
2344 0: if (ElementType.isNull())
2345 0: return QualType();
2346 :
2347 : // Array bounds are not potentially evaluated contexts
2348 0: EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
2349 :
2350 : Sema::OwningExprResult SizeResult
2351 0: = getDerived().TransformExpr(T->getSizeExpr());
0: branch 1 not taken
0: branch 2 not taken
2352 0: if (SizeResult.isInvalid())
2353 0: return QualType();
2354 :
2355 0: Expr *Size = static_cast<Expr*>(SizeResult.get());
2356 :
2357 0: QualType Result = TL.getType();
0: branch 2 not taken
0: branch 3 not taken
0: branch 6 not taken
0: branch 7 not taken
0: branch 9 not taken
0: branch 10 not taken
0: branch 11 not taken
0: branch 12 not taken
2358 0: if (getDerived().AlwaysRebuild() ||
2359 : ElementType != T->getElementType() ||
2360 : Size != T->getSizeExpr()) {
2361 0: Result = getDerived().RebuildVariableArrayType(ElementType,
2362 : T->getSizeModifier(),
2363 : move(SizeResult),
2364 : T->getIndexTypeCVRQualifiers(),
2365 : TL.getBracketsRange());
0: branch 1 not taken
0: branch 2 not taken
2366 0: if (Result.isNull())
2367 0: return QualType();
2368 : }
2369 0: else SizeResult.take();
2370 :
2371 0: VariableArrayTypeLoc NewTL = TLB.push<VariableArrayTypeLoc>(Result);
2372 0: NewTL.setLBracketLoc(TL.getLBracketLoc());
2373 0: NewTL.setRBracketLoc(TL.getRBracketLoc());
2374 0: NewTL.setSizeExpr(Size);
2375 :
2376 0: return Result;
2377 : }
2378 :
2379 : template<typename Derived>
2380 : QualType
2381 : TreeTransform<Derived>::TransformDependentSizedArrayType(TypeLocBuilder &TLB,
2382 54: DependentSizedArrayTypeLoc TL) {
2383 54: DependentSizedArrayType *T = TL.getTypePtr();
2384 54: QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
0: branch 1 not taken
54: branch 2 taken
2385 54: if (ElementType.isNull())
2386 0: return QualType();
2387 :
2388 : // Array bounds are not potentially evaluated contexts
2389 54: EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
2390 :
2391 : Sema::OwningExprResult SizeResult
2392 54: = getDerived().TransformExpr(T->getSizeExpr());
0: branch 1 not taken
54: branch 2 taken
2393 54: if (SizeResult.isInvalid())
2394 0: return QualType();
2395 :
2396 54: Expr *Size = static_cast<Expr*>(SizeResult.get());
2397 :
2398 54: QualType Result = TL.getType();
54: branch 2 taken
0: branch 3 not taken
42: branch 6 taken
12: branch 7 taken
42: branch 9 taken
0: branch 10 not taken
54: branch 11 taken
0: branch 12 not taken
2399 54: if (getDerived().AlwaysRebuild() ||
2400 : ElementType != T->getElementType() ||
2401 : Size != T->getSizeExpr()) {
2402 54: Result = getDerived().RebuildDependentSizedArrayType(ElementType,
2403 : T->getSizeModifier(),
2404 : move(SizeResult),
2405 : T->getIndexTypeCVRQualifiers(),
2406 : TL.getBracketsRange());
8: branch 1 taken
46: branch 2 taken
2407 54: if (Result.isNull())
2408 8: return QualType();
2409 : }
2410 0: else SizeResult.take();
2411 :
2412 : // We might have any sort of array type now, but fortunately they
2413 : // all have the same location layout.
2414 46: ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
2415 46: NewTL.setLBracketLoc(TL.getLBracketLoc());
2416 46: NewTL.setRBracketLoc(TL.getRBracketLoc());
2417 46: NewTL.setSizeExpr(Size);
2418 :
2419 46: return Result;
2420 : }
2421 :
2422 : template<typename Derived>
2423 : QualType TreeTransform<Derived>::TransformDependentSizedExtVectorType(
2424 : TypeLocBuilder &TLB,
2425 6: DependentSizedExtVectorTypeLoc TL) {
2426 6: DependentSizedExtVectorType *T = TL.getTypePtr();
2427 :
2428 : // FIXME: ext vector locs should be nested
2429 6: QualType ElementType = getDerived().TransformType(T->getElementType());
0: branch 1 not taken
6: branch 2 taken
2430 6: if (ElementType.isNull())
2431 0: return QualType();
2432 :
2433 : // Vector sizes are not potentially evaluated contexts
2434 6: EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
2435 :
2436 6: Sema::OwningExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
0: branch 1 not taken
6: branch 2 taken
2437 6: if (Size.isInvalid())
2438 0: return QualType();
2439 :
2440 6: QualType Result = TL.getType();
6: branch 2 taken
0: branch 3 not taken
2: branch 6 taken
4: branch 7 taken
2: branch 10 taken
0: branch 11 not taken
6: branch 12 taken
0: branch 13 not taken
2441 6: if (getDerived().AlwaysRebuild() ||
2442 : ElementType != T->getElementType() ||
2443 : Size.get() != T->getSizeExpr()) {
2444 6: Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
2445 : move(Size),
2446 : T->getAttributeLoc());
2: branch 1 taken
4: branch 2 taken
2447 6: if (Result.isNull())
2448 2: return QualType();
2449 : }
2450 0: else Size.take();
2451 :
2452 : // Result might be dependent or not.
0: branch 1 not taken
4: branch 2 taken
2453 4: if (isa<DependentSizedExtVectorType>(Result)) {
2454 : DependentSizedExtVectorTypeLoc NewTL
2455 0: = TLB.push<DependentSizedExtVectorTypeLoc>(Result);
2456 0: NewTL.setNameLoc(TL.getNameLoc());
2457 : } else {
2458 4: ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
2459 4: NewTL.setNameLoc(TL.getNameLoc());
2460 : }
2461 :
2462 4: return Result;
2463 : }
2464 :
2465 : template<typename Derived>
2466 : QualType TreeTransform<Derived>::TransformVectorType(TypeLocBuilder &TLB,
2467 0: VectorTypeLoc TL) {
2468 0: VectorType *T = TL.getTypePtr();
2469 0: QualType ElementType = getDerived().TransformType(T->getElementType());
0: branch 1 not taken
0: branch 2 not taken
2470 0: if (ElementType.isNull())
2471 0: return QualType();
2472 :
2473 0: QualType Result = TL.getType();
0: branch 2 not taken
0: branch 3 not taken
0: branch 6 not taken
0: branch 7 not taken
0: branch 8 not taken
0: branch 9 not taken
2474 0: if (getDerived().AlwaysRebuild() ||
2475 : ElementType != T->getElementType()) {
2476 0: Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
2477 : T->isAltiVec(), T->isPixel());
0: branch 1 not taken
0: branch 2 not taken
2478 0: if (Result.isNull())
2479 0: return QualType();
2480 : }
2481 :
2482 0: VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
2483 0: NewTL.setNameLoc(TL.getNameLoc());
2484 :
2485 0: return Result;
2486 : }
2487 :
2488 : template<typename Derived>
2489 : QualType TreeTransform<Derived>::TransformExtVectorType(TypeLocBuilder &TLB,
2490 0: ExtVectorTypeLoc TL) {
2491 0: VectorType *T = TL.getTypePtr();
2492 0: QualType ElementType = getDerived().TransformType(T->getElementType());
0: branch 1 not taken
0: branch 2 not taken
2493 0: if (ElementType.isNull())
2494 0: return QualType();
2495 :
2496 0: QualType Result = TL.getType();
0: branch 2 not taken
0: branch 3 not taken
0: branch 6 not taken
0: branch 7 not taken
0: branch 8 not taken
0: branch 9 not taken
2497 0: if (getDerived().AlwaysRebuild() ||
2498 : ElementType != T->getElementType()) {
2499 0: Result = getDerived().RebuildExtVectorType(ElementType,
2500 : T->getNumElements(),
2501 : /*FIXME*/ SourceLocation());
0: branch 1 not taken
0: branch 2 not taken
2502 0: if (Result.isNull())
2503 0: return QualType();
2504 : }
2505 :
2506 0: ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
2507 0: NewTL.setNameLoc(TL.getNameLoc());
2508 :
2509 0: return Result;
2510 : }
2511 :
2512 : template<typename Derived>
2513 : QualType
2514 : TreeTransform<Derived>::TransformFunctionProtoType(TypeLocBuilder &TLB,
2515 26: FunctionProtoTypeLoc TL) {
2516 26: FunctionProtoType *T = TL.getTypePtr();
2517 26: QualType ResultType = getDerived().TransformType(TLB, TL.getResultLoc());
0: branch 1 not taken
26: branch 2 taken
2518 26: if (ResultType.isNull())
2519 0: return QualType();
2520 :
2521 : // Transform the parameters.
2522 26: llvm::SmallVector<QualType, 4> ParamTypes;
2523 26: llvm::SmallVector<ParmVarDecl*, 4> ParamDecls;
25: branch 1 taken
26: branch 2 taken
2524 51: for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i) {
2525 25: ParmVarDecl *OldParm = TL.getArg(i);
2526 :
2527 25: QualType NewType;
2528 : ParmVarDecl *NewParm;
2529 :
20: branch 0 taken
5: branch 1 taken
2530 25: if (OldParm) {
2531 20: TypeSourceInfo *OldDI = OldParm->getTypeSourceInfo();
0: branch 3 not taken
20: branch 4 taken
2532 20: assert(OldDI->getType() == T->getArgType(i));
2533 :
2534 20: TypeSourceInfo *NewDI = getDerived().TransformType(OldDI);
0: branch 0 not taken
20: branch 1 taken
2535 20: if (!NewDI)
2536 0: return QualType();
2537 :
0: branch 0 not taken
20: branch 1 taken
2538 20: if (NewDI == OldDI)
2539 0: NewParm = OldParm;
2540 : else
2541 20: NewParm = ParmVarDecl::Create(SemaRef.Context,
2542 : OldParm->getDeclContext(),
2543 : OldParm->getLocation(),
2544 : OldParm->getIdentifier(),
2545 : NewDI->getType(),
2546 : NewDI,
2547 : OldParm->getStorageClass(),
2548 : /* DefArg */ NULL);
2549 20: NewType = NewParm->getType();
2550 :
2551 : // Deal with the possibility that we don't have a parameter
2552 : // declaration for this parameter.
2553 : } else {
2554 5: NewParm = 0;
2555 :
2556 5: QualType OldType = T->getArgType(i);
2557 5: NewType = getDerived().TransformType(OldType);
0: branch 1 not taken
5: branch 2 taken
2558 5: if (NewType.isNull())
2559 0: return QualType();
2560 : }
2561 :
2562 25: ParamTypes.push_back(NewType);
2563 25: ParamDecls.push_back(NewParm);
2564 : }
2565 :
2566 26: QualType Result = TL.getType();
26: branch 2 taken
0: branch 3 not taken
7: branch 6 taken
19: branch 7 taken
6: branch 12 taken
1: branch 13 taken
25: branch 14 taken
1: branch 15 taken
2567 26: if (getDerived().AlwaysRebuild() ||
2568 : ResultType != T->getResultType() ||
2569 : !std::equal(T->arg_type_begin(), T->arg_type_end(), ParamTypes.begin())) {
2570 25: Result = getDerived().RebuildFunctionProtoType(ResultType,
2571 : ParamTypes.data(),
2572 : ParamTypes.size(),
2573 : T->isVariadic(),
2574 : T->getTypeQuals());
0: branch 1 not taken
25: branch 2 taken
2575 25: if (Result.isNull())
2576 0: return QualType();
2577 : }
2578 :
2579 26: FunctionProtoTypeLoc NewTL = TLB.push<FunctionProtoTypeLoc>(Result);
2580 26: NewTL.setLParenLoc(TL.getLParenLoc());
2581 26: NewTL.setRParenLoc(TL.getRParenLoc());
25: branch 1 taken
26: branch 2 taken
2582 51: for (unsigned i = 0, e = NewTL.getNumArgs(); i != e; ++i)
2583 25: NewTL.setArg(i, ParamDecls[i]);
2584 :
2585 26: return Result;
2586 : }
2587 :
2588 : template<typename Derived>
2589 : QualType TreeTransform<Derived>::TransformFunctionNoProtoType(
2590 : TypeLocBuilder &TLB,
2591 0: FunctionNoProtoTypeLoc TL) {
2592 0: FunctionNoProtoType *T = TL.getTypePtr();
2593 0: QualType ResultType = getDerived().TransformType(TLB, TL.getResultLoc());
0: branch 1 not taken
0: branch 2 not taken
2594 0: if (ResultType.isNull())
2595 0: return QualType();
2596 :
2597 0: QualType Result = TL.getType();
0: branch 2 not taken
0: branch 3 not taken
0: branch 6 not taken
0: branch 7 not taken
0: branch 8 not taken
0: branch 9 not taken
2598 0: if (getDerived().AlwaysRebuild() ||
2599 : ResultType != T->getResultType())
2600 0: Result = getDerived().RebuildFunctionNoProtoType(ResultType);
2601 :
2602 0: FunctionNoProtoTypeLoc NewTL = TLB.push<FunctionNoProtoTypeLoc>(Result);
2603 0: NewTL.setLParenLoc(TL.getLParenLoc());
2604 0: NewTL.setRParenLoc(TL.getRParenLoc());
2605 :
2606 0: return Result;
2607 : }
2608 :
2609 : template<typename Derived> QualType
2610 : TreeTransform<Derived>::TransformUnresolvedUsingType(TypeLocBuilder &TLB,
2611 1: UnresolvedUsingTypeLoc TL) {
2612 1: UnresolvedUsingType *T = TL.getTypePtr();
2613 1: Decl *D = getDerived().TransformDecl(T->getDecl());
0: branch 0 not taken
1: branch 1 taken
2614 1: if (!D)
2615 0: return QualType();
2616 :
2617 1: QualType Result = TL.getType();
1: branch 2 taken
0: branch 3 not taken
1: branch 5 taken
0: branch 6 not taken
1: branch 7 taken
0: branch 8 not taken
2618 1: if (getDerived().AlwaysRebuild() || D != T->getDecl()) {
2619 1: Result = getDerived().RebuildUnresolvedUsingType(D);
0: branch 1 not taken
1: branch 2 taken
2620 1: if (Result.isNull())
2621 0: return QualType();
2622 : }
2623 :
2624 : // We might get an arbitrary type spec type back. We should at
2625 : // least always get a type spec type, though.
2626 1: TypeSpecTypeLoc NewTL = TLB.pushTypeSpec(Result);
2627 1: NewTL.setNameLoc(TL.getNameLoc());
2628 :
2629 1: return Result;
2630 : }
2631 :
2632 : template<typename Derived>
2633 : QualType TreeTransform<Derived>::TransformTypedefType(TypeLocBuilder &TLB,
2634 68: TypedefTypeLoc TL) {
2635 68: TypedefType *T = TL.getTypePtr();
2636 : TypedefDecl *Typedef
2637 68: = cast_or_null<TypedefDecl>(getDerived().TransformDecl(T->getDecl()));
0: branch 0 not taken
68: branch 1 taken
2638 68: if (!Typedef)
2639 0: return QualType();
2640 :
2641 68: QualType Result = TL.getType();
68: branch 2 taken
0: branch 3 not taken
66: branch 5 taken
2: branch 6 taken
66: branch 7 taken
2: branch 8 taken
2642 68: if (getDerived().AlwaysRebuild() ||
2643 : Typedef != T->getDecl()) {
2644 66: Result = getDerived().RebuildTypedefType(Typedef);
0: branch 1 not taken
66: branch 2 taken
2645 66: if (Result.isNull())
2646 0: return QualType();
2647 : }
2648 :
2649 68: TypedefTypeLoc NewTL = TLB.push<TypedefTypeLoc>(Result);
2650 68: NewTL.setNameLoc(TL.getNameLoc());
2651 :
2652 68: return Result;
2653 : }
2654 :
2655 : template<typename Derived>
2656 : QualType TreeTransform<Derived>::TransformTypeOfExprType(TypeLocBuilder &TLB,
2657 2: TypeOfExprTypeLoc TL) {
2658 : // typeof expressions are not potentially evaluated contexts
2659 2: EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
2660 :
2661 2: Sema::OwningExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
0: branch 1 not taken
2: branch 2 taken
2662 2: if (E.isInvalid())
2663 0: return QualType();
2664 :
2665 2: QualType Result = TL.getType();
2: branch 2 taken
0: branch 3 not taken
2: branch 6 taken
0: branch 7 not taken
2: branch 8 taken
0: branch 9 not taken
2666 2: if (getDerived().AlwaysRebuild() ||
2667 : E.get() != TL.getUnderlyingExpr()) {
2668 2: Result = getDerived().RebuildTypeOfExprType(move(E));
0: branch 1 not taken
2: branch 2 taken
2669 2: if (Result.isNull())
2670 0: return QualType();
2671 : }
2672 0: else E.take();
2673 :
2674 2: TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
2675 2: NewTL.setTypeofLoc(TL.getTypeofLoc());
2676 2: NewTL.setLParenLoc(TL.getLParenLoc());
2677 2: NewTL.setRParenLoc(TL.getRParenLoc());
2678 :
2679 2: return Result;
2680 : }
2681 :
2682 : template<typename Derived>
2683 : QualType TreeTransform<Derived>::TransformTypeOfType(TypeLocBuilder &TLB,
2684 2: TypeOfTypeLoc TL) {
2685 2: TypeSourceInfo* Old_Under_TI = TL.getUnderlyingTInfo();
2686 2: TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
0: branch 0 not taken
2: branch 1 taken
2687 2: if (!New_Under_TI)
2688 0: return QualType();
2689 :
2690 2: QualType Result = TL.getType();
2: branch 2 taken
0: branch 3 not taken
2: branch 4 taken
0: branch 5 not taken
2: branch 6 taken
0: branch 7 not taken
2691 2: if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
2692 2: Result = getDerived().RebuildTypeOfType(New_Under_TI->getType());
0: branch 1 not taken
2: branch 2 taken
2693 2: if (Result.isNull())
2694 0: return QualType();
2695 : }
2696 :
2697 2: TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
2698 2: NewTL.setTypeofLoc(TL.getTypeofLoc());
2699 2: NewTL.setLParenLoc(TL.getLParenLoc());
2700 2: NewTL.setRParenLoc(TL.getRParenLoc());
2701 2: NewTL.setUnderlyingTInfo(New_Under_TI);
2702 :
2703 2: return Result;
2704 : }
2705 :
2706 : template<typename Derived>
2707 : QualType TreeTransform<Derived>::TransformDecltypeType(TypeLocBuilder &TLB,
2708 2: DecltypeTypeLoc TL) {
2709 2: DecltypeType *T = TL.getTypePtr();
2710 :
2711 : // decltype expressions are not potentially evaluated contexts
2712 2: EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
2713 :
2714 2: Sema::OwningExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
0: branch 1 not taken
2: branch 2 taken
2715 2: if (E.isInvalid())
2716 0: return QualType();
2717 :
2718 2: QualType Result = TL.getType();
2: branch 2 taken
0: branch 3 not taken
2: branch 6 taken
0: branch 7 not taken
2: branch 8 taken
0: branch 9 not taken
2719 2: if (getDerived().AlwaysRebuild() ||
2720 : E.get() != T->getUnderlyingExpr()) {
2721 2: Result = getDerived().RebuildDecltypeType(move(E));
1: branch 1 taken
1: branch 2 taken
2722 2: if (Result.isNull())
2723 1: return QualType();
2724 : }
2725 0: else E.take();
2726 :
2727 1: DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
2728 1: NewTL.setNameLoc(TL.getNameLoc());
2729 :
2730 1: return Result;
2731 : }
2732 :
2733 : template<typename Derived>
2734 : QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB,
2735 38: RecordTypeLoc TL) {
2736 38: RecordType *T = TL.getTypePtr();
2737 : RecordDecl *Record
2738 38: = cast_or_null<RecordDecl>(getDerived().TransformDecl(T->getDecl()));
0: branch 0 not taken
38: branch 1 taken
2739 38: if (!Record)
2740 0: return QualType();
2741 :
2742 38: QualType Result = TL.getType();
38: branch 2 taken
0: branch 3 not taken
38: branch 5 taken
0: branch 6 not taken
38: branch 7 taken
0: branch 8 not taken
2743 38: if (getDerived().AlwaysRebuild() ||
2744 : Record != T->getDecl()) {
2745 38: Result = getDerived().RebuildRecordType(Record);
0: branch 1 not taken
38: branch 2 taken
2746 38: if (Result.isNull())
2747 0: return QualType();
2748 : }
2749 :
2750 38: RecordTypeLoc NewTL = TLB.push<RecordTypeLoc>(Result);
2751 38: NewTL.setNameLoc(TL.getNameLoc());
2752 :
2753 38: return Result;
2754 : }
2755 :
2756 : template<typename Derived>
2757 : QualType TreeTransform<Derived>::TransformEnumType(TypeLocBuilder &TLB,
2758 11: EnumTypeLoc TL) {
2759 11: EnumType *T = TL.getTypePtr();
2760 : EnumDecl *Enum
2761 11: = cast_or_null<EnumDecl>(getDerived().TransformDecl(T->getDecl()));
0: branch 0 not taken
11: branch 1 taken
2762 11: if (!Enum)
2763 0: return QualType();
2764 :
2765 11: QualType Result = TL.getType();
11: branch 2 taken
0: branch 3 not taken
11: branch 5 taken
0: branch 6 not taken
11: branch 7 taken
0: branch 8 not taken
2766 11: if (getDerived().AlwaysRebuild() ||
2767 : Enum != T->getDecl()) {
2768 11: Result = getDerived().RebuildEnumType(Enum);
0: branch 1 not taken
11: branch 2 taken
2769 11: if (Result.isNull())
2770 0: return QualType();
2771 : }
2772 :
2773 11: EnumTypeLoc NewTL = TLB.push<EnumTypeLoc>(Result);
2774 11: NewTL.setNameLoc(TL.getNameLoc());
2775 :
2776 11: return Result;
2777 : }
2778 :
2779 : template <typename Derived>
2780 : QualType TreeTransform<Derived>::TransformElaboratedType(TypeLocBuilder &TLB,
2781 24: ElaboratedTypeLoc TL) {
2782 24: ElaboratedType *T = TL.getTypePtr();
2783 :
2784 : // FIXME: this should be a nested type.
2785 24: QualType Underlying = getDerived().TransformType(T->getUnderlyingType());
1: branch 1 taken
23: branch 2 taken
2786 24: if (Underlying.isNull())
2787 1: return QualType();
2788 :
2789 23: QualType Result = TL.getType();
23: branch 2 taken
0: branch 3 not taken
23: branch 6 taken
0: branch 7 not taken
23: branch 8 taken
0: branch 9 not taken
2790 23: if (getDerived().AlwaysRebuild() ||
2791 : Underlying != T->getUnderlyingType()) {
2792 23: Result = getDerived().RebuildElaboratedType(Underlying, T->getTagKind());
0: branch 1 not taken
23: branch 2 taken
2793 23: if (Result.isNull())
2794 0: return QualType();
2795 : }
2796 :
2797 23: ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
2798 23: NewTL.setNameLoc(TL.getNameLoc());
2799 :
2800 23: return Result;
2801 : }
2802 :
2803 :
2804 : template<typename Derived>
2805 : QualType TreeTransform<Derived>::TransformTemplateTypeParmType(
2806 : TypeLocBuilder &TLB,
2807 46: TemplateTypeParmTypeLoc TL) {
2808 46: return TransformTypeSpecType(TLB, TL);
2809 : }
2810 :
2811 : template<typename Derived>
2812 : QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType(
2813 : TypeLocBuilder &TLB,
2814 0: SubstTemplateTypeParmTypeLoc TL) {
2815 0: return TransformTypeSpecType(TLB, TL);
2816 : }
2817 :
2818 : template<typename Derived>
2819 : inline QualType
2820 : TreeTransform<Derived>::TransformTemplateSpecializationType(
2821 : TypeLocBuilder &TLB,
2822 1319: TemplateSpecializationTypeLoc TL) {
2823 1319: return TransformTemplateSpecializationType(TLB, TL, QualType());
2824 : }
2825 :
2826 : template<typename Derived>
2827 : QualType TreeTransform<Derived>::TransformTemplateSpecializationType(
2828 : const TemplateSpecializationType *TST,
2829 1: QualType ObjectType) {
2830 : // FIXME: this entire method is a temporary workaround; callers
2831 : // should be rewritten to provide real type locs.
2832 :
2833 : // Fake up a TemplateSpecializationTypeLoc.
2834 1: TypeLocBuilder TLB;
2835 : TemplateSpecializationTypeLoc TL
2836 1: = TLB.push<TemplateSpecializationTypeLoc>(QualType(TST, 0));
2837 :
2838 1: SourceLocation BaseLoc = getDerived().getBaseLocation();
2839 :
2840 1: TL.setTemplateNameLoc(BaseLoc);
2841 1: TL.setLAngleLoc(BaseLoc);
2842 1: TL.setRAngleLoc(BaseLoc);
1: branch 2 taken
1: branch 3 taken
2843 2: for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i) {
2844 1: const TemplateArgument &TA = TST->getArg(i);
2845 1: TemplateArgumentLoc TAL;
2846 1: getDerived().InventTemplateArgumentLoc(TA, TAL);
2847 1: TL.setArgLocInfo(i, TAL.getLocInfo());
2848 : }
2849 :
2850 1: TypeLocBuilder IgnoredTLB;
2851 1: return TransformTemplateSpecializationType(IgnoredTLB, TL, ObjectType);
2852 : }
2853 :
2854 : template<typename Derived>
2855 : QualType TreeTransform<Derived>::TransformTemplateSpecializationType(
2856 : TypeLocBuilder &TLB,
2857 : TemplateSpecializationTypeLoc TL,
2858 1320: QualType ObjectType) {
2859 1320: const TemplateSpecializationType *T = TL.getTypePtr();
2860 :
2861 : TemplateName Template
2862 1320: = getDerived().TransformTemplateName(T->getTemplateName(), ObjectType);
1: branch 1 taken
1319: branch 2 taken
2863 1320: if (Template.isNull())
2864 1: return QualType();
2865 :
2866 1319: TemplateArgumentListInfo NewTemplateArgs;
2867 1319: NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
2868 1319: NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
2869 :
1835: branch 2 taken
0: branch 3 not taken
1835: branch 4 taken
1319: branch 5 taken
2870 3154: for (unsigned i = 0, e = T->getNumArgs(); i != e; ++i) {
2871 1835: TemplateArgumentLoc Loc;
0: branch 4 not taken
1835: branch 5 taken
2872 1835: if (getDerived().TransformTemplateArgument(TL.getArgLoc(i), Loc))
2873 0: return QualType();
2874 1835: NewTemplateArgs.addArgument(Loc);
2875 : }
2876 :
2877 : // FIXME: maybe don't rebuild if all the template arguments are the same.
2878 :
2879 : QualType Result =
2880 : getDerived().RebuildTemplateSpecializationType(Template,
2881 : TL.getTemplateNameLoc(),
2882 1319: NewTemplateArgs);
2883 :
1318: branch 1 taken
1: branch 2 taken
2884 1319: if (!Result.isNull()) {
2885 : TemplateSpecializationTypeLoc NewTL
2886 1318: = TLB.push<TemplateSpecializationTypeLoc>(Result);
2887 1318: NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
2888 1318: NewTL.setLAngleLoc(TL.getLAngleLoc());
2889 1318: NewTL.setRAngleLoc(TL.getRAngleLoc());
1834: branch 1 taken
1318: branch 2 taken
2890 3152: for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
2891 1834: NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
2892 : }
2893 :
2894 1319: return Result;
2895 : }
2896 :
2897 : template<typename Derived>
2898 : QualType
2899 : TreeTransform<Derived>::TransformQualifiedNameType(TypeLocBuilder &TLB,
2900 0: QualifiedNameTypeLoc TL) {
2901 0: QualifiedNameType *T = TL.getTypePtr();
2902 : NestedNameSpecifier *NNS
2903 : = getDerived().TransformNestedNameSpecifier(T->getQualifier(),
2904 0: SourceRange());
0: branch 0 not taken
0: branch 1 not taken
2905 0: if (!NNS)
2906 0: return QualType();
2907 :
2908 0: QualType Named = getDerived().TransformType(T->getNamedType());
0: branch 1 not taken
0: branch 2 not taken
2909 0: if (Named.isNull())
2910 0: return QualType();
2911 :
2912 0: QualType Result = TL.getType();
0: branch 2 not taken
0: branch 3 not taken
0: branch 5 not taken
0: branch 6 not taken
0: branch 9 not taken
0: branch 10 not taken
0: branch 11 not taken
0: branch 12 not taken
2913 0: if (getDerived().AlwaysRebuild() ||
2914 : NNS != T->getQualifier() ||
2915 : Named != T->getNamedType()) {
2916 0: Result = getDerived().RebuildQualifiedNameType(NNS, Named);
0: branch 1 not taken
0: branch 2 not taken
2917 0: if (Result.isNull())
2918 0: return QualType();
2919 : }
2920 :
2921 0: QualifiedNameTypeLoc NewTL = TLB.push<QualifiedNameTypeLoc>(Result);
2922 0: NewTL.setNameLoc(TL.getNameLoc());
2923 :
2924 0: return Result;
2925 : }
2926 :
2927 : template<typename Derived>
2928 : QualType TreeTransform<Derived>::TransformTypenameType(TypeLocBuilder &TLB,
2929 137: TypenameTypeLoc TL) {
2930 137: TypenameType *T = TL.getTypePtr();
2931 :
2932 : /* FIXME: preserve source information better than this */
2933 137: SourceRange SR(TL.getNameLoc());
2934 :
2935 : NestedNameSpecifier *NNS
2936 137: = getDerived().TransformNestedNameSpecifier(T->getQualifier(), SR);
3: branch 0 taken
134: branch 1 taken
2937 137: if (!NNS)
2938 3: return QualType();
2939 :
2940 134: QualType Result;
2941 :
5: branch 1 taken
129: branch 2 taken
2942 134: if (const TemplateSpecializationType *TemplateId = T->getTemplateId()) {
2943 : QualType NewTemplateId
2944 5: = getDerived().TransformType(QualType(TemplateId, 0));
0: branch 1 not taken
5: branch 2 taken
2945 5: if (NewTemplateId.isNull())
2946 0: return QualType();
2947 :
5: branch 2 taken
0: branch 3 not taken
0: branch 5 not taken
5: branch 6 taken
0: branch 9 not taken
0: branch 10 not taken
0: branch 11 not taken
5: branch 12 taken
2948 5: if (!getDerived().AlwaysRebuild() &&
2949 : NNS == T->getQualifier() &&
2950 : NewTemplateId == QualType(TemplateId, 0))
2951 0: return QualType(T, 0);
2952 :
2953 5: Result = getDerived().RebuildTypenameType(NNS, NewTemplateId);
2954 : } else {
2955 129: Result = getDerived().RebuildTypenameType(NNS, T->getIdentifier(), SR);
2956 : }
11: branch 1 taken
123: branch 2 taken
2957 134: if (Result.isNull())
2958 11: return QualType();
2959 :
2960 123: TypenameTypeLoc NewTL = TLB.push<TypenameTypeLoc>(Result);
2961 123: NewTL.setNameLoc(TL.getNameLoc());
2962 :
2963 123: return Result;
2964 : }
2965 :
2966 : template<typename Derived>
2967 : QualType
2968 : TreeTransform<Derived>::TransformObjCInterfaceType(TypeLocBuilder &TLB,
2969 0: ObjCInterfaceTypeLoc TL) {
2970 0: assert(false && "TransformObjCInterfaceType unimplemented");
2971 : return QualType();
2972 : }
2973 :
2974 : template<typename Derived>
2975 : QualType
2976 : TreeTransform<Derived>::TransformObjCObjectPointerType(TypeLocBuilder &TLB,
2977 0: ObjCObjectPointerTypeLoc TL) {
2978 0: assert(false && "TransformObjCObjectPointerType unimplemented");
2979 : return QualType();
2980 : }
2981 :
2982 : //===----------------------------------------------------------------------===//
2983 : // Statement transformation
2984 : //===----------------------------------------------------------------------===//
2985 : template<typename Derived>
2986 : Sema::OwningStmtResult
2987 5: TreeTransform<Derived>::TransformNullStmt(NullStmt *S) {
2988 5: return SemaRef.Owned(S->Retain());
2989 : }
2990 :
2991 : template<typename Derived>
2992 : Sema::OwningStmtResult
2993 573: TreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S) {
2994 573: return getDerived().TransformCompoundStmt(S, false);
2995 : }
2996 :
2997 : template<typename Derived>
2998 : Sema::OwningStmtResult
2999 : TreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S,
3000 575: bool IsStmtExpr) {
3001 575: bool SubStmtChanged = false;
3002 575: ASTOwningVector<&ActionBase::DeleteStmt> Statements(getSema());
509: branch 3 taken
83: branch 4 taken
592: branch 5 taken
492: branch 6 taken
3003 1167: for (CompoundStmt::body_iterator B = S->body_begin(), BEnd = S->body_end();
3004 : B != BEnd; ++B) {
3005 592: OwningStmtResult Result = getDerived().TransformStmt(*B);
83: branch 1 taken
509: branch 2 taken
3006 592: if (Result.isInvalid())
3007 83: return getSema().StmtError();
3008 :
354: branch 0 taken
155: branch 1 taken
345: branch 3 taken
9: branch 4 taken
3009 509: SubStmtChanged = SubStmtChanged || Result.get() != *B;
3010 509: Statements.push_back(Result.takeAs<Stmt>());
3011 : }
3012 :
492: branch 2 taken
0: branch 3 not taken
163: branch 4 taken
329: branch 5 taken
163: branch 6 taken
329: branch 7 taken
3013 492: if (!getDerived().AlwaysRebuild() &&
3014 : !SubStmtChanged)
3015 163: return SemaRef.Owned(S->Retain());
3016 :
3017 : return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
3018 : move_arg(Statements),
3019 : S->getRBracLoc(),
3020 329: IsStmtExpr);
3021 : }
3022 :
3023 : template<typename Derived>
3024 : Sema::OwningStmtResult
3025 19: TreeTransform<Derived>::TransformCaseStmt(CaseStmt *S) {
3026 19: OwningExprResult LHS(SemaRef), RHS(SemaRef);
3027 : {
3028 : // The case value expressions are not potentially evaluated.
3029 19: EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
3030 :
3031 : // Transform the left-hand case value.
3032 19: LHS = getDerived().TransformExpr(S->getLHS());
0: branch 1 not taken
19: branch 2 taken
3033 19: if (LHS.isInvalid())
3034 0: return SemaRef.StmtError();
3035 :
3036 : // Transform the right-hand case value (for the GNU case-range extension).
3037 19: RHS = getDerived().TransformExpr(S->getRHS());
0: branch 1 not taken
19: branch 2 taken
3038 19: if (RHS.isInvalid())
19: branch 5 taken
0: branch 6 not taken
3039 0: return SemaRef.StmtError();
3040 : }
3041 :
3042 : // Build the case statement.
3043 : // Case statements are always rebuilt so that they will attached to their
3044 : // transformed switch statement.
3045 : OwningStmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
3046 : move(LHS),
3047 : S->getEllipsisLoc(),
3048 : move(RHS),
3049 19: S->getColonLoc());
0: branch 1 not taken
19: branch 2 taken
3050 19: if (Case.isInvalid())
3051 0: return SemaRef.StmtError();
3052 :
3053 : // Transform the statement following the case
3054 19: OwningStmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
0: branch 1 not taken
19: branch 2 taken
3055 19: if (SubStmt.isInvalid())
3056 0: return SemaRef.StmtError();
3057 :
3058 : // Attach the body to the case statement
3059 19: return getDerived().RebuildCaseStmtBody(move(Case), move(SubStmt));
3060 : }
3061 :
3062 : template<typename Derived>
3063 : Sema::OwningStmtResult
3064 3: TreeTransform<Derived>::TransformDefaultStmt(DefaultStmt *S) {
3065 : // Transform the statement following the default case
3066 3: OwningStmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
0: branch 1 not taken
3: branch 2 taken
3067 3: if (SubStmt.isInvalid())
3068 0: return SemaRef.StmtError();
3069 :
3070 : // Default statements are always rebuilt
3071 : return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
3072 3: move(SubStmt));
3073 : }
3074 :
3075 : template<typename Derived>
3076 : Sema::OwningStmtResult
3077 3: TreeTransform<Derived>::TransformLabelStmt(LabelStmt *S) {
3078 3: OwningStmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
0: branch 1 not taken
3: branch 2 taken
3079 3: if (SubStmt.isInvalid())
3080 0: return SemaRef.StmtError();
3081 :
3082 : // FIXME: Pass the real colon location in.
3083 3: SourceLocation ColonLoc = SemaRef.PP.getLocForEndOfToken(S->getIdentLoc());
3084 : return getDerived().RebuildLabelStmt(S->getIdentLoc(), S->getID(), ColonLoc,
3085 3: move(SubStmt));
3086 : }
3087 :
3088 : template<typename Derived>
3089 : Sema::OwningStmtResult
3090 23: TreeTransform<Derived>::TransformIfStmt(IfStmt *S) {
3091 : // Transform the condition
3092 23: OwningExprResult Cond(SemaRef);
3093 23: VarDecl *ConditionVar = 0;
2: branch 1 taken
21: branch 2 taken
3094 23: if (S->getConditionVariable()) {
3095 2: ConditionVar
3096 : = cast_or_null<VarDecl>(
3097 : getDerived().TransformDefinition(S->getConditionVariable()));
0: branch 0 not taken
2: branch 1 taken
3098 2: if (!ConditionVar)
3099 0: return SemaRef.StmtError();
3100 : } else {
3101 21: Cond = getDerived().TransformExpr(S->getCond());
3102 :
0: branch 1 not taken
21: branch 2 taken
3103 21: if (Cond.isInvalid())
3104 0: return SemaRef.StmtError();
3105 : }
3106 :
3107 23: Sema::FullExprArg FullCond(getSema().MakeFullExpr(Cond));
3108 :
3109 : // Transform the "then" branch.
3110 23: OwningStmtResult Then = getDerived().TransformStmt(S->getThen());
3: branch 1 taken
20: branch 2 taken
3111 23: if (Then.isInvalid())
3112 3: return SemaRef.StmtError();
3113 :
3114 : // Transform the "else" branch.
3115 20: OwningStmtResult Else = getDerived().TransformStmt(S->getElse());
2: branch 1 taken
18: branch 2 taken
3116 20: if (Else.isInvalid())
3117 2: return SemaRef.StmtError();
3118 :
18: branch 2 taken
0: branch 3 not taken
0: branch 7 not taken
18: branch 8 taken
0: branch 10 not taken
0: branch 11 not taken
0: branch 14 not taken
0: branch 15 not taken
0: branch 18 not taken
0: branch 19 not taken
0: branch 20 not taken
18: branch 21 taken
3119 18: if (!getDerived().AlwaysRebuild() &&
3120 : FullCond->get() == S->getCond() &&
3121 : ConditionVar == S->getConditionVariable() &&
3122 : Then.get() == S->getThen() &&
3123 : Else.get() == S->getElse())
3124 0: return SemaRef.Owned(S->Retain());
3125 :
3126 : return getDerived().RebuildIfStmt(S->getIfLoc(), FullCond, ConditionVar,
3127 : move(Then),
3128 18: S->getElseLoc(), move(Else));
3129 : }
3130 :
3131 : template<typename Derived>
3132 : Sema::OwningStmtResult
3133 5: TreeTransform<Derived>::TransformSwitchStmt(SwitchStmt *S) {
3134 : // Transform the condition.
3135 5: OwningExprResult Cond(SemaRef);
3136 5: VarDecl *ConditionVar = 0;
0: branch 1 not taken
5: branch 2 taken
3137 5: if (S->getConditionVariable()) {
3138 0: ConditionVar
3139 : = cast_or_null<VarDecl>(
3140 : getDerived().TransformDefinition(S->getConditionVariable()));
0: branch 0 not taken
0: branch 1 not taken
3141 0: if (!ConditionVar)
3142 0: return SemaRef.StmtError();
3143 : } else {
3144 5: Cond = getDerived().TransformExpr(S->getCond());
3145 :
0: branch 1 not taken
5: branch 2 taken
3146 5: if (Cond.isInvalid())
3147 0: return SemaRef.StmtError();
3148 : }
3149 :
3150 5: Sema::FullExprArg FullCond(getSema().MakeFullExpr(Cond));
3151 :
3152 : // Rebuild the switch statement.
3153 : OwningStmtResult Switch = getDerived().RebuildSwitchStmtStart(FullCond,
3154 5: ConditionVar);
0: branch 1 not taken
5: branch 2 taken
3155 5: if (Switch.isInvalid())
3156 0: return SemaRef.StmtError();
3157 :
3158 : // Transform the body of the switch statement.
3159 5: OwningStmtResult Body = getDerived().TransformStmt(S->getBody());
0: branch 1 not taken
5: branch 2 taken
3160 5: if (Body.isInvalid())
3161 0: return SemaRef.StmtError();
3162 :
3163 : // Complete the switch statement.
3164 : return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), move(Switch),
3165 5: move(Body));
3166 : }
3167 :
3168 : template<typename Derived>
3169 : Sema::OwningStmtResult
3170 2: TreeTransform<Derived>::TransformWhileStmt(WhileStmt *S) {
3171 : // Transform the condition
3172 2: OwningExprResult Cond(SemaRef);
3173 2: VarDecl *ConditionVar = 0;
1: branch 1 taken
1: branch 2 taken
3174 2: if (S->getConditionVariable()) {
3175 1: ConditionVar
3176 : = cast_or_null<VarDecl>(
3177 : getDerived().TransformDefinition(S->getConditionVariable()));
0: branch 0 not taken
1: branch 1 taken
3178 1: if (!ConditionVar)
3179 0: return SemaRef.StmtError();
3180 : } else {
3181 1: Cond = getDerived().TransformExpr(S->getCond());
3182 :
0: branch 1 not taken
1: branch 2 taken
3183 1: if (Cond.isInvalid())
3184 0: return SemaRef.StmtError();
3185 : }
3186 :
3187 2: Sema::FullExprArg FullCond(getSema().MakeFullExpr(Cond));
3188 :
3189 : // Transform the body
3190 2: OwningStmtResult Body = getDerived().TransformStmt(S->getBody());
0: branch 1 not taken
2: branch 2 taken
3191 2: if (Body.isInvalid())
3192 0: return SemaRef.StmtError();
3193 :
2: branch 2 taken
0: branch 3 not taken
0: branch 7 not taken
2: branch 8 taken
0: branch 10 not taken
0: branch 11 not taken
0: branch 14 not taken
0: branch 15 not taken
0: branch 16 not taken
2: branch 17 taken
3194 2: if (!getDerived().AlwaysRebuild() &&
3195 : FullCond->get() == S->getCond() &&
3196 : ConditionVar == S->getConditionVariable() &&
3197 : Body.get() == S->getBody())
3198 0: return SemaRef.Owned(S->Retain());
3199 :
3200 : return getDerived().RebuildWhileStmt(S->getWhileLoc(), FullCond, ConditionVar,
3201 2: move(Body));
3202 : }
3203 :
3204 : template<typename Derived>
3205 : Sema::OwningStmtResult
3206 2: TreeTransform<Derived>::TransformDoStmt(DoStmt *S) {
3207 : // Transform the condition
3208 2: OwningExprResult Cond = getDerived().TransformExpr(S->getCond());
0: branch 1 not taken
2: branch 2 taken
3209 2: if (Cond.isInvalid())
3210 0: return SemaRef.StmtError();
3211 :
3212 : // Transform the body
3213 2: OwningStmtResult Body = getDerived().TransformStmt(S->getBody());
0: branch 1 not taken
2: branch 2 taken
3214 2: if (Body.isInvalid())
3215 0: return SemaRef.StmtError();
3216 :
2: branch 2 taken
0: branch 3 not taken
0: branch 6 not taken
2: branch 7 taken
0: branch 10 not taken
0: branch 11 not taken
0: branch 12 not taken
2: branch 13 taken
3217 2: if (!getDerived().AlwaysRebuild() &&
3218 : Cond.get() == S->getCond() &&
3219 : Body.get() == S->getBody())
3220 0: return SemaRef.Owned(S->Retain());
3221 :
3222 : return getDerived().RebuildDoStmt(S->getDoLoc(), move(Body), S->getWhileLoc(),
3223 : /*FIXME:*/S->getWhileLoc(), move(Cond),
3224 2: S->getRParenLoc());
3225 : }
3226 :
3227 : template<typename Derived>
3228 : Sema::OwningStmtResult
3229 14: TreeTransform<Derived>::TransformForStmt(ForStmt *S) {
3230 : // Transform the initialization statement
3231 14: OwningStmtResult Init = getDerived().TransformStmt(S->getInit());
0: branch 1 not taken
14: branch 2 taken
3232 14: if (Init.isInvalid())
3233 0: return SemaRef.StmtError();
3234 :
3235 : // Transform the condition
3236 14: OwningExprResult Cond(SemaRef);
3237 14: VarDecl *ConditionVar = 0;
0: branch 1 not taken
14: branch 2 taken
3238 14: if (S->getConditionVariable()) {
3239 0: ConditionVar
3240 : = cast_or_null<VarDecl>(
3241 : getDerived().TransformDefinition(S->getConditionVariable()));
0: branch 0 not taken
0: branch 1 not taken
3242 0: if (!ConditionVar)
3243 0: return SemaRef.StmtError();
3244 : } else {
3245 14: Cond = getDerived().TransformExpr(S->getCond());
3246 :
0: branch 1 not taken
14: branch 2 taken
3247 14: if (Cond.isInvalid())
3248 0: return SemaRef.StmtError();
3249 : }
3250 :
3251 : // Transform the increment
3252 14: OwningExprResult Inc = getDerived().TransformExpr(S->getInc());
0: branch 1 not taken
14: branch 2 taken
3253 14: if (Inc.isInvalid())
3254 0: return SemaRef.StmtError();
3255 :
3256 : // Transform the body
3257 14: OwningStmtResult Body = getDerived().TransformStmt(S->getBody());
0: branch 1 not taken
14: branch 2 taken
3258 14: if (Body.isInvalid())
3259 0: return SemaRef.StmtError();
3260 :
14: branch 2 taken
0: branch 3 not taken
1: branch 6 taken
13: branch 7 taken
0: branch 10 not taken
1: branch 11 taken
0: branch 14 not taken
0: branch 15 not taken
0: branch 18 not taken
0: branch 19 not taken
0: branch 20 not taken
14: branch 21 taken
3261 14: if (!getDerived().AlwaysRebuild() &&
3262 : Init.get() == S->getInit() &&
3263 : Cond.get() == S->getCond() &&
3264 : Inc.get() == S->getInc() &&
3265 : Body.get() == S->getBody())
3266 0: return SemaRef.Owned(S->Retain());
3267 :
3268 : return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
3269 : move(Init), getSema().MakeFullExpr(Cond),
3270 : ConditionVar,
3271 : getSema().MakeFullExpr(Inc),
3272 14: S->getRParenLoc(), move(Body));
3273 : }
3274 :
3275 : template<typename Derived>
3276 : Sema::OwningStmtResult
3277 1: TreeTransform<Derived>::TransformGotoStmt(GotoStmt *S) {
3278 : // Goto statements must always be rebuilt, to resolve the label.
3279 : return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
3280 1: S->getLabel());
3281 : }
3282 :
3283 : template<typename Derived>
3284 : Sema::OwningStmtResult
3285 2: TreeTransform<Derived>::TransformIndirectGotoStmt(IndirectGotoStmt *S) {
3286 2: OwningExprResult Target = getDerived().TransformExpr(S->getTarget());
0: branch 1 not taken
2: branch 2 taken
3287 2: if (Target.isInvalid())
3288 0: return SemaRef.StmtError();
3289 :
2: branch 2 taken
0: branch 3 not taken
0: branch 6 not taken
2: branch 7 taken
0: branch 8 not taken
2: branch 9 taken
3290 2: if (!getDerived().AlwaysRebuild() &&
3291 : Target.get() == S->getTarget())
3292 0: return SemaRef.Owned(S->Retain());
3293 :
3294 : return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
3295 2: move(Target));
3296 : }
3297 :
3298 : template<typename Derived>
3299 : Sema::OwningStmtResult
3300 1: TreeTransform<Derived>::TransformContinueStmt(ContinueStmt *S) {
3301 1: return SemaRef.Owned(S->Retain());
3302 : }
3303 :
3304 : template<typename Derived>
3305 : Sema::OwningStmtResult
3306 1: TreeTransform<Derived>::TransformBreakStmt(BreakStmt *S) {
3307 1: return SemaRef.Owned(S->Retain());
3308 : }
3309 :
3310 : template<typename Derived>
3311 : Sema::OwningStmtResult
3312 147: TreeTransform<Derived>::TransformReturnStmt(ReturnStmt *S) {
3313 147: Sema::OwningExprResult Result = getDerived().TransformExpr(S->getRetValue());
14: branch 1 taken
133: branch 2 taken
3314 147: if (Result.isInvalid())
3315 14: return SemaRef.StmtError();
3316 :
3317 : // FIXME: We always rebuild the return statement because there is no way
3318 : // to tell whether the return type of the function has changed.
3319 133: return getDerived().RebuildReturnStmt(S->getReturnLoc(), move(Result));
3320 : }
3321 :
3322 : template<typename Derived>
3323 : Sema::OwningStmtResult
3324 181: TreeTransform<Derived>::TransformDeclStmt(DeclStmt *S) {
3325 181: bool DeclChanged = false;
3326 181: llvm::SmallVector<Decl *, 4> Decls;
200: branch 2 taken
174: branch 3 taken
3327 374: for (DeclStmt::decl_iterator D = S->decl_begin(), DEnd = S->decl_end();
3328 : D != DEnd; ++D) {
3329 200: Decl *Transformed = getDerived().TransformDefinition(*D);
7: branch 0 taken
193: branch 1 taken
3330 200: if (!Transformed)
3331 7: return SemaRef.StmtError();
3332 :
193: branch 0 taken
0: branch 1 not taken
3333 193: if (Transformed != *D)
3334 193: DeclChanged = true;
3335 :
3336 193: Decls.push_back(Transformed);
3337 : }
3338 :
174: branch 2 taken
0: branch 3 not taken
0: branch 4 not taken
174: branch 5 taken
0: branch 6 not taken
174: branch 7 taken
3339 174: if (!getDerived().AlwaysRebuild() && !DeclChanged)
3340 0: return SemaRef.Owned(S->Retain());
3341 :
3342 : return getDerived().RebuildDeclStmt(Decls.data(), Decls.size(),
3343 174: S->getStartLoc(), S->getEndLoc());
3344 : }
3345 :
3346 : template<typename Derived>
3347 : Sema::OwningStmtResult
3348 0: TreeTransform<Derived>::TransformSwitchCase(SwitchCase *S) {
3349 0: assert(false && "SwitchCase is abstract and cannot be transformed");
3350 : return SemaRef.Owned(S->Retain());
3351 : }
3352 :
3353 : template<typename Derived>
3354 : Sema::OwningStmtResult
3355 2: TreeTransform<Derived>::TransformAsmStmt(AsmStmt *S) {
3356 :
3357 2: ASTOwningVector<&ActionBase::DeleteExpr> Constraints(getSema());
3358 2: ASTOwningVector<&ActionBase::DeleteExpr> Exprs(getSema());
3359 2: llvm::SmallVector<IdentifierInfo *, 4> Names;
3360 :
3361 2: OwningExprResult AsmString(SemaRef);
3362 2: ASTOwningVector<&ActionBase::DeleteExpr> Clobbers(getSema());
3363 :
3364 2: bool ExprsChanged = false;
3365 :
3366 : // Go through the outputs.
1: branch 2 taken
1: branch 3 taken
2: branch 4 taken
1: branch 5 taken
3367 4: for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
3368 2: Names.push_back(S->getOutputIdentifier(I));
3369 :
3370 : // No need to transform the constraint literal.
3371 2: Constraints.push_back(S->getOutputConstraintLiteral(I)->Retain());
3372 :
3373 : // Transform the output expr.
3374 2: Expr *OutputExpr = S->getOutputExpr(I);
3375 2: OwningExprResult Result = getDerived().TransformExpr(OutputExpr);
1: branch 1 taken
1: branch 2 taken
3376 2: if (Result.isInvalid())
3377 1: return SemaRef.StmtError();
3378 :
3379 1: ExprsChanged |= Result.get() != OutputExpr;
3380 :
3381 1: Exprs.push_back(Result.takeAs<Expr>());
3382 : }
3383 :
3384 : // Go through the inputs.
1: branch 2 taken
0: branch 3 not taken
1: branch 4 taken
1: branch 5 taken
3385 2: for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
3386 1: Names.push_back(S->getInputIdentifier(I));
3387 :
3388 : // No need to transform the constraint literal.
3389 1: Constraints.push_back(S->getInputConstraintLiteral(I)->Retain());
3390 :
3391 : // Transform the input expr.
3392 1: Expr *InputExpr = S->getInputExpr(I);
3393 1: OwningExprResult Result = getDerived().TransformExpr(InputExpr);
0: branch 1 not taken
1: branch 2 taken
3394 1: if (Result.isInvalid())
3395 0: return SemaRef.StmtError();
3396 :
3397 1: ExprsChanged |= Result.get() != InputExpr;
3398 :
3399 1: Exprs.push_back(Result.takeAs<Expr>());
3400 : }
3401 :
1: branch 2 taken
0: branch 3 not taken
0: branch 4 not taken
1: branch 5 taken
0: branch 6 not taken
1: branch 7 taken
3402 1: if (!getDerived().AlwaysRebuild() && !ExprsChanged)
3403 0: return SemaRef.Owned(S->Retain());
3404 :
3405 : // Go through the clobbers.
0: branch 1 not taken
1: branch 2 taken
3406 1: for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I)
3407 0: Clobbers.push_back(S->getClobber(I)->Retain());
3408 :
3409 : // No need to transform the asm string literal.
3410 1: AsmString = SemaRef.Owned(S->getAsmString());
3411 :
3412 : return getDerived().RebuildAsmStmt(S->getAsmLoc(),
3413 : S->isSimple(),
3414 : S->isVolatile(),
3415 : S->getNumOutputs(),
3416 : S->getNumInputs(),
3417 : Names.data(),
3418 : move_arg(Constraints),
3419 : move_arg(Exprs),
3420 : move(AsmString),
3421 : move_arg(Clobbers),
3422 : S->getRParenLoc(),
3423 1: S->isMSAsm());
3424 : }
3425 :
3426 :
3427 : template<typename Derived>
3428 : Sema::OwningStmtResult
3429 0: TreeTransform<Derived>::TransformObjCAtTryStmt(ObjCAtTryStmt *S) {
3430 : // FIXME: Implement this
3431 0: assert(false && "Cannot transform an Objective-C @try statement");
3432 : return SemaRef.Owned(S->Retain());
3433 : }
3434 :
3435 : template<typename Derived>
3436 : Sema::OwningStmtResult
3437 0: TreeTransform<Derived>::TransformObjCAtCatchStmt(ObjCAtCatchStmt *S) {
3438 : // FIXME: Implement this
3439 0: assert(false && "Cannot transform an Objective-C @catch statement");
3440 : return SemaRef.Owned(S->Retain());
3441 : }
3442 :
3443 : template<typename Derived>
3444 : Sema::OwningStmtResult
3445 0: TreeTransform<Derived>::TransformObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
3446 : // FIXME: Implement this
3447 0: assert(false && "Cannot transform an Objective-C @finally statement");
3448 : return SemaRef.Owned(S->Retain());
3449 : }
3450 :
3451 : template<typename Derived>
3452 : Sema::OwningStmtResult
3453 0: TreeTransform<Derived>::TransformObjCAtThrowStmt(ObjCAtThrowStmt *S) {
3454 : // FIXME: Implement this
3455 0: assert(false && "Cannot transform an Objective-C @throw statement");
3456 : return SemaRef.Owned(S->Retain());
3457 : }
3458 :
3459 : template<typename Derived>
3460 : Sema::OwningStmtResult
3461 : TreeTransform<Derived>::TransformObjCAtSynchronizedStmt(
3462 0: ObjCAtSynchronizedStmt *S) {
3463