Coverage Report

Created: 2020-02-25 14:32

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/AST/Expr.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- Expr.cpp - Expression AST Node Implementation --------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file implements the Expr class and subclasses.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "clang/AST/Expr.h"
14
#include "clang/AST/APValue.h"
15
#include "clang/AST/ASTContext.h"
16
#include "clang/AST/Attr.h"
17
#include "clang/AST/DeclCXX.h"
18
#include "clang/AST/DeclObjC.h"
19
#include "clang/AST/DeclTemplate.h"
20
#include "clang/AST/EvaluatedExprVisitor.h"
21
#include "clang/AST/ExprCXX.h"
22
#include "clang/AST/Mangle.h"
23
#include "clang/AST/RecordLayout.h"
24
#include "clang/AST/StmtVisitor.h"
25
#include "clang/Basic/Builtins.h"
26
#include "clang/Basic/CharInfo.h"
27
#include "clang/Basic/SourceManager.h"
28
#include "clang/Basic/TargetInfo.h"
29
#include "clang/Lex/Lexer.h"
30
#include "clang/Lex/LiteralSupport.h"
31
#include "llvm/Support/ErrorHandling.h"
32
#include "llvm/Support/raw_ostream.h"
33
#include <algorithm>
34
#include <cstring>
35
using namespace clang;
36
37
30.9k
const Expr *Expr::getBestDynamicClassTypeExpr() const {
38
30.9k
  const Expr *E = this;
39
31.2k
  while (true) {
40
31.2k
    E = E->ignoreParenBaseCasts();
41
31.2k
42
31.2k
    // Follow the RHS of a comma operator.
43
31.2k
    if (auto *BO = dyn_cast<BinaryOperator>(E)) {
44
60
      if (BO->getOpcode() == BO_Comma) {
45
18
        E = BO->getRHS();
46
18
        continue;
47
18
      }
48
31.1k
    }
49
31.1k
50
31.1k
    // Step into initializer for materialized temporaries.
51
31.1k
    if (auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
52
289
      E = MTE->getSubExpr();
53
289
      continue;
54
289
    }
55
30.9k
56
30.9k
    break;
57
30.9k
  }
58
30.9k
59
30.9k
  return E;
60
30.9k
}
61
62
16.6k
const CXXRecordDecl *Expr::getBestDynamicClassType() const {
63
16.6k
  const Expr *E = getBestDynamicClassTypeExpr();
64
16.6k
  QualType DerivedType = E->getType();
65
16.6k
  if (const PointerType *PTy = DerivedType->getAs<PointerType>())
66
12.6k
    DerivedType = PTy->getPointeeType();
67
16.6k
68
16.6k
  if (DerivedType->isDependentType())
69
4.20k
    return nullptr;
70
12.4k
71
12.4k
  const RecordType *Ty = DerivedType->castAs<RecordType>();
72
12.4k
  Decl *D = Ty->getDecl();
73
12.4k
  return cast<CXXRecordDecl>(D);
74
12.4k
}
75
76
const Expr *Expr::skipRValueSubobjectAdjustments(
77
    SmallVectorImpl<const Expr *> &CommaLHSs,
78
6.38M
    SmallVectorImpl<SubobjectAdjustment> &Adjustments) const {
79
6.38M
  const Expr *E = this;
80
6.64M
  while (true) {
81
6.64M
    E = E->IgnoreParens();
82
6.64M
83
6.64M
    if (const CastExpr *CE = dyn_cast<CastExpr>(E)) {
84
2.77M
      if ((CE->getCastKind() == CK_DerivedToBase ||
85
2.77M
           
CE->getCastKind() == CK_UncheckedDerivedToBase2.77M
) &&
86
2.77M
          
E->getType()->isRecordType()3.36k
) {
87
2.91k
        E = CE->getSubExpr();
88
2.91k
        auto *Derived =
89
2.91k
            cast<CXXRecordDecl>(E->getType()->castAs<RecordType>()->getDecl());
90
2.91k
        Adjustments.push_back(SubobjectAdjustment(CE, Derived));
91
2.91k
        continue;
92
2.91k
      }
93
2.77M
94
2.77M
      if (CE->getCastKind() == CK_NoOp) {
95
215k
        E = CE->getSubExpr();
96
215k
        continue;
97
215k
      }
98
3.87M
    } else if (const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
99
91.4k
      if (!ME->isArrow()) {
100
46.9k
        assert(ME->getBase()->getType()->isRecordType());
101
46.9k
        if (FieldDecl *Field = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
102
46.8k
          if (!Field->isBitField() && 
!Field->getType()->isReferenceType()46.5k
) {
103
45.2k
            E = ME->getBase();
104
45.2k
            Adjustments.push_back(SubobjectAdjustment(Field));
105
45.2k
            continue;
106
45.2k
          }
107
3.78M
        }
108
46.9k
      }
109
3.78M
    } else if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
110
423k
      if (BO->getOpcode() == BO_PtrMemD) {
111
104
        assert(BO->getRHS()->isRValue());
112
104
        E = BO->getLHS();
113
104
        const MemberPointerType *MPT =
114
104
          BO->getRHS()->getType()->getAs<MemberPointerType>();
115
104
        Adjustments.push_back(SubobjectAdjustment(MPT, BO->getRHS()));
116
104
        continue;
117
423k
      } else if (BO->getOpcode() == BO_Comma) {
118
526
        CommaLHSs.push_back(BO->getLHS());
119
526
        E = BO->getRHS();
120
526
        continue;
121
526
      }
122
6.38M
    }
123
6.38M
124
6.38M
    // Nothing changed.
125
6.38M
    break;
126
6.38M
  }
127
6.38M
  return E;
128
6.38M
}
129
130
305k
bool Expr::isKnownToHaveBooleanValue(bool Semantic) const {
131
305k
  const Expr *E = IgnoreParens();
132
305k
133
305k
  // If this value has _Bool type, it is obvious 0/1.
134
305k
  if (E->getType()->isBooleanType()) 
return true452
;
135
305k
  // If this is a non-scalar-integer type, we don't care enough to try.
136
305k
  if (!E->getType()->isIntegralOrEnumerationType()) 
return false20.5k
;
137
284k
138
284k
  if (const UnaryOperator *UO = dyn_cast<UnaryOperator>(E)) {
139
4.44k
    switch (UO->getOpcode()) {
140
2
    case UO_Plus:
141
2
      return UO->getSubExpr()->isKnownToHaveBooleanValue(Semantic);
142
118
    case UO_LNot:
143
118
      return true;
144
4.32k
    default:
145
4.32k
      return false;
146
280k
    }
147
280k
  }
148
280k
149
280k
  // Only look through implicit casts.  If the user writes
150
280k
  // '(int) (a && b)' treat it as an arbitrary int.
151
280k
  // FIXME: Should we look through any cast expression in !Semantic mode?
152
280k
  if (const ImplicitCastExpr *CE = dyn_cast<ImplicitCastExpr>(E))
153
51.8k
    return CE->getSubExpr()->isKnownToHaveBooleanValue(Semantic);
154
228k
155
228k
  if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
156
7.86k
    switch (BO->getOpcode()) {
157
2.34k
    default: return false;
158
655
    case BO_LT:   // Relational operators.
159
655
    case BO_GT:
160
655
    case BO_LE:
161
655
    case BO_GE:
162
655
    case BO_EQ:   // Equality operators.
163
655
    case BO_NE:
164
655
    case BO_LAnd: // AND operator.
165
655
    case BO_LOr:  // Logical OR operator.
166
655
      return true;
167
655
168
4.51k
    case BO_And:  // Bitwise AND operator.
169
4.51k
    case BO_Xor:  // Bitwise XOR operator.
170
4.51k
    case BO_Or:   // Bitwise OR operator.
171
4.51k
      // Handle things like (x==2)|(y==12).
172
4.51k
      return BO->getLHS()->isKnownToHaveBooleanValue(Semantic) &&
173
4.51k
             
BO->getRHS()->isKnownToHaveBooleanValue(Semantic)0
;
174
4.51k
175
4.51k
    case BO_Comma:
176
356
    case BO_Assign:
177
356
      return BO->getRHS()->isKnownToHaveBooleanValue(Semantic);
178
220k
    }
179
220k
  }
180
220k
181
220k
  if (const ConditionalOperator *CO = dyn_cast<ConditionalOperator>(E))
182
0
    return CO->getTrueExpr()->isKnownToHaveBooleanValue(Semantic) &&
183
0
           CO->getFalseExpr()->isKnownToHaveBooleanValue(Semantic);
184
220k
185
220k
  if (isa<ObjCBoolLiteralExpr>(E))
186
1
    return true;
187
220k
188
220k
  if (const auto *OVE = dyn_cast<OpaqueValueExpr>(E))
189
5
    return OVE->getSourceExpr()->isKnownToHaveBooleanValue(Semantic);
190
220k
191
220k
  if (const FieldDecl *FD = E->getSourceBitField())
192
712
    if (!Semantic && 
FD->getType()->isUnsignedIntegerType()26
&&
193
712
        
!FD->getBitWidth()->isValueDependent()22
&&
194
712
        
FD->getBitWidthValue(FD->getASTContext()) == 122
)
195
11
      return true;
196
220k
197
220k
  return false;
198
220k
}
199
200
// Amusing macro metaprogramming hack: check whether a class provides
201
// a more specific implementation of getExprLoc().
202
//
203
// See also Stmt.cpp:{getBeginLoc(),getEndLoc()}.
204
namespace {
205
  /// This implementation is used when a class provides a custom
206
  /// implementation of getExprLoc.
207
  template <class E, class T>
208
  SourceLocation getExprLocImpl(const Expr *expr,
209
15.9M
                                SourceLocation (T::*v)() const) {
210
15.9M
    return static_cast<const E*>(expr)->getExprLoc();
211
15.9M
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ArraySubscriptExpr, clang::ArraySubscriptExpr>(clang::Expr const*, clang::SourceLocation (clang::ArraySubscriptExpr::*)() const)
Line
Count
Source
209
499k
                                SourceLocation (T::*v)() const) {
210
499k
    return static_cast<const E*>(expr)->getExprLoc();
211
499k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::BinaryOperator, clang::BinaryOperator>(clang::Expr const*, clang::SourceLocation (clang::BinaryOperator::*)() const)
Line
Count
Source
209
8.35M
                                SourceLocation (T::*v)() const) {
210
8.35M
    return static_cast<const E*>(expr)->getExprLoc();
211
8.35M
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CompoundAssignOperator, clang::BinaryOperator>(clang::Expr const*, clang::SourceLocation (clang::BinaryOperator::*)() const)
Line
Count
Source
209
257k
                                SourceLocation (T::*v)() const) {
210
257k
    return static_cast<const E*>(expr)->getExprLoc();
211
257k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXDefaultArgExpr, clang::CXXDefaultArgExpr>(clang::Expr const*, clang::SourceLocation (clang::CXXDefaultArgExpr::*)() const)
Line
Count
Source
209
34.3k
                                SourceLocation (T::*v)() const) {
210
34.3k
    return static_cast<const E*>(expr)->getExprLoc();
211
34.3k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXRewrittenBinaryOperator, clang::CXXRewrittenBinaryOperator>(clang::Expr const*, clang::SourceLocation (clang::CXXRewrittenBinaryOperator::*)() const)
Line
Count
Source
209
213
                                SourceLocation (T::*v)() const) {
210
213
    return static_cast<const E*>(expr)->getExprLoc();
211
213
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXMemberCallExpr, clang::CXXMemberCallExpr>(clang::Expr const*, clang::SourceLocation (clang::CXXMemberCallExpr::*)() const)
Line
Count
Source
209
908k
                                SourceLocation (T::*v)() const) {
210
908k
    return static_cast<const E*>(expr)->getExprLoc();
211
908k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXOperatorCallExpr, clang::CXXOperatorCallExpr>(clang::Expr const*, clang::SourceLocation (clang::CXXOperatorCallExpr::*)() const)
Line
Count
Source
209
607k
                                SourceLocation (T::*v)() const) {
210
607k
    return static_cast<const E*>(expr)->getExprLoc();
211
607k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::MSPropertySubscriptExpr, clang::MSPropertySubscriptExpr>(clang::Expr const*, clang::SourceLocation (clang::MSPropertySubscriptExpr::*)() const)
Line
Count
Source
209
396
                                SourceLocation (T::*v)() const) {
210
396
    return static_cast<const E*>(expr)->getExprLoc();
211
396
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::MemberExpr, clang::MemberExpr>(clang::Expr const*, clang::SourceLocation (clang::MemberExpr::*)() const)
Line
Count
Source
209
2.07M
                                SourceLocation (T::*v)() const) {
210
2.07M
    return static_cast<const E*>(expr)->getExprLoc();
211
2.07M
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::OMPArraySectionExpr, clang::OMPArraySectionExpr>(clang::Expr const*, clang::SourceLocation (clang::OMPArraySectionExpr::*)() const)
Line
Count
Source
209
16.0k
                                SourceLocation (T::*v)() const) {
210
16.0k
    return static_cast<const E*>(expr)->getExprLoc();
211
16.0k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ObjCIndirectCopyRestoreExpr, clang::ObjCIndirectCopyRestoreExpr>(clang::Expr const*, clang::SourceLocation (clang::ObjCIndirectCopyRestoreExpr::*)() const)
Line
Count
Source
209
95
                                SourceLocation (T::*v)() const) {
210
95
    return static_cast<const E*>(expr)->getExprLoc();
211
95
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ObjCIsaExpr, clang::ObjCIsaExpr>(clang::Expr const*, clang::SourceLocation (clang::ObjCIsaExpr::*)() const)
Line
Count
Source
209
185
                                SourceLocation (T::*v)() const) {
210
185
    return static_cast<const E*>(expr)->getExprLoc();
211
185
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::OpaqueValueExpr, clang::OpaqueValueExpr>(clang::Expr const*, clang::SourceLocation (clang::OpaqueValueExpr::*)() const)
Line
Count
Source
209
40.7k
                                SourceLocation (T::*v)() const) {
210
40.7k
    return static_cast<const E*>(expr)->getExprLoc();
211
40.7k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::UnresolvedMemberExpr, clang::UnresolvedMemberExpr>(clang::Expr const*, clang::SourceLocation (clang::UnresolvedMemberExpr::*)() const)
Line
Count
Source
209
270
                                SourceLocation (T::*v)() const) {
210
270
    return static_cast<const E*>(expr)->getExprLoc();
211
270
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::PseudoObjectExpr, clang::PseudoObjectExpr>(clang::Expr const*, clang::SourceLocation (clang::PseudoObjectExpr::*)() const)
Line
Count
Source
209
8.22k
                                SourceLocation (T::*v)() const) {
210
8.22k
    return static_cast<const E*>(expr)->getExprLoc();
211
8.22k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::UnaryOperator, clang::UnaryOperator>(clang::Expr const*, clang::SourceLocation (clang::UnaryOperator::*)() const)
Line
Count
Source
209
3.14M
                                SourceLocation (T::*v)() const) {
210
3.14M
    return static_cast<const E*>(expr)->getExprLoc();
211
3.14M
  }
212
213
  /// This implementation is used when a class doesn't provide
214
  /// a custom implementation of getExprLoc.  Overload resolution
215
  /// should pick it over the implementation above because it's
216
  /// more specialized according to function template partial ordering.
217
  template <class E>
218
  SourceLocation getExprLocImpl(const Expr *expr,
219
62.2M
                                SourceLocation (Expr::*v)() const) {
220
62.2M
    return static_cast<const E *>(expr)->getBeginLoc();
221
62.2M
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::BinaryConditionalOperator>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
406
                                SourceLocation (Expr::*v)() const) {
220
406
    return static_cast<const E *>(expr)->getBeginLoc();
221
406
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ConditionalOperator>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
223k
                                SourceLocation (Expr::*v)() const) {
220
223k
    return static_cast<const E *>(expr)->getBeginLoc();
221
223k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::AddrLabelExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
447
                                SourceLocation (Expr::*v)() const) {
220
447
    return static_cast<const E *>(expr)->getBeginLoc();
221
447
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ArrayInitIndexExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
63
                                SourceLocation (Expr::*v)() const) {
220
63
    return static_cast<const E *>(expr)->getBeginLoc();
221
63
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ArrayInitLoopExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
76
                                SourceLocation (Expr::*v)() const) {
220
76
    return static_cast<const E *>(expr)->getBeginLoc();
221
76
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ArrayTypeTraitExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
6
                                SourceLocation (Expr::*v)() const) {
220
6
    return static_cast<const E *>(expr)->getBeginLoc();
221
6
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::AsTypeExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
81
                                SourceLocation (Expr::*v)() const) {
220
81
    return static_cast<const E *>(expr)->getBeginLoc();
221
81
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::AtomicExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
12.4k
                                SourceLocation (Expr::*v)() const) {
220
12.4k
    return static_cast<const E *>(expr)->getBeginLoc();
221
12.4k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::BlockExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
5.92k
                                SourceLocation (Expr::*v)() const) {
220
5.92k
    return static_cast<const E *>(expr)->getBeginLoc();
221
5.92k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXBindTemporaryExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
60.6k
                                SourceLocation (Expr::*v)() const) {
220
60.6k
    return static_cast<const E *>(expr)->getBeginLoc();
221
60.6k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXBoolLiteralExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
1.54M
                                SourceLocation (Expr::*v)() const) {
220
1.54M
    return static_cast<const E *>(expr)->getBeginLoc();
221
1.54M
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXConstructExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
540k
                                SourceLocation (Expr::*v)() const) {
220
540k
    return static_cast<const E *>(expr)->getBeginLoc();
221
540k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXTemporaryObjectExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
246k
                                SourceLocation (Expr::*v)() const) {
220
246k
    return static_cast<const E *>(expr)->getBeginLoc();
221
246k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXDefaultInitExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
994
                                SourceLocation (Expr::*v)() const) {
220
994
    return static_cast<const E *>(expr)->getBeginLoc();
221
994
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXDeleteExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
12.0k
                                SourceLocation (Expr::*v)() const) {
220
12.0k
    return static_cast<const E *>(expr)->getBeginLoc();
221
12.0k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXDependentScopeMemberExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
66.1k
                                SourceLocation (Expr::*v)() const) {
220
66.1k
    return static_cast<const E *>(expr)->getBeginLoc();
221
66.1k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXFoldExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
86
                                SourceLocation (Expr::*v)() const) {
220
86
    return static_cast<const E *>(expr)->getBeginLoc();
221
86
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXInheritedCtorInitExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
240
                                SourceLocation (Expr::*v)() const) {
220
240
    return static_cast<const E *>(expr)->getBeginLoc();
221
240
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXNewExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
49.6k
                                SourceLocation (Expr::*v)() const) {
220
49.6k
    return static_cast<const E *>(expr)->getBeginLoc();
221
49.6k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXNoexceptExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
1.95k
                                SourceLocation (Expr::*v)() const) {
220
1.95k
    return static_cast<const E *>(expr)->getBeginLoc();
221
1.95k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXNullPtrLiteralExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
36.7k
                                SourceLocation (Expr::*v)() const) {
220
36.7k
    return static_cast<const E *>(expr)->getBeginLoc();
221
36.7k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXPseudoDestructorExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
508
                                SourceLocation (Expr::*v)() const) {
220
508
    return static_cast<const E *>(expr)->getBeginLoc();
221
508
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXScalarValueInitExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
14.5k
                                SourceLocation (Expr::*v)() const) {
220
14.5k
    return static_cast<const E *>(expr)->getBeginLoc();
221
14.5k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXStdInitializerListExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
2.07k
                                SourceLocation (Expr::*v)() const) {
220
2.07k
    return static_cast<const E *>(expr)->getBeginLoc();
221
2.07k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXThisExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
1.25M
                                SourceLocation (Expr::*v)() const) {
220
1.25M
    return static_cast<const E *>(expr)->getBeginLoc();
221
1.25M
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXThrowExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
38.9k
                                SourceLocation (Expr::*v)() const) {
220
38.9k
    return static_cast<const E *>(expr)->getBeginLoc();
221
38.9k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXTypeidExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
2.69k
                                SourceLocation (Expr::*v)() const) {
220
2.69k
    return static_cast<const E *>(expr)->getBeginLoc();
221
2.69k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXUnresolvedConstructExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
6.33k
                                SourceLocation (Expr::*v)() const) {
220
6.33k
    return static_cast<const E *>(expr)->getBeginLoc();
221
6.33k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXUuidofExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
218
                                SourceLocation (Expr::*v)() const) {
220
218
    return static_cast<const E *>(expr)->getBeginLoc();
221
218
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CallExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
9.97M
                                SourceLocation (Expr::*v)() const) {
220
9.97M
    return static_cast<const E *>(expr)->getBeginLoc();
221
9.97M
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CUDAKernelCallExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
260
                                SourceLocation (Expr::*v)() const) {
220
260
    return static_cast<const E *>(expr)->getBeginLoc();
221
260
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::UserDefinedLiteral>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
3.02k
                                SourceLocation (Expr::*v)() const) {
220
3.02k
    return static_cast<const E *>(expr)->getBeginLoc();
221
3.02k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::BuiltinBitCastExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
163
                                SourceLocation (Expr::*v)() const) {
220
163
    return static_cast<const E *>(expr)->getBeginLoc();
221
163
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CStyleCastExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
4.28M
                                SourceLocation (Expr::*v)() const) {
220
4.28M
    return static_cast<const E *>(expr)->getBeginLoc();
221
4.28M
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXFunctionalCastExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
65.0k
                                SourceLocation (Expr::*v)() const) {
220
65.0k
    return static_cast<const E *>(expr)->getBeginLoc();
221
65.0k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXConstCastExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
569
                                SourceLocation (Expr::*v)() const) {
220
569
    return static_cast<const E *>(expr)->getBeginLoc();
221
569
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXDynamicCastExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
428
                                SourceLocation (Expr::*v)() const) {
220
428
    return static_cast<const E *>(expr)->getBeginLoc();
221
428
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXReinterpretCastExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
2.16k
                                SourceLocation (Expr::*v)() const) {
220
2.16k
    return static_cast<const E *>(expr)->getBeginLoc();
221
2.16k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CXXStaticCastExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
69.0k
                                SourceLocation (Expr::*v)() const) {
220
69.0k
    return static_cast<const E *>(expr)->getBeginLoc();
221
69.0k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ObjCBridgedCastExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
366
                                SourceLocation (Expr::*v)() const) {
220
366
    return static_cast<const E *>(expr)->getBeginLoc();
221
366
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ImplicitCastExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
5.85M
                                SourceLocation (Expr::*v)() const) {
220
5.85M
    return static_cast<const E *>(expr)->getBeginLoc();
221
5.85M
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CharacterLiteral>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
874k
                                SourceLocation (Expr::*v)() const) {
220
874k
    return static_cast<const E *>(expr)->getBeginLoc();
221
874k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ChooseExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
30
                                SourceLocation (Expr::*v)() const) {
220
30
    return static_cast<const E *>(expr)->getBeginLoc();
221
30
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CompoundLiteralExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
78.3k
                                SourceLocation (Expr::*v)() const) {
220
78.3k
    return static_cast<const E *>(expr)->getBeginLoc();
221
78.3k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ConceptSpecializationExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
468
                                SourceLocation (Expr::*v)() const) {
220
468
    return static_cast<const E *>(expr)->getBeginLoc();
221
468
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ConvertVectorExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
18.5k
                                SourceLocation (Expr::*v)() const) {
220
18.5k
    return static_cast<const E *>(expr)->getBeginLoc();
221
18.5k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CoawaitExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
1.33k
                                SourceLocation (Expr::*v)() const) {
220
1.33k
    return static_cast<const E *>(expr)->getBeginLoc();
221
1.33k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::CoyieldExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
142
                                SourceLocation (Expr::*v)() const) {
220
142
    return static_cast<const E *>(expr)->getBeginLoc();
221
142
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::DeclRefExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
22.1M
                                SourceLocation (Expr::*v)() const) {
220
22.1M
    return static_cast<const E *>(expr)->getBeginLoc();
221
22.1M
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::DependentCoawaitExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
50
                                SourceLocation (Expr::*v)() const) {
220
50
    return static_cast<const E *>(expr)->getBeginLoc();
221
50
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::DependentScopeDeclRefExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
1.19k
                                SourceLocation (Expr::*v)() const) {
220
1.19k
    return static_cast<const E *>(expr)->getBeginLoc();
221
1.19k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::DesignatedInitExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
10
                                SourceLocation (Expr::*v)() const) {
220
10
    return static_cast<const E *>(expr)->getBeginLoc();
221
10
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::DesignatedInitUpdateExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
64
                                SourceLocation (Expr::*v)() const) {
220
64
    return static_cast<const E *>(expr)->getBeginLoc();
221
64
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ExpressionTraitExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
5
                                SourceLocation (Expr::*v)() const) {
220
5
    return static_cast<const E *>(expr)->getBeginLoc();
221
5
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ExtVectorElementExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
1.51k
                                SourceLocation (Expr::*v)() const) {
220
1.51k
    return static_cast<const E *>(expr)->getBeginLoc();
221
1.51k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::FixedPointLiteral>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
965
                                SourceLocation (Expr::*v)() const) {
220
965
    return static_cast<const E *>(expr)->getBeginLoc();
221
965
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::FloatingLiteral>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
74.0k
                                SourceLocation (Expr::*v)() const) {
220
74.0k
    return static_cast<const E *>(expr)->getBeginLoc();
221
74.0k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ConstantExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
133k
                                SourceLocation (Expr::*v)() const) {
220
133k
    return static_cast<const E *>(expr)->getBeginLoc();
221
133k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ExprWithCleanups>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
22.9k
                                SourceLocation (Expr::*v)() const) {
220
22.9k
    return static_cast<const E *>(expr)->getBeginLoc();
221
22.9k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::FunctionParmPackExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
130
                                SourceLocation (Expr::*v)() const) {
220
130
    return static_cast<const E *>(expr)->getBeginLoc();
221
130
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::GNUNullExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
4.97k
                                SourceLocation (Expr::*v)() const) {
220
4.97k
    return static_cast<const E *>(expr)->getBeginLoc();
221
4.97k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::GenericSelectionExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
259
                                SourceLocation (Expr::*v)() const) {
220
259
    return static_cast<const E *>(expr)->getBeginLoc();
221
259
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ImaginaryLiteral>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
504
                                SourceLocation (Expr::*v)() const) {
220
504
    return static_cast<const E *>(expr)->getBeginLoc();
221
504
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ImplicitValueInitExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
17.6k
                                SourceLocation (Expr::*v)() const) {
220
17.6k
    return static_cast<const E *>(expr)->getBeginLoc();
221
17.6k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::InitListExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
118k
                                SourceLocation (Expr::*v)() const) {
220
118k
    return static_cast<const E *>(expr)->getBeginLoc();
221
118k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::IntegerLiteral>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
10.3M
                                SourceLocation (Expr::*v)() const) {
220
10.3M
    return static_cast<const E *>(expr)->getBeginLoc();
221
10.3M
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::LambdaExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
27.0k
                                SourceLocation (Expr::*v)() const) {
220
27.0k
    return static_cast<const E *>(expr)->getBeginLoc();
221
27.0k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::MSPropertyRefExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
631
                                SourceLocation (Expr::*v)() const) {
220
631
    return static_cast<const E *>(expr)->getBeginLoc();
221
631
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::MaterializeTemporaryExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
41.1k
                                SourceLocation (Expr::*v)() const) {
220
41.1k
    return static_cast<const E *>(expr)->getBeginLoc();
221
41.1k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::NoInitExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
101
                                SourceLocation (Expr::*v)() const) {
220
101
    return static_cast<const E *>(expr)->getBeginLoc();
221
101
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ObjCArrayLiteral>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
821
                                SourceLocation (Expr::*v)() const) {
220
821
    return static_cast<const E *>(expr)->getBeginLoc();
221
821
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ObjCAvailabilityCheckExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
181
                                SourceLocation (Expr::*v)() const) {
220
181
    return static_cast<const E *>(expr)->getBeginLoc();
221
181
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ObjCBoolLiteralExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
3.02k
                                SourceLocation (Expr::*v)() const) {
220
3.02k
    return static_cast<const E *>(expr)->getBeginLoc();
221
3.02k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ObjCBoxedExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
3.36k
                                SourceLocation (Expr::*v)() const) {
220
3.36k
    return static_cast<const E *>(expr)->getBeginLoc();
221
3.36k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ObjCDictionaryLiteral>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
633
                                SourceLocation (Expr::*v)() const) {
220
633
    return static_cast<const E *>(expr)->getBeginLoc();
221
633
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ObjCEncodeExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
196
                                SourceLocation (Expr::*v)() const) {
220
196
    return static_cast<const E *>(expr)->getBeginLoc();
221
196
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ObjCIvarRefExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
9.73k
                                SourceLocation (Expr::*v)() const) {
220
9.73k
    return static_cast<const E *>(expr)->getBeginLoc();
221
9.73k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ObjCMessageExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
96.8k
                                SourceLocation (Expr::*v)() const) {
220
96.8k
    return static_cast<const E *>(expr)->getBeginLoc();
221
96.8k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ObjCPropertyRefExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
6.68k
                                SourceLocation (Expr::*v)() const) {
220
6.68k
    return static_cast<const E *>(expr)->getBeginLoc();
221
6.68k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ObjCProtocolExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
96
                                SourceLocation (Expr::*v)() const) {
220
96
    return static_cast<const E *>(expr)->getBeginLoc();
221
96
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ObjCSelectorExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
786
                                SourceLocation (Expr::*v)() const) {
220
786
    return static_cast<const E *>(expr)->getBeginLoc();
221
786
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ObjCStringLiteral>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
24.4k
                                SourceLocation (Expr::*v)() const) {
220
24.4k
    return static_cast<const E *>(expr)->getBeginLoc();
221
24.4k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ObjCSubscriptRefExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
722
                                SourceLocation (Expr::*v)() const) {
220
722
    return static_cast<const E *>(expr)->getBeginLoc();
221
722
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::OffsetOfExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
776
                                SourceLocation (Expr::*v)() const) {
220
776
    return static_cast<const E *>(expr)->getBeginLoc();
221
776
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::UnresolvedLookupExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
922k
                                SourceLocation (Expr::*v)() const) {
220
922k
    return static_cast<const E *>(expr)->getBeginLoc();
221
922k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::PackExpansionExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
12
                                SourceLocation (Expr::*v)() const) {
220
12
    return static_cast<const E *>(expr)->getBeginLoc();
221
12
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ParenExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
605k
                                SourceLocation (Expr::*v)() const) {
220
605k
    return static_cast<const E *>(expr)->getBeginLoc();
221
605k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ParenListExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
4.88k
                                SourceLocation (Expr::*v)() const) {
220
4.88k
    return static_cast<const E *>(expr)->getBeginLoc();
221
4.88k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::PredefinedExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
2.01k
                                SourceLocation (Expr::*v)() const) {
220
2.01k
    return static_cast<const E *>(expr)->getBeginLoc();
221
2.01k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::RequiresExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
237
                                SourceLocation (Expr::*v)() const) {
220
237
    return static_cast<const E *>(expr)->getBeginLoc();
221
237
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::ShuffleVectorExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
328k
                                SourceLocation (Expr::*v)() const) {
220
328k
    return static_cast<const E *>(expr)->getBeginLoc();
221
328k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::SizeOfPackExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
177k
                                SourceLocation (Expr::*v)() const) {
220
177k
    return static_cast<const E *>(expr)->getBeginLoc();
221
177k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::SourceLocExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
318
                                SourceLocation (Expr::*v)() const) {
220
318
    return static_cast<const E *>(expr)->getBeginLoc();
221
318
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::StmtExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
9.09k
                                SourceLocation (Expr::*v)() const) {
220
9.09k
    return static_cast<const E *>(expr)->getBeginLoc();
221
9.09k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::StringLiteral>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
369k
                                SourceLocation (Expr::*v)() const) {
220
369k
    return static_cast<const E *>(expr)->getBeginLoc();
221
369k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::SubstNonTypeTemplateParmExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
888k
                                SourceLocation (Expr::*v)() const) {
220
888k
    return static_cast<const E *>(expr)->getBeginLoc();
221
888k
  }
Unexecuted instantiation: Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::SubstNonTypeTemplateParmPackExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::TypeTraitExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
337k
                                SourceLocation (Expr::*v)() const) {
220
337k
    return static_cast<const E *>(expr)->getBeginLoc();
221
337k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::TypoExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
78
                                SourceLocation (Expr::*v)() const) {
220
78
    return static_cast<const E *>(expr)->getBeginLoc();
221
78
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::UnaryExprOrTypeTraitExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
196k
                                SourceLocation (Expr::*v)() const) {
220
196k
    return static_cast<const E *>(expr)->getBeginLoc();
221
196k
  }
Expr.cpp:clang::SourceLocation (anonymous namespace)::getExprLocImpl<clang::VAArgExpr>(clang::Expr const*, clang::SourceLocation (clang::Expr::*)() const)
Line
Count
Source
219
3.11k
                                SourceLocation (Expr::*v)() const) {
220
3.11k
    return static_cast<const E *>(expr)->getBeginLoc();
221
3.11k
  }
222
}
223
224
78.2M
SourceLocation Expr::getExprLoc() const {
225
78.2M
  switch (getStmtClass()) {
226
0
  case Stmt::NoStmtClass: llvm_unreachable("statement without class");
227
0
#define ABSTRACT_STMT(type)
228
0
#define STMT(type, base) \
229
0
  case Stmt::type##Class: break;
230
0
#define EXPR(type, base) \
231
78.2M
  case Stmt::type##Class: return getExprLocImpl<type>(this, &type::getExprLoc);
232
0
#include "clang/AST/StmtNodes.inc"
233
78.2M
  }
234
78.2M
  
llvm_unreachable0
("unknown expression kind");
235
78.2M
}
236
237
//===----------------------------------------------------------------------===//
238
// Primary Expressions.
239
//===----------------------------------------------------------------------===//
240
241
6.65M
static void AssertResultStorageKind(ConstantExpr::ResultStorageKind Kind) {
242
6.65M
  assert((Kind == ConstantExpr::RSK_APValue ||
243
6.65M
          Kind == ConstantExpr::RSK_Int64 || Kind == ConstantExpr::RSK_None) &&
244
6.65M
         "Invalid StorageKind Value");
245
6.65M
}
246
247
ConstantExpr::ResultStorageKind
248
4.66M
ConstantExpr::getStorageKind(const APValue &Value) {
249
4.66M
  switch (Value.getKind()) {
250
11.9k
  case APValue::None:
251
11.9k
  case APValue::Indeterminate:
252
11.9k
    return ConstantExpr::RSK_None;
253
4.64M
  case APValue::Int:
254
4.64M
    if (!Value.getInt().needsCleanup())
255
4.64M
      return ConstantExpr::RSK_Int64;
256
0
    LLVM_FALLTHROUGH;
257
1.46k
  default:
258
1.46k
    return ConstantExpr::RSK_APValue;
259
4.66M
  }
260
4.66M
}
261
262
ConstantExpr::ResultStorageKind
263
79
ConstantExpr::getStorageKind(const Type *T, const ASTContext &Context) {
264
79
  if (T->isIntegralOrEnumerationType() && 
Context.getTypeInfo(T).Width <= 6449
)
265
49
    return ConstantExpr::RSK_Int64;
266
30
  return ConstantExpr::RSK_APValue;
267
30
}
268
269
6.65M
void ConstantExpr::DefaultInit(ResultStorageKind StorageKind) {
270
6.65M
  ConstantExprBits.ResultKind = StorageKind;
271
6.65M
  ConstantExprBits.APValueKind = APValue::None;
272
6.65M
  ConstantExprBits.HasCleanup = false;
273
6.65M
  if (StorageKind == ConstantExpr::RSK_APValue)
274
762
    ::new (getTrailingObjects<APValue>()) APValue();
275
6.65M
}
276
277
ConstantExpr::ConstantExpr(Expr *subexpr, ResultStorageKind StorageKind)
278
6.58M
    : FullExpr(ConstantExprClass, subexpr) {
279
6.58M
  DefaultInit(StorageKind);
280
6.58M
}
281
282
ConstantExpr *ConstantExpr::Create(const ASTContext &Context, Expr *E,
283
                                   ResultStorageKind StorageKind,
284
6.58M
                                   bool IsImmediateInvocation) {
285
6.58M
  assert(!isa<ConstantExpr>(E));
286
6.58M
  AssertResultStorageKind(StorageKind);
287
6.58M
  unsigned Size = totalSizeToAlloc<APValue, uint64_t>(
288
6.58M
      StorageKind == ConstantExpr::RSK_APValue,
289
6.58M
      StorageKind == ConstantExpr::RSK_Int64);
290
6.58M
  void *Mem = Context.Allocate(Size, alignof(ConstantExpr));
291
6.58M
  ConstantExpr *Self = new (Mem) ConstantExpr(E, StorageKind);
292
6.58M
  Self->ConstantExprBits.IsImmediateInvocation =
293
6.58M
      IsImmediateInvocation;
294
6.58M
  return Self;
295
6.58M
}
296
297
ConstantExpr *ConstantExpr::Create(const ASTContext &Context, Expr *E,
298
2.33M
                                   const APValue &Result) {
299
2.33M
  ResultStorageKind StorageKind = getStorageKind(Result);
300
2.33M
  ConstantExpr *Self = Create(Context, E, StorageKind);
301
2.33M
  Self->SetResult(Result, Context);
302
2.33M
  return Self;
303
2.33M
}
304
305
ConstantExpr::ConstantExpr(ResultStorageKind StorageKind, EmptyShell Empty)
306
76.3k
    : FullExpr(ConstantExprClass, Empty) {
307
76.3k
  DefaultInit(StorageKind);
308
76.3k
}
309
310
ConstantExpr *ConstantExpr::CreateEmpty(const ASTContext &Context,
311
                                        ResultStorageKind StorageKind,
312
76.3k
                                        EmptyShell Empty) {
313
76.3k
  AssertResultStorageKind(StorageKind);
314
76.3k
  unsigned Size = totalSizeToAlloc<APValue, uint64_t>(
315
76.3k
      StorageKind == ConstantExpr::RSK_APValue,
316
76.3k
      StorageKind == ConstantExpr::RSK_Int64);
317
76.3k
  void *Mem = Context.Allocate(Size, alignof(ConstantExpr));
318
76.3k
  ConstantExpr *Self = new (Mem) ConstantExpr(StorageKind, Empty);
319
76.3k
  return Self;
320
76.3k
}
321
322
2.33M
void ConstantExpr::MoveIntoResult(APValue &Value, const ASTContext &Context) {
323
2.33M
  assert((unsigned)getStorageKind(Value) <= ConstantExprBits.ResultKind &&
324
2.33M
         "Invalid storage for this value kind");
325
2.33M
  ConstantExprBits.APValueKind = Value.getKind();
326
2.33M
  switch (ConstantExprBits.ResultKind) {
327
5.96k
  case RSK_None:
328
5.96k
    return;
329
2.32M
  case RSK_Int64:
330
2.32M
    Int64Result() = *Value.getInt().getRawData();
331
2.32M
    ConstantExprBits.BitWidth = Value.getInt().getBitWidth();
332
2.32M
    ConstantExprBits.IsUnsigned = Value.getInt().isUnsigned();
333
2.32M
    return;
334
735
  case RSK_APValue:
335
735
    if (!ConstantExprBits.HasCleanup && Value.needsCleanup()) {
336
3
      ConstantExprBits.HasCleanup = true;
337
3
      Context.addDestruction(&APValueResult());
338
3
    }
339
735
    APValueResult() = std::move(Value);
340
735
    return;
341
0
  }
342
0
  llvm_unreachable("Invalid ResultKind Bits");
343
0
}
344
345
0
llvm::APSInt ConstantExpr::getResultAsAPSInt() const {
346
0
  switch (ConstantExprBits.ResultKind) {
347
0
  case ConstantExpr::RSK_APValue:
348
0
    return APValueResult().getInt();
349
0
  case ConstantExpr::RSK_Int64:
350
0
    return llvm::APSInt(llvm::APInt(ConstantExprBits.BitWidth, Int64Result()),
351
0
                        ConstantExprBits.IsUnsigned);
352
0
  default:
353
0
    llvm_unreachable("invalid Accessor");
354
0
  }
355
0
}
356
357
81.8k
APValue ConstantExpr::getAPValueResult() const {
358
81.8k
  switch (ConstantExprBits.ResultKind) {
359
0
  case ConstantExpr::RSK_APValue:
360
0
    return APValueResult();
361
81.8k
  case ConstantExpr::RSK_Int64:
362
81.8k
    return APValue(
363
81.8k
        llvm::APSInt(llvm::APInt(ConstantExprBits.BitWidth, Int64Result()),
364
81.8k
                     ConstantExprBits.IsUnsigned));
365
0
  case ConstantExpr::RSK_None:
366
0
    return APValue();
367
0
  }
368
0
  llvm_unreachable("invalid ResultKind");
369
0
}
370
371
/// Compute the type-, value-, and instantiation-dependence of a
372
/// declaration reference
373
/// based on the declaration being referenced.
374
static void computeDeclRefDependence(const ASTContext &Ctx, NamedDecl *D,
375
                                     QualType T, bool &TypeDependent,
376
                                     bool &ValueDependent,
377
17.8M
                                     bool &InstantiationDependent) {
378
17.8M
  TypeDependent = false;
379
17.8M
  ValueDependent = false;
380
17.8M
  InstantiationDependent = false;
381
17.8M
382
17.8M
  // (TD) C++ [temp.dep.expr]p3:
383
17.8M
  //   An id-expression is type-dependent if it contains:
384
17.8M
  //
385
17.8M
  // and
386
17.8M
  //
387
17.8M
  // (VD) C++ [temp.dep.constexpr]p2:
388
17.8M
  //  An identifier is value-dependent if it is:
389
17.8M
390
17.8M
  //  (TD)  - an identifier that was declared with dependent type
391
17.8M
  //  (VD)  - a name declared with a dependent type,
392
17.8M
  if (T->isDependentType()) {
393
3.24M
    TypeDependent = true;
394
3.24M
    ValueDependent = true;
395
3.24M
    InstantiationDependent = true;
396
3.24M
    return;
397
14.5M
  } else if (T->isInstantiationDependentType()) {
398
18
    InstantiationDependent = true;
399
18
  }
400
17.8M
401
17.8M
  //  (TD)  - a conversion-function-id that specifies a dependent type
402
17.8M
  
if (14.5M
D->getDeclName().getNameKind()
403
14.5M
                                == DeclarationName::CXXConversionFunctionName) {
404
348k
    QualType T = D->getDeclName().getCXXNameType();
405
348k
    if (T->isDependentType()) {
406
0
      TypeDependent = true;
407
0
      ValueDependent = true;
408
0
      InstantiationDependent = true;
409
0
      return;
410
0
    }
411
348k
412
348k
    if (T->isInstantiationDependentType())
413
0
      InstantiationDependent = true;
414
348k
  }
415
14.5M
416
14.5M
  //  (VD)  - the name of a non-type template parameter,
417
14.5M
  if (isa<NonTypeTemplateParmDecl>(D)) {
418
416k
    ValueDependent = true;
419
416k
    InstantiationDependent = true;
420
416k
    return;
421
416k
  }
422
14.1M
423
14.1M
  //  (VD) - a constant with integral or enumeration type and is
424
14.1M
  //         initialized with an expression that is value-dependent.
425
14.1M
  //  (VD) - a constant with literal type and is initialized with an
426
14.1M
  //         expression that is value-dependent [C++11].
427
14.1M
  //  (VD) - FIXME: Missing from the standard:
428
14.1M
  //       -  an entity with reference type and is initialized with an
429
14.1M
  //          expression that is value-dependent [C++11]
430
14.1M
  if (VarDecl *Var = dyn_cast<VarDecl>(D)) {
431
10.6M
    if ((Ctx.getLangOpts().CPlusPlus11 ?
432
6.00M
           Var->getType()->isLiteralType(Ctx) :
433
10.6M
           
Var->getType()->isIntegralOrEnumerationType()4.59M
) &&
434
10.6M
        
(7.06M
Var->getType().isConstQualified()7.06M
||
435
7.06M
         
Var->getType()->isReferenceType()5.02M
)) {
436
2.31M
      if (const Expr *Init = Var->getAnyInitializer())
437
2.02M
        if (Init->isValueDependent()) {
438
84.0k
          ValueDependent = true;
439
84.0k
          InstantiationDependent = true;
440
84.0k
        }
441
2.31M
    }
442
10.6M
443
10.6M
    // (VD) - FIXME: Missing from the standard:
444
10.6M
    //      -  a member function or a static data member of the current
445
10.6M
    //         instantiation
446
10.6M
    if (Var->isStaticDataMember() &&
447
10.6M
        
Var->getDeclContext()->isDependentContext()1.86M
) {
448
72.1k
      ValueDependent = true;
449
72.1k
      InstantiationDependent = true;
450
72.1k
      TypeSourceInfo *TInfo = Var->getFirstDecl()->getTypeSourceInfo();
451
72.1k
      if (TInfo->getType()->isIncompleteArrayType())
452
18
        TypeDependent = true;
453
72.1k
    }
454
10.6M
455
10.6M
    return;
456
10.6M
  }
457
3.56M
458
3.56M
  // (VD) - FIXME: Missing from the standard:
459
3.56M
  //      -  a member function or a static data member of the current
460
3.56M
  //         instantiation
461
3.56M
  if (isa<CXXMethodDecl>(D) && 
D->getDeclContext()->isDependentContext()534k
) {
462
1.09k
    ValueDependent = true;
463
1.09k
    InstantiationDependent = true;
464
1.09k
  }
465
3.56M
}
466
467
17.8M
void DeclRefExpr::computeDependence(const ASTContext &Ctx) {
468
17.8M
  bool TypeDependent = false;
469
17.8M
  bool ValueDependent = false;
470
17.8M
  bool InstantiationDependent = false;
471
17.8M
  computeDeclRefDependence(Ctx, getDecl(), getType(), TypeDependent,
472
17.8M
                           ValueDependent, InstantiationDependent);
473
17.8M
474
17.8M
  ExprBits.TypeDependent |= TypeDependent;
475
17.8M
  ExprBits.ValueDependent |= ValueDependent;
476
17.8M
  ExprBits.InstantiationDependent |= InstantiationDependent;
477
17.8M
478
17.8M
  // Is the declaration a parameter pack?
479
17.8M
  if (getDecl()->isParameterPack())
480
74.7k
    ExprBits.ContainsUnexpandedParameterPack = true;
481
17.8M
}
482
483
DeclRefExpr::DeclRefExpr(const ASTContext &Ctx, ValueDecl *D,
484
                         bool RefersToEnclosingVariableOrCapture, QualType T,
485
                         ExprValueKind VK, SourceLocation L,
486
                         const DeclarationNameLoc &LocInfo,
487
                         NonOdrUseReason NOUR)
488
    : Expr(DeclRefExprClass, T, VK, OK_Ordinary, false, false, false, false),
489
620k
      D(D), DNLoc(LocInfo) {
490
620k
  DeclRefExprBits.HasQualifier = false;
491
620k
  DeclRefExprBits.HasTemplateKWAndArgsInfo = false;
492
620k
  DeclRefExprBits.HasFoundDecl = false;
493
620k
  DeclRefExprBits.HadMultipleCandidates = false;
494
620k
  DeclRefExprBits.RefersToEnclosingVariableOrCapture =
495
620k
      RefersToEnclosingVariableOrCapture;
496
620k
  DeclRefExprBits.NonOdrUseReason = NOUR;
497
620k
  DeclRefExprBits.Loc = L;
498
620k
  computeDependence(Ctx);
499
620k
}
500
501
DeclRefExpr::DeclRefExpr(const ASTContext &Ctx,
502
                         NestedNameSpecifierLoc QualifierLoc,
503
                         SourceLocation TemplateKWLoc, ValueDecl *D,
504
                         bool RefersToEnclosingVariableOrCapture,
505
                         const DeclarationNameInfo &NameInfo, NamedDecl *FoundD,
506
                         const TemplateArgumentListInfo *TemplateArgs,
507
                         QualType T, ExprValueKind VK, NonOdrUseReason NOUR)
508
    : Expr(DeclRefExprClass, T, VK, OK_Ordinary, false, false, false, false),
509
17.2M
      D(D), DNLoc(NameInfo.getInfo()) {
510
17.2M
  DeclRefExprBits.Loc = NameInfo.getLoc();
511
17.2M
  DeclRefExprBits.HasQualifier = QualifierLoc ? 
11.82M
:
015.3M
;
512
17.2M
  if (QualifierLoc) {
513
1.82M
    new (getTrailingObjects<NestedNameSpecifierLoc>())
514
1.82M
        NestedNameSpecifierLoc(QualifierLoc);
515
1.82M
    auto *NNS = QualifierLoc.getNestedNameSpecifier();
516
1.82M
    if (NNS->isInstantiationDependent())
517
229
      ExprBits.InstantiationDependent = true;
518
1.82M
    if (NNS->containsUnexpandedParameterPack())
519
1
      ExprBits.ContainsUnexpandedParameterPack = true;
520
1.82M
  }
521
17.2M
  DeclRefExprBits.HasFoundDecl = FoundD ? 
1248k
:
016.9M
;
522
17.2M
  if (FoundD)
523
248k
    *getTrailingObjects<NamedDecl *>() = FoundD;
524
17.2M
  DeclRefExprBits.HasTemplateKWAndArgsInfo
525
17.2M
    = (TemplateArgs || 
TemplateKWLoc.isValid()17.0M
) ?
1172k
:
017.0M
;
526
17.2M
  DeclRefExprBits.RefersToEnclosingVariableOrCapture =
527
17.2M
      RefersToEnclosingVariableOrCapture;
528
17.2M
  DeclRefExprBits.NonOdrUseReason = NOUR;
529
17.2M
  if (TemplateArgs) {
530
172k
    bool Dependent = false;
531
172k
    bool InstantiationDependent = false;
532
172k
    bool ContainsUnexpandedParameterPack = false;
533
172k
    getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
534
172k
        TemplateKWLoc, *TemplateArgs, getTrailingObjects<TemplateArgumentLoc>(),
535
172k
        Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
536
172k
    assert(!Dependent && "built a DeclRefExpr with dependent template args");
537
172k
    ExprBits.InstantiationDependent |= InstantiationDependent;
538
172k
    ExprBits.ContainsUnexpandedParameterPack |= ContainsUnexpandedParameterPack;
539
17.0M
  } else if (TemplateKWLoc.isValid()) {
540
19
    getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
541
19
        TemplateKWLoc);
542
19
  }
543
17.2M
  DeclRefExprBits.HadMultipleCandidates = 0;
544
17.2M
545
17.2M
  computeDependence(Ctx);
546
17.2M
}
547
548
DeclRefExpr *DeclRefExpr::Create(const ASTContext &Context,
549
                                 NestedNameSpecifierLoc QualifierLoc,
550
                                 SourceLocation TemplateKWLoc, ValueDecl *D,
551
                                 bool RefersToEnclosingVariableOrCapture,
552
                                 SourceLocation NameLoc, QualType T,
553
                                 ExprValueKind VK, NamedDecl *FoundD,
554
                                 const TemplateArgumentListInfo *TemplateArgs,
555
1.41M
                                 NonOdrUseReason NOUR) {
556
1.41M
  return Create(Context, QualifierLoc, TemplateKWLoc, D,
557
1.41M
                RefersToEnclosingVariableOrCapture,
558
1.41M
                DeclarationNameInfo(D->getDeclName(), NameLoc),
559
1.41M
                T, VK, FoundD, TemplateArgs, NOUR);
560
1.41M
}
561
562
DeclRefExpr *DeclRefExpr::Create(const ASTContext &Context,
563
                                 NestedNameSpecifierLoc QualifierLoc,
564
                                 SourceLocation TemplateKWLoc, ValueDecl *D,
565
                                 bool RefersToEnclosingVariableOrCapture,
566
                                 const DeclarationNameInfo &NameInfo,
567
                                 QualType T, ExprValueKind VK,
568
                                 NamedDecl *FoundD,
569
                                 const TemplateArgumentListInfo *TemplateArgs,
570
17.2M
                                 NonOdrUseReason NOUR) {
571
17.2M
  // Filter out cases where the found Decl is the same as the value refenenced.
572
17.2M
  if (D == FoundD)
573
15.2M
    FoundD = nullptr;
574
17.2M
575
17.2M
  bool HasTemplateKWAndArgsInfo = TemplateArgs || 
TemplateKWLoc.isValid()17.0M
;
576
17.2M
  std::size_t Size =
577
17.2M
      totalSizeToAlloc<NestedNameSpecifierLoc, NamedDecl *,
578
17.2M
                       ASTTemplateKWAndArgsInfo, TemplateArgumentLoc>(
579
17.2M
          QualifierLoc ? 
11.82M
:
015.3M
, FoundD ?
1248k
:
016.9M
,
580
17.2M
          HasTemplateKWAndArgsInfo ? 
1172k
:
017.0M
,
581
17.2M
          TemplateArgs ? 
TemplateArgs->size()172k
:
017.0M
);
582
17.2M
583
17.2M
  void *Mem = Context.Allocate(Size, alignof(DeclRefExpr));
584
17.2M
  return new (Mem) DeclRefExpr(Context, QualifierLoc, TemplateKWLoc, D,
585
17.2M
                               RefersToEnclosingVariableOrCapture, NameInfo,
586
17.2M
                               FoundD, TemplateArgs, T, VK, NOUR);
587
17.2M
}
588
589
DeclRefExpr *DeclRefExpr::CreateEmpty(const ASTContext &Context,
590
                                      bool HasQualifier,
591
                                      bool HasFoundDecl,
592
                                      bool HasTemplateKWAndArgsInfo,
593
390k
                                      unsigned NumTemplateArgs) {
594
390k
  assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
595
390k
  std::size_t Size =
596
390k
      totalSizeToAlloc<NestedNameSpecifierLoc, NamedDecl *,
597
390k
                       ASTTemplateKWAndArgsInfo, TemplateArgumentLoc>(
598
390k
          HasQualifier ? 
129.9k
:
0360k
, HasFoundDecl ?
113.6k
:
0376k
, HasTemplateKWAndArgsInfo,
599
390k
          NumTemplateArgs);
600
390k
  void *Mem = Context.Allocate(Size, alignof(DeclRefExpr));
601
390k
  return new (Mem) DeclRefExpr(EmptyShell());
602
390k
}
603
604
90.3M
SourceLocation DeclRefExpr::getBeginLoc() const {
605
90.3M
  if (hasQualifier())
606
8.31M
    return getQualifierLoc().getBeginLoc();
607
82.0M
  return getNameInfo().getBeginLoc();
608
82.0M
}
609
7.46M
SourceLocation DeclRefExpr::getEndLoc() const {
610
7.46M
  if (hasExplicitTemplateArgs())
611
169k
    return getRAngleLoc();
612
7.29M
  return getNameInfo().getEndLoc();
613
7.29M
}
614
615
PredefinedExpr::PredefinedExpr(SourceLocation L, QualType FNTy, IdentKind IK,
616
                               StringLiteral *SL)
617
    : Expr(PredefinedExprClass, FNTy, VK_LValue, OK_Ordinary,
618
           FNTy->isDependentType(), FNTy->isDependentType(),
619
           FNTy->isInstantiationDependentType(),
620
752
           /*ContainsUnexpandedParameterPack=*/false) {
621
752
  PredefinedExprBits.Kind = IK;
622
752
  assert((getIdentKind() == IK) &&
623
752
         "IdentKind do not fit in PredefinedExprBitfields!");
624
752
  bool HasFunctionName = SL != nullptr;
625
752
  PredefinedExprBits.HasFunctionName = HasFunctionName;
626
752
  PredefinedExprBits.Loc = L;
627
752
  if (HasFunctionName)
628
694
    setFunctionName(SL);
629
752
}
630
631
PredefinedExpr::PredefinedExpr(EmptyShell Empty, bool HasFunctionName)
632
17
    : Expr(PredefinedExprClass, Empty) {
633
17
  PredefinedExprBits.HasFunctionName = HasFunctionName;
634
17
}
635
636
PredefinedExpr *PredefinedExpr::Create(const ASTContext &Ctx, SourceLocation L,
637
                                       QualType FNTy, IdentKind IK,
638
752
                                       StringLiteral *SL) {
639
752
  bool HasFunctionName = SL != nullptr;
640
752
  void *Mem = Ctx.Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
641
752
                           alignof(PredefinedExpr));
642
752
  return new (Mem) PredefinedExpr(L, FNTy, IK, SL);
643
752
}
644
645
PredefinedExpr *PredefinedExpr::CreateEmpty(const ASTContext &Ctx,
646
17
                                            bool HasFunctionName) {
647
17
  void *Mem = Ctx.Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
648
17
                           alignof(PredefinedExpr));
649
17
  return new (Mem) PredefinedExpr(EmptyShell(), HasFunctionName);
650
17
}
651
652
541
StringRef PredefinedExpr::getIdentKindName(PredefinedExpr::IdentKind IK) {
653
541
  switch (IK) {
654
188
  case Func:
655
188
    return "__func__";
656
167
  case Function:
657
167
    return "__FUNCTION__";
658
0
  case FuncDName:
659
0
    return "__FUNCDNAME__";
660
1
  case LFunction:
661
1
    return "L__FUNCTION__";
662
176
  case PrettyFunction:
663
176
    return "__PRETTY_FUNCTION__";
664
9
  case FuncSig:
665
9
    return "__FUNCSIG__";
666
0
  case LFuncSig:
667
0
    return "L__FUNCSIG__";
668
0
  case PrettyFunctionNoVirtual:
669
0
    break;
670
0
  }
671
0
  llvm_unreachable("Unknown ident kind for PredefinedExpr");
672
0
}
673
674
// FIXME: Maybe this should use DeclPrinter with a special "print predefined
675
// expr" policy instead.
676
2.60k
std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) {
677
2.60k
  ASTContext &Context = CurrentDecl->getASTContext();
678
2.60k
679
2.60k
  if (IK == PredefinedExpr::FuncDName) {
680
5
    if (const NamedDecl *ND = dyn_cast<NamedDecl>(CurrentDecl)) {
681
5
      std::unique_ptr<MangleContext> MC;
682
5
      MC.reset(Context.createMangleContext());
683
5
684
5
      if (MC->shouldMangleDeclName(ND)) {
685
4
        SmallString<256> Buffer;
686
4
        llvm::raw_svector_ostream Out(Buffer);
687
4
        if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(ND))
688
1
          MC->mangleCXXCtor(CD, Ctor_Base, Out);
689
3
        else if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(ND))
690
1
          MC->mangleCXXDtor(DD, Dtor_Base, Out);
691
2
        else
692
2
          MC->mangleName(ND, Out);
693
4
694
4
        if (!Buffer.empty() && Buffer.front() == '\01')
695
0
          return std::string(Buffer.substr(1));
696
4
        return std::string(Buffer.str());
697
4
      } else
698
1
        return std::string(ND->getIdentifier()->getName());
699
0
    }
700
0
    return "";
701
0
  }
702
2.60k
  if (isa<BlockDecl>(CurrentDecl)) {
703
43
    // For blocks we only emit something if it is enclosed in a function
704
43
    // For top-level block we'd like to include the name of variable, but we
705
43
    // don't have it at this point.
706
43
    auto DC = CurrentDecl->getDeclContext();
707
43
    if (DC->isFileContext())
708
5
      return "";
709
38
710
38
    SmallString<256> Buffer;
711
38
    llvm::raw_svector_ostream Out(Buffer);
712
38
    if (auto *DCBlock = dyn_cast<BlockDecl>(DC))
713
5
      // For nested blocks, propagate up to the parent.
714
5
      Out << ComputeName(IK, DCBlock);
715
33
    else if (auto *DCDecl = dyn_cast<Decl>(DC))
716
33
      Out << ComputeName(IK, DCDecl) << "_block_invoke";
717
38
    return std::string(Out.str());
718
38
  }
719
2.56k
  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurrentDecl)) {
720
2.39k
    if (IK != PrettyFunction && 
IK != PrettyFunctionNoVirtual2.21k
&&
721
2.39k
        
IK != FuncSig488
&&
IK != LFuncSig479
)
722
477
      return FD->getNameAsString();
723
1.91k
724
1.91k
    SmallString<256> Name;
725
1.91k
    llvm::raw_svector_ostream Out(Name);
726
1.91k
727
1.91k
    if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
728
1.84k
      if (MD->isVirtual() && 
IK != PrettyFunctionNoVirtual1.72k
)
729
2
        Out << "virtual ";
730
1.84k
      if (MD->isStatic())
731
2
        Out << "static ";
732
1.84k
    }
733
1.91k
734
1.91k
    PrintingPolicy Policy(Context.getLangOpts());
735
1.91k
    std::string Proto;
736
1.91k
    llvm::raw_string_ostream POut(Proto);
737
1.91k
738
1.91k
    const FunctionDecl *Decl = FD;
739
1.91k
    if (const FunctionDecl* Pattern = FD->getTemplateInstantiationPattern())
740
30
      Decl = Pattern;
741
1.91k
    const FunctionType *AFT = Decl->getType()->getAs<FunctionType>();
742
1.91k
    const FunctionProtoType *FT = nullptr;
743
1.91k
    if (FD->hasWrittenPrototype())
744
1.89k
      FT = dyn_cast<FunctionProtoType>(AFT);
745
1.91k
746
1.91k
    if (IK == FuncSig || 
IK == LFuncSig1.90k
) {
747
11
      switch (AFT->getCallConv()) {
748
9
      case CC_C: POut << "__cdecl "; break;
749
0
      case CC_X86StdCall: POut << "__stdcall "; break;
750
0
      case CC_X86FastCall: POut << "__fastcall "; break;
751
2
      case CC_X86ThisCall: POut << "__thiscall "; break;
752
0
      case CC_X86VectorCall: POut << "__vectorcall "; break;
753
0
      case CC_X86RegCall: POut << "__regcall "; break;
754
0
      // Only bother printing the conventions that MSVC knows about.
755
0
      default: break;
756
1.91k
      }
757
1.91k
    }
758
1.91k
759
1.91k
    FD->printQualifiedName(POut, Policy);
760
1.91k
761
1.91k
    POut << "(";
762
1.91k
    if (FT) {
763
2.03k
      for (unsigned i = 0, e = Decl->getNumParams(); i != e; 
++i142
) {
764
142
        if (i) 
POut << ", "10
;
765
142
        POut << Decl->getParamDecl(i)->getType().stream(Policy);
766
142
      }
767
1.89k
768
1.89k
      if (FT->isVariadic()) {
769
4
        if (FD->getNumParams()) 
POut << ", "3
;
770
4
        POut << "...";
771
1.88k
      } else if ((IK == FuncSig || 
IK == LFuncSig1.88k
||
772
1.88k
                  
!Context.getLangOpts().CPlusPlus1.87k
) &&
773
1.88k
                 
!Decl->getNumParams()10
) {
774
5
        POut << "void";
775
5
      }
776
1.89k
    }
777
1.91k
    POut << ")";
778
1.91k
779
1.91k
    if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
780
1.84k
      assert(FT && "We must have a written prototype in this case.");
781
1.84k
      if (FT->isConst())
782
17
        POut << " const";
783
1.84k
      if (FT->isVolatile())
784
2
        POut << " volatile";
785
1.84k
      RefQualifierKind Ref = MD->getRefQualifier();
786
1.84k
      if (Ref == RQ_LValue)
787
1
        POut << " &";
788
1.84k
      else if (Ref == RQ_RValue)
789
1
        POut << " &&";
790
1.84k
    }
791
1.91k
792
1.91k
    typedef SmallVector<const ClassTemplateSpecializationDecl *, 8> SpecsTy;
793
1.91k
    SpecsTy Specs;
794
1.91k
    const DeclContext *Ctx = FD->getDeclContext();
795
5.28k
    while (Ctx && isa<NamedDecl>(Ctx)) {
796
3.37k
      const ClassTemplateSpecializationDecl *Spec
797
3.37k
                               = dyn_cast<ClassTemplateSpecializationDecl>(Ctx);
798
3.37k
      if (Spec && 
!Spec->isExplicitSpecialization()12
)
799
11
        Specs.push_back(Spec);
800
3.37k
      Ctx = Ctx->getParent();
801
3.37k
    }
802
1.91k
803
1.91k
    std::string TemplateParams;
804
1.91k
    llvm::raw_string_ostream TOut(TemplateParams);
805
1.91k
    for (SpecsTy::reverse_iterator I = Specs.rbegin(), E = Specs.rend();
806
1.92k
         I != E; 
++I11
) {
807
11
      const TemplateParameterList *Params
808
11
                  = (*I)->getSpecializedTemplate()->getTemplateParameters();
809
11
      const TemplateArgumentList &Args = (*I)->getTemplateArgs();
810
11
      assert(Params->size() == Args.size());
811
23
      for (unsigned i = 0, numParams = Params->size(); i != numParams; 
++i12
) {
812
12
        StringRef Param = Params->getParam(i)->getName();
813
12
        if (Param.empty()) 
continue0
;
814
12
        TOut << Param << " = ";
815
12
        Args.get(i).print(Policy, TOut);
816
12
        TOut << ", ";
817
12
      }
818
11
    }
819
1.91k
820
1.91k
    FunctionTemplateSpecializationInfo *FSI
821
1.91k
                                          = FD->getTemplateSpecializationInfo();
822
1.91k
    if (FSI && 
!FSI->isExplicitSpecialization()20
) {
823
19
      const TemplateParameterList* Params
824
19
                                  = FSI->getTemplate()->getTemplateParameters();
825
19
      const TemplateArgumentList* Args = FSI->TemplateArguments;
826
19
      assert(Params->size() == Args->size());
827
40
      for (unsigned i = 0, e = Params->size(); i != e; 
++i21
) {
828
21
        StringRef Param = Params->getParam(i)->getName();
829
21
        if (Param.empty()) 
continue1
;
830
20
        TOut << Param << " = ";
831
20
        Args->get(i).print(Policy, TOut);
832
20
        TOut << ", ";
833
20
      }
834
19
    }
835
1.91k
836
1.91k
    TOut.flush();
837
1.91k
    if (!TemplateParams.empty()) {
838
28
      // remove the trailing comma and space
839
28
      TemplateParams.resize(TemplateParams.size() - 2);
840
28
      POut << " [" << TemplateParams << "]";
841
28
    }
842
1.91k
843
1.91k
    POut.flush();
844
1.91k
845
1.91k
    // Print "auto" for all deduced return types. This includes C++1y return
846
1.91k
    // type deduction and lambdas. For trailing return types resolve the
847
1.91k
    // decltype expression. Otherwise print the real type when this is
848
1.91k
    // not a constructor or destructor.
849
1.91k
    if (isa<CXXMethodDecl>(FD) &&
850
1.91k
         
cast<CXXMethodDecl>(FD)->getParent()->isLambda()1.84k
)
851
6
      Proto = "auto " + Proto;
852
1.90k
    else if (FT && 
FT->getReturnType()->getAs<DecltypeType>()1.88k
)
853
1
      FT->getReturnType()
854
1
          ->getAs<DecltypeType>()
855
1
          ->getUnderlyingType()
856
1
          .getAsStringInternal(Proto, Policy);
857
1.90k
    else if (!isa<CXXConstructorDecl>(FD) && 
!isa<CXXDestructorDecl>(FD)1.90k
)
858
1.76k
      AFT->getReturnType().getAsStringInternal(Proto, Policy);
859
1.91k
860
1.91k
    Out << Proto;
861
1.91k
862
1.91k
    return std::string(Name);
863
1.91k
  }
864
168
  if (const CapturedDecl *CD = dyn_cast<CapturedDecl>(CurrentDecl)) {
865
22
    for (const DeclContext *DC = CD->getParent(); DC; 
DC = DC->getParent()3
)
866
22
      // Skip to its enclosing function or method, but not its enclosing
867
22
      // CapturedDecl.
868
22
      if (DC->isFunctionOrMethod() && (DC->getDeclKind() != Decl::Captured)) {
869
19
        const Decl *D = Decl::castFromDeclContext(DC);
870
19
        return ComputeName(IK, D);
871
19
      }
872
19
    
llvm_unreachable0
("CapturedDecl not inside a function or method");
873
149
  }
874
149
  if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(CurrentDecl)) {
875
107
    SmallString<256> Name;
876
107
    llvm::raw_svector_ostream Out(Name);
877
107
    Out << (MD->isInstanceMethod() ? 
'-'92
:
'+'15
);
878
107
    Out << '[';
879
107
880
107
    // For incorrect code, there might not be an ObjCInterfaceDecl.  Do
881
107
    // a null check to avoid a crash.
882
107
    if (const ObjCInterfaceDecl *ID = MD->getClassInterface())
883
106
      Out << *ID;
884
107
885
107
    if (const ObjCCategoryImplDecl *CID =
886
7
        dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext()))
887
7
      Out << '(' << *CID << ')';
888
107
889
107
    Out <<  ' ';
890
107
    MD->getSelector().print(Out);
891
107
    Out <<  ']';
892
107
893
107
    return std::string(Name);
894
107
  }
895
42
  if (isa<TranslationUnitDecl>(CurrentDecl) && 
IK == PrettyFunction18
) {
896
2
    // __PRETTY_FUNCTION__ -> "top level", the others produce an empty string.
897
2
    return "top level";
898
2
  }
899
40
  return "";
900
40
}
901
902
void APNumericStorage::setIntValue(const ASTContext &C,
903
9.56M
                                   const llvm::APInt &Val) {
904
9.56M
  if (hasAllocation())
905
0
    C.Deallocate(pVal);
906
9.56M
907
9.56M
  BitWidth = Val.getBitWidth();
908
9.56M
  unsigned NumWords = Val.getNumWords();
909
9.56M
  const uint64_t* Words = Val.getRawData();
910
9.56M
  if (NumWords > 1) {
911
4.62k
    pVal = new (C) uint64_t[NumWords];
912
4.62k
    std::copy(Words, Words + NumWords, pVal);
913
9.56M
  } else if (NumWords == 1)
914
9.56M
    VAL = Words[0];
915
0
  else
916
0
    VAL = 0;
917
9.56M
}
918
919
IntegerLiteral::IntegerLiteral(const ASTContext &C, const llvm::APInt &V,
920
                               QualType type, SourceLocation l)
921
  : Expr(IntegerLiteralClass, type, VK_RValue, OK_Ordinary, false, false,
922
         false, false),
923
9.38M
    Loc(l) {
924
9.38M
  assert(type->isIntegerType() && "Illegal type in IntegerLiteral");
925
9.38M
  assert(V.getBitWidth() == C.getIntWidth(type) &&
926
9.38M
         "Integer type is not the correct size for constant.");
927
9.38M
  setValue(C, V);
928
9.38M
}
929
930
IntegerLiteral *
931
IntegerLiteral::Create(const ASTContext &C, const llvm::APInt &V,
932
9.37M
                       QualType type, SourceLocation l) {
933
9.37M
  return new (C) IntegerLiteral(C, V, type, l);
934
9.37M
}
935
936
IntegerLiteral *
937
149k
IntegerLiteral::Create(const ASTContext &C, EmptyShell Empty) {
938
149k
  return new (C) IntegerLiteral(Empty);
939
149k
}
940
941
FixedPointLiteral::FixedPointLiteral(const ASTContext &C, const llvm::APInt &V,
942
                                     QualType type, SourceLocation l,
943
                                     unsigned Scale)
944
    : Expr(FixedPointLiteralClass, type, VK_RValue, OK_Ordinary, false, false,
945
           false, false),
946
401
      Loc(l), Scale(Scale) {
947
401
  assert(type->isFixedPointType() && "Illegal type in FixedPointLiteral");
948
401
  assert(V.getBitWidth() == C.getTypeInfo(type).Width &&
949
401
         "Fixed point type is not the correct size for constant.");
950
401
  setValue(C, V);
951
401
}
952
953
FixedPointLiteral *FixedPointLiteral::CreateFromRawInt(const ASTContext &C,
954
                                                       const llvm::APInt &V,
955
                                                       QualType type,
956
                                                       SourceLocation l,
957
401
                                                       unsigned Scale) {
958
401
  return new (C) FixedPointLiteral(C, V, type, l, Scale);
959
401
}
960
961
53
std::string FixedPointLiteral::getValueAsString(unsigned Radix) const {
962
53
  // Currently the longest decimal number that can be printed is the max for an
963
53
  // unsigned long _Accum: 4294967295.99999999976716935634613037109375
964
53
  // which is 43 characters.
965
53
  SmallString<64> S;
966
53
  FixedPointValueToString(
967
53
      S, llvm::APSInt::getUnsigned(getValue().getZExtValue()), Scale);
968
53
  return std::string(S.str());
969
53
}
970
971
FloatingLiteral::FloatingLiteral(const ASTContext &C, const llvm::APFloat &V,
972
                                 bool isexact, QualType Type, SourceLocation L)
973
  : Expr(FloatingLiteralClass, Type, VK_RValue, OK_Ordinary, false, false,
974
35.2k
         false, false), Loc(L) {
975
35.2k
  setSemantics(V.getSemantics());
976
35.2k
  FloatingLiteralBits.IsExact = isexact;
977
35.2k
  setValue(C, V);
978
35.2k
}
979
980
FloatingLiteral::FloatingLiteral(const ASTContext &C, EmptyShell Empty)
981
1.15k
  : Expr(FloatingLiteralClass, Empty) {
982
1.15k
  setRawSemantics(llvm::APFloatBase::S_IEEEhalf);
983
1.15k
  FloatingLiteralBits.IsExact = false;
984
1.15k
}
985
986
FloatingLiteral *
987
FloatingLiteral::Create(const ASTContext &C, const llvm::APFloat &V,
988
35.2k
                        bool isexact, QualType Type, SourceLocation L) {
989
35.2k
  return new (C) FloatingLiteral(C, V, isexact, Type, L);
990
35.2k
}
991
992
FloatingLiteral *
993
1.15k
FloatingLiteral::Create(const ASTContext &C, EmptyShell Empty) {
994
1.15k
  return new (C) FloatingLiteral(C, Empty);
995
1.15k
}
996
997
/// getValueAsApproximateDouble - This returns the value as an inaccurate
998
/// double.  Note that this may cause loss of precision, but is useful for
999
/// debugging dumps, etc.
1000
91
double FloatingLiteral::getValueAsApproximateDouble() const {
1001
91
  llvm::APFloat V = getValue();
1002
91
  bool ignored;
1003
91
  V.convert(llvm::APFloat::IEEEdouble(), llvm::APFloat::rmNearestTiesToEven,
1004
91
            &ignored);
1005
91
  return V.convertToDouble();
1006
91
}
1007
1008
unsigned StringLiteral::mapCharByteWidth(TargetInfo const &Target,
1009
3.24M
                                         StringKind SK) {
1010
3.24M
  unsigned CharByteWidth = 0;
1011
3.24M
  switch (SK) {
1012
3.24M
  case Ascii:
1013
3.24M
  case UTF8:
1014
3.24M
    CharByteWidth = Target.getCharWidth();
1015
3.24M
    break;
1016
3.24M
  case Wide:
1017
1.04k
    CharByteWidth = Target.getWCharWidth();
1018
1.04k
    break;
1019
3.24M
  case UTF16:
1020
113
    CharByteWidth = Target.getChar16Width();
1021
113
    break;
1022
3.24M
  case UTF32:
1023
110
    CharByteWidth = Target.getChar32Width();
1024
110
    break;
1025
3.24M
  }
1026
3.24M
  assert((CharByteWidth & 7) == 0 && "Assumes character size is byte multiple");
1027
3.24M
  CharByteWidth /= 8;
1028
3.24M
  assert((CharByteWidth == 1 || CharByteWidth == 2 || CharByteWidth == 4) &&
1029
3.24M
         "The only supported character byte widths are 1,2 and 4!");
1030
3.24M
  return CharByteWidth;
1031
3.24M
}
1032
1033
StringLiteral::StringLiteral(const ASTContext &Ctx, StringRef Str,
1034
                             StringKind Kind, bool Pascal, QualType Ty,
1035
                             const SourceLocation *Loc,
1036
                             unsigned NumConcatenated)
1037
    : Expr(StringLiteralClass, Ty, VK_LValue, OK_Ordinary, false, false, false,
1038
3.24M
           false) {
1039
3.24M
  assert(Ctx.getAsConstantArrayType(Ty) &&
1040
3.24M
         "StringLiteral must be of constant array type!");
1041
3.24M
  unsigned CharByteWidth = mapCharByteWidth(Ctx.getTargetInfo(), Kind);
1042
3.24M
  unsigned ByteLength = Str.size();
1043
3.24M
  assert((ByteLength % CharByteWidth == 0) &&
1044
3.24M
         "The size of the data must be a multiple of CharByteWidth!");
1045
3.24M
1046
3.24M
  // Avoid the expensive division. The compiler should be able to figure it
1047
3.24M
  // out by itself. However as of clang 7, even with the appropriate
1048
3.24M
  // llvm_unreachable added just here, it is not able to do so.
1049
3.24M
  unsigned Length;
1050
3.24M
  switch (CharByteWidth) {
1051
3.23M
  case 1:
1052
3.23M
    Length = ByteLength;
1053
3.23M
    break;
1054
404
  case 2:
1055
404
    Length = ByteLength / 2;
1056
404
    break;
1057
857
  case 4:
1058
857
    Length = ByteLength / 4;
1059
857
    break;
1060
0
  default:
1061
0
    llvm_unreachable("Unsupported character width!");
1062
3.24M
  }
1063
3.24M
1064
3.24M
  StringLiteralBits.Kind = Kind;
1065
3.24M
  StringLiteralBits.CharByteWidth = CharByteWidth;
1066
3.24M
  StringLiteralBits.IsPascal = Pascal;
1067
3.24M
  StringLiteralBits.NumConcatenated = NumConcatenated;
1068
3.24M
  *getTrailingObjects<unsigned>() = Length;
1069
3.24M
1070
3.24M
  // Initialize the trailing array of SourceLocation.
1071
3.24M
  // This is safe since SourceLocation is POD-like.
1072
3.24M
  std::memcpy(getTrailingObjects<SourceLocation>(), Loc,
1073
3.24M
              NumConcatenated * sizeof(SourceLocation));
1074
3.24M
1075
3.24M
  // Initialize the trailing array of char holding the string data.
1076
3.24M
  std::memcpy(getTrailingObjects<char>(), Str.data(), ByteLength);
1077
3.24M
}
1078
1079
StringLiteral::StringLiteral(EmptyShell Empty, unsigned NumConcatenated,
1080
                             unsigned Length, unsigned CharByteWidth)
1081
2.62k
    : Expr(StringLiteralClass, Empty) {
1082
2.62k
  StringLiteralBits.CharByteWidth = CharByteWidth;
1083
2.62k
  StringLiteralBits.NumConcatenated = NumConcatenated;
1084
2.62k
  *getTrailingObjects<unsigned>() = Length;
1085
2.62k
}
1086
1087
StringLiteral *StringLiteral::Create(const ASTContext &Ctx, StringRef Str,
1088
                                     StringKind Kind, bool Pascal, QualType Ty,
1089
                                     const SourceLocation *Loc,
1090
3.24M
                                     unsigned NumConcatenated) {
1091
3.24M
  void *Mem = Ctx.Allocate(totalSizeToAlloc<unsigned, SourceLocation, char>(
1092
3.24M
                               1, NumConcatenated, Str.size()),
1093
3.24M
                           alignof(StringLiteral));
1094
3.24M
  return new (Mem)
1095
3.24M
      StringLiteral(Ctx, Str, Kind, Pascal, Ty, Loc, NumConcatenated);
1096
3.24M
}
1097
1098
StringLiteral *StringLiteral::CreateEmpty(const ASTContext &Ctx,
1099
                                          unsigned NumConcatenated,
1100
                                          unsigned Length,
1101
2.62k
                                          unsigned CharByteWidth) {
1102
2.62k
  void *Mem = Ctx.Allocate(totalSizeToAlloc<unsigned, SourceLocation, char>(
1103
2.62k
                               1, NumConcatenated, Length * CharByteWidth),
1104
2.62k
                           alignof(StringLiteral));
1105
2.62k
  return new (Mem)
1106
2.62k
      StringLiteral(EmptyShell(), NumConcatenated, Length, CharByteWidth);
1107
2.62k
}
1108
1109
952
void StringLiteral::outputString(raw_ostream &OS) const {
1110
952
  switch (getKind()) {
1111
921
  case Ascii: break; // no prefix.
1112
16
  case Wide:  OS << 'L'; break;
1113
6
  case UTF8:  OS << "u8"; break;
1114
5
  case UTF16: OS << 'u'; break;
1115
4
  case UTF32: OS << 'U'; break;
1116
952
  }
1117
952
  OS << '"';
1118
952
  static const char Hex[] = "0123456789ABCDEF";
1119
952
1120
952
  unsigned LastSlashX = getLength();
1121
9.01k
  for (unsigned I = 0, N = getLength(); I != N; 
++I8.06k
) {
1122
8.06k
    switch (uint32_t Char = getCodeUnit(I)) {
1123
8.01k
    default:
1124
8.01k
      // FIXME: Convert UTF-8 back to codepoints before rendering.
1125
8.01k
1126
8.01k
      // Convert UTF-16 surrogate pairs back to codepoints before rendering.
1127
8.01k
      // Leave invalid surrogates alone; we'll use \x for those.
1128
8.01k
      if (getKind() == UTF16 && 
I != N - 117
&&
Char >= 0xd80013
&&
1129
8.01k
          
Char <= 0xdbff1
) {
1130
1
        uint32_t Trail = getCodeUnit(I + 1);
1131
1
        if (Trail >= 0xdc00 && Trail <= 0xdfff) {
1132
1
          Char = 0x10000 + ((Char - 0xd800) << 10) + (Trail - 0xdc00);
1133
1
          ++I;
1134
1
        }
1135
1
      }
1136
8.01k
1137
8.01k
      if (Char > 0xff) {
1138
16
        // If this is a wide string, output characters over 0xff using \x
1139
16
        // escapes. Otherwise, this is a UTF-16 or UTF-32 string, and Char is a
1140
16
        // codepoint: use \x escapes for invalid codepoints.
1141
16
        if (getKind() == Wide ||
1142
16
            
(7
Char >= 0xd8007
&&
Char <= 0xdfff3
) ||
Char >= 0x1100007
) {
1143
9
          // FIXME: Is this the best way to print wchar_t?
1144
9
          OS << "\\x";
1145
9
          int Shift = 28;
1146
34
          while ((Char >> Shift) == 0)
1147
25
            Shift -= 4;
1148
56
          for (/**/; Shift >= 0; 
Shift -= 447
)
1149
47
            OS << Hex[(Char >> Shift) & 15];
1150
9
          LastSlashX = I;
1151
9
          break;
1152
9
        }
1153
7
1154
7
        if (Char > 0xffff)
1155
3
          OS << "\\U00"
1156
3
             << Hex[(Char >> 20) & 15]
1157
3
             << Hex[(Char >> 16) & 15];
1158
4
        else
1159
4
          OS << "\\u";
1160
7
        OS << Hex[(Char >> 12) & 15]
1161
7
           << Hex[(Char >>  8) & 15]
1162
7
           << Hex[(Char >>  4) & 15]
1163
7
           << Hex[(Char >>  0) & 15];
1164
7
        break;
1165
7
      }
1166
8.00k
1167
8.00k
      // If we used \x... for the previous character, and this character is a
1168
8.00k
      // hexadecimal digit, prevent it being slurped as part of the \x.
1169
8.00k
      if (LastSlashX + 1 == I) {
1170
3
        switch (Char) {
1171
2
          case '0': case '1': case '2': case '3': case '4':
1172
2
          case '5': case '6': case '7': case '8': case '9':
1173
2
          case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
1174
2
          case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
1175
2
            OS << "\"\"";
1176
3
        }
1177
3
      }
1178
8.00k
1179
8.00k
      assert(Char <= 0xff &&
1180
8.00k
             "Characters above 0xff should already have been handled.");
1181
8.00k
1182
8.00k
      if (isPrintable(Char))
1183
7.98k
        OS << (char)Char;
1184
21
      else  // Output anything hard as an octal escape.
1185
21
        OS << '\\'
1186
21
           << (char)('0' + ((Char >> 6) & 7))
1187
21
           << (char)('0' + ((Char >> 3) & 7))
1188
21
           << (char)('0' + ((Char >> 0) & 7));
1189
8.00k
      break;
1190
8.00k
    // Handle some common non-printable cases to make dumps prettier.
1191
8.00k
    
case '\\': OS << "\\\\"; break9
;
1192
8.00k
    
case '"': OS << "\\\""; break10
;
1193
8.00k
    
case '\a': OS << "\\a"; break9
;
1194
8.00k
    
case '\b': OS << "\\b"; break9
;
1195
8.00k
    
case '\f': OS << "\\f"; break1
;
1196
8.00k
    
case '\n': OS << "\\n"; break1
;
1197
8.00k
    
case '\r': OS << "\\r"; break1
;
1198
8.00k
    
case '\t': OS << "\\t"; break9
;
1199
8.00k
    
case '\v': OS << "\\v"; break1
;
1200
8.06k
    }
1201
8.06k
  }
1202
952
  OS << '"';
1203
952
}
1204
1205
/// getLocationOfByte - Return a source location that points to the specified
1206
/// byte of this string literal.
1207
///
1208
/// Strings are amazingly complex.  They can be formed from multiple tokens and
1209
/// can have escape sequences in them in addition to the usual trigraph and
1210
/// escaped newline business.  This routine handles this complexity.
1211
///
1212
/// The *StartToken sets the first token to be searched in this function and
1213
/// the *StartTokenByteOffset is the byte offset of the first token. Before
1214
/// returning, it updates the *StartToken to the TokNo of the token being found
1215
/// and sets *StartTokenByteOffset to the byte offset of the token in the
1216
/// string.
1217
/// Using these two parameters can reduce the time complexity from O(n^2) to
1218
/// O(n) if one wants to get the location of byte for all the tokens in a
1219
/// string.
1220
///
1221
SourceLocation
1222
StringLiteral::getLocationOfByte(unsigned ByteNo, const SourceManager &SM,
1223
                                 const LangOptions &Features,
1224
                                 const TargetInfo &Target, unsigned *StartToken,
1225
25.3k
                                 unsigned *StartTokenByteOffset) const {
1226
25.3k
  assert((getKind() == StringLiteral::Ascii ||
1227
25.3k
          getKind() == StringLiteral::UTF8) &&
1228
25.3k
         "Only narrow string literals are currently supported");
1229
25.3k
1230
25.3k
  // Loop over all of the tokens in this string until we find the one that
1231
25.3k
  // contains the byte we're looking for.
1232
25.3k
  unsigned TokNo = 0;
1233
25.3k
  unsigned StringOffset = 0;
1234
25.3k
  if (StartToken)
1235
12.8k
    TokNo = *StartToken;
1236
25.3k
  if (StartTokenByteOffset) {
1237
12.8k
    StringOffset = *StartTokenByteOffset;
1238
12.8k
    ByteNo -= StringOffset;
1239
12.8k
  }
1240
26.2k
  while (1) {
1241
26.2k
    assert(TokNo < getNumConcatenated() && "Invalid byte number!");
1242
26.2k
    SourceLocation StrTokLoc = getStrTokenLoc(TokNo);
1243
26.2k
1244
26.2k
    // Get the spelling of the string so that we can get the data that makes up
1245
26.2k
    // the string literal, not the identifier for the macro it is potentially
1246
26.2k
    // expanded through.
1247
26.2k
    SourceLocation StrTokSpellingLoc = SM.getSpellingLoc(StrTokLoc);
1248
26.2k
1249
26.2k
    // Re-lex the token to get its length and original spelling.
1250
26.2k
    std::pair<FileID, unsigned> LocInfo =
1251
26.2k
        SM.getDecomposedLoc(StrTokSpellingLoc);
1252
26.2k
    bool Invalid = false;
1253
26.2k
    StringRef Buffer = SM.getBufferData(LocInfo.first, &Invalid);
1254
26.2k
    if (Invalid) {
1255
0
      if (StartTokenByteOffset != nullptr)
1256
0
        *StartTokenByteOffset = StringOffset;
1257
0
      if (StartToken != nullptr)
1258
0
        *StartToken = TokNo;
1259
0
      return StrTokSpellingLoc;
1260
0
    }
1261
26.2k
1262
26.2k
    const char *StrData = Buffer.data()+LocInfo.second;
1263
26.2k
1264
26.2k
    // Create a lexer starting at the beginning of this token.
1265
26.2k
    Lexer TheLexer(SM.getLocForStartOfFile(LocInfo.first), Features,
1266
26.2k
                   Buffer.begin(), StrData, Buffer.end());
1267
26.2k
    Token TheTok;
1268
26.2k
    TheLexer.LexFromRawLexer(TheTok);
1269
26.2k
1270
26.2k
    // Use the StringLiteralParser to compute the length of the string in bytes.
1271
26.2k
    StringLiteralParser SLP(TheTok, SM, Features, Target);
1272
26.2k
    unsigned TokNumBytes = SLP.GetStringLength();
1273
26.2k
1274
26.2k
    // If the byte is in this token, return the location of the byte.
1275
26.2k
    if (ByteNo < TokNumBytes ||
1276
26.2k
        
(2.77k
ByteNo == TokNumBytes2.77k
&&
TokNo == getNumConcatenated() - 11.83k
)) {
1277
25.3k
      unsigned Offset = SLP.getOffsetOfStringByte(TheTok, ByteNo);
1278
25.3k
1279
25.3k
      // Now that we know the offset of the token in the spelling, use the
1280
25.3k
      // preprocessor to get the offset in the original source.
1281
25.3k
      if (StartTokenByteOffset != nullptr)
1282
12.8k
        *StartTokenByteOffset = StringOffset;
1283
25.3k
      if (StartToken != nullptr)
1284
12.8k
        *StartToken = TokNo;
1285
25.3k
      return Lexer::AdvanceToTokenCharacter(StrTokLoc, Offset, SM, Features);
1286
25.3k
    }
1287
974
1288
974
    // Move to the next string token.
1289
974
    StringOffset += TokNumBytes;
1290
974
    ++TokNo;
1291
974
    ByteNo -= TokNumBytes;
1292
974
  }
1293
25.3k
}
1294
1295
/// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
1296
/// corresponds to, e.g. "sizeof" or "[pre]++".
1297
26.3k
StringRef UnaryOperator::getOpcodeStr(Opcode Op) {
1298
26.3k
  switch (Op) {
1299
26.3k
#define UNARY_OPERATION(Name, Spelling) case UO_##Name: return Spelling;
1300
0
#include "clang/AST/OperationKinds.def"
1301
26.3k
  }
1302
26.3k
  
llvm_unreachable0
("Unknown unary operator");
1303
26.3k
}
1304
1305
UnaryOperatorKind
1306
5.11k
UnaryOperator::getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix) {
1307
5.11k
  switch (OO) {
1308
0
  default: llvm_unreachable("No unary operator for overloaded function");
1309
148
  case OO_PlusPlus:   return Postfix ? 
UO_PostInc1
:
UO_PreInc147
;
1310
0
  case OO_MinusMinus: return Postfix ? UO_PostDec : UO_PreDec;
1311
267
  case OO_Amp:        return UO_AddrOf;
1312
4.61k
  case OO_Star:       return UO_Deref;
1313
0
  case OO_Plus:       return UO_Plus;
1314
13
  case OO_Minus:      return UO_Minus;
1315
56
  case OO_Tilde:      return UO_Not;
1316
1
  case OO_Exclaim:    return UO_LNot;
1317
22
  case OO_Coawait:    return UO_Coawait;
1318
5.11k
  }
1319
5.11k
}
1320
1321
2.70M
OverloadedOperatorKind UnaryOperator::getOverloadedOperator(Opcode Opc) {
1322
2.70M
  switch (Opc) {
1323
461k
  case UO_PostInc: case UO_PreInc: return OO_PlusPlus;
1324
461k
  
case UO_PostDec: 132k
case UO_PreDec: return OO_MinusMinus132k
;
1325
223k
  case UO_AddrOf: return OO_Amp;
1326
1.12M
  case UO_Deref: return OO_Star;
1327
132k
  
case UO_Plus: return OO_Plus391
;
1328
132k
  
case UO_Minus: return OO_Minus16.6k
;
1329
132k
  
case UO_Not: return OO_Tilde82.5k
;
1330
659k
  case UO_LNot: return OO_Exclaim;
1331
132k
  
case UO_Coawait: return OO_Coawait851
;
1332
132k
  
default: return OO_None5
;
1333
2.70M
  }
1334
2.70M
}
1335
1336
1337
//===----------------------------------------------------------------------===//
1338
// Postfix Operators.
1339
//===----------------------------------------------------------------------===//
1340
1341
CallExpr::CallExpr(StmtClass SC, Expr *Fn, ArrayRef<Expr *> PreArgs,
1342
                   ArrayRef<Expr *> Args, QualType Ty, ExprValueKind VK,
1343
                   SourceLocation RParenLoc, unsigned MinNumArgs,
1344
                   ADLCallKind UsesADL)
1345
    : Expr(SC, Ty, VK, OK_Ordinary, Fn->isTypeDependent(),
1346
           Fn->isValueDependent(), Fn->isInstantiationDependent(),
1347
           Fn->containsUnexpandedParameterPack()),
1348
5.51M
      RParenLoc(RParenLoc) {
1349
5.51M
  NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1350
5.51M
  unsigned NumPreArgs = PreArgs.size();
1351
5.51M
  CallExprBits.NumPreArgs = NumPreArgs;
1352
5.51M
  assert((NumPreArgs == getNumPreArgs()) && "NumPreArgs overflow!");
1353
5.51M
1354
5.51M
  unsigned OffsetToTrailingObjects = offsetToTrailingObjects(SC);
1355
5.51M
  CallExprBits.OffsetToTrailingObjects = OffsetToTrailingObjects;
1356
5.51M
  assert((CallExprBits.OffsetToTrailingObjects == OffsetToTrailingObjects) &&
1357
5.51M
         "OffsetToTrailingObjects overflow!");
1358
5.51M
1359
5.51M
  CallExprBits.UsesADL = static_cast<bool>(UsesADL);
1360
5.51M
1361
5.51M
  setCallee(Fn);
1362
5.51M
  for (unsigned I = 0; I != NumPreArgs; 
++I50
) {
1363
50
    updateDependenciesFromArg(PreArgs[I]);
1364
50
    setPreArg(I, PreArgs[I]);
1365
50
  }
1366
14.6M
  for (unsigned I = 0; I != Args.size(); 
++I9.08M
) {
1367
9.08M
    updateDependenciesFromArg(Args[I]);
1368
9.08M
    setArg(I, Args[I]);
1369
9.08M
  }
1370
5.52M
  for (unsigned I = Args.size(); I != NumArgs; 
++I10.6k
) {
1371
10.6k
    setArg(I, nullptr);
1372
10.6k
  }
1373
5.51M
}
1374
1375
CallExpr::CallExpr(StmtClass SC, unsigned NumPreArgs, unsigned NumArgs,
1376
                   EmptyShell Empty)
1377
67.4k
    : Expr(SC, Empty), NumArgs(NumArgs) {
1378
67.4k
  CallExprBits.NumPreArgs = NumPreArgs;
1379
67.4k
  assert((NumPreArgs == getNumPreArgs()) && "NumPreArgs overflow!");
1380
67.4k
1381
67.4k
  unsigned OffsetToTrailingObjects = offsetToTrailingObjects(SC);
1382
67.4k
  CallExprBits.OffsetToTrailingObjects = OffsetToTrailingObjects;
1383
67.4k
  assert((CallExprBits.OffsetToTrailingObjects == OffsetToTrailingObjects) &&
1384
67.4k
         "OffsetToTrailingObjects overflow!");
1385
67.4k
}
1386
1387
CallExpr *CallExpr::Create(const ASTContext &Ctx, Expr *Fn,
1388
                           ArrayRef<Expr *> Args, QualType Ty, ExprValueKind VK,
1389
                           SourceLocation RParenLoc, unsigned MinNumArgs,
1390
4.25M
                           ADLCallKind UsesADL) {
1391
4.25M
  unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1392
4.25M
  unsigned SizeOfTrailingObjects =
1393
4.25M
      CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs);
1394
4.25M
  void *Mem =
1395
4.25M
      Ctx.Allocate(sizeof(CallExpr) + SizeOfTrailingObjects, alignof(CallExpr));
1396
4.25M
  return new (Mem) CallExpr(CallExprClass, Fn, /*PreArgs=*/{}, Args, Ty, VK,
1397
4.25M
                            RParenLoc, MinNumArgs, UsesADL);
1398
4.25M
}
1399
1400
CallExpr *CallExpr::CreateTemporary(void *Mem, Expr *Fn, QualType Ty,
1401
                                    ExprValueKind VK, SourceLocation RParenLoc,
1402
348k
                                    ADLCallKind UsesADL) {
1403
348k
  assert(!(reinterpret_cast<uintptr_t>(Mem) % alignof(CallExpr)) &&
1404
348k
         "Misaligned memory in CallExpr::CreateTemporary!");
1405
348k
  return new (Mem) CallExpr(CallExprClass, Fn, /*PreArgs=*/{}, /*Args=*/{}, Ty,
1406
348k
                            VK, RParenLoc, /*MinNumArgs=*/0, UsesADL);
1407
348k
}
1408
1409
CallExpr *CallExpr::CreateEmpty(const ASTContext &Ctx, unsigned NumArgs,
1410
50.6k
                                EmptyShell Empty) {
1411
50.6k
  unsigned SizeOfTrailingObjects =
1412
50.6k
      CallExpr::sizeOfTrailingObjects(/*NumPreArgs=*/0, NumArgs);
1413
50.6k
  void *Mem =
1414
50.6k
      Ctx.Allocate(sizeof(CallExpr) + SizeOfTrailingObjects, alignof(CallExpr));
1415
50.6k
  return new (Mem) CallExpr(CallExprClass, /*NumPreArgs=*/0, NumArgs, Empty);
1416
50.6k
}
1417
1418
5.58M
unsigned CallExpr::offsetToTrailingObjects(StmtClass SC) {
1419
5.58M
  switch (SC) {
1420
4.65M
  case CallExprClass:
1421
4.65M
    return sizeof(CallExpr);
1422
758k
  case CXXOperatorCallExprClass:
1423
758k
    return sizeof(CXXOperatorCallExpr);
1424
174k
  case CXXMemberCallExprClass:
1425
174k
    return sizeof(CXXMemberCallExpr);
1426
190
  case UserDefinedLiteralClass:
1427
190
    return sizeof(UserDefinedLiteral);
1428
51
  case CUDAKernelCallExprClass:
1429
51
    return sizeof(CUDAKernelCallExpr);
1430
0
  default:
1431
0
    llvm_unreachable("unexpected class deriving from CallExpr!");
1432
5.58M
  }
1433
5.58M
}
1434
1435
9.08M
void CallExpr::updateDependenciesFromArg(Expr *Arg) {
1436
9.08M
  if (Arg->isTypeDependent())
1437
2.61M
    ExprBits.TypeDependent = true;
1438
9.08M
  if (Arg->isValueDependent())
1439
2.71M
    ExprBits.ValueDependent = true;
1440
9.08M
  if (Arg->isInstantiationDependent())
1441
2.71M
    ExprBits.InstantiationDependent = true;
1442
9.08M
  if (Arg->containsUnexpandedParameterPack())
1443
39.3k
    ExprBits.ContainsUnexpandedParameterPack = true;
1444
9.08M
}
1445
1446
10.4M
Decl *Expr::getReferencedDeclOfCallee() {
1447
10.4M
  Expr *CEE = IgnoreParenImpCasts();
1448
10.4M
1449
10.4M
  while (SubstNonTypeTemplateParmExpr *NTTP =
1450
0
             dyn_cast<SubstNonTypeTemplateParmExpr>(CEE)) {
1451
0
    CEE = NTTP->getReplacement()->IgnoreParenImpCasts();
1452
0
  }
1453
10.4M
1454
10.4M
  // If we're calling a dereference, look at the pointer instead.
1455
10.5M
  while (true) {
1456
10.5M
    if (BinaryOperator *BO = dyn_cast<BinaryOperator>(CEE)) {
1457
1.39k
      if (BO->isPtrMemOp()) {
1458
1.38k
        CEE = BO->getRHS()->IgnoreParenImpCasts();
1459
1.38k
        continue;
1460
1.38k
      }
1461
10.5M
    } else if (UnaryOperator *UO = dyn_cast<UnaryOperator>(CEE)) {
1462
15.8k
      if (UO->getOpcode() == UO_Deref || 
UO->getOpcode() == UO_AddrOf313
||
1463
15.8k
          
UO->getOpcode() == UO_Plus4
) {
1464
15.8k
        CEE = UO->getSubExpr()->IgnoreParenImpCasts();
1465
15.8k
        continue;
1466
15.8k
      }
1467
10.4M
    }
1468
10.4M
    break;
1469
10.4M
  }
1470
10.4M
1471
10.4M
  if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE))
1472
9.21M
    return DRE->getDecl();
1473
1.26M
  if (MemberExpr *ME = dyn_cast<MemberExpr>(CEE))
1474
1.21M
    return ME->getMemberDecl();
1475
50.3k
  if (auto *BE = dyn_cast<BlockExpr>(CEE))
1476
1.86k
    return BE->getBlockDecl();
1477
48.4k
1478
48.4k
  return nullptr;
1479
48.4k
}
1480
1481
/// If this is a call to a builtin, return the builtin ID. If not, return 0.
1482
2.99M
unsigned CallExpr::getBuiltinCallee() const {
1483
2.99M
  auto *FDecl =
1484
2.99M
      dyn_cast_or_null<FunctionDecl>(getCallee()->getReferencedDeclOfCallee());
1485
2.99M
  return FDecl ? 
FDecl->getBuiltinID()2.96M
:
030.8k
;
1486
2.99M
}
1487
1488
2.61M
bool CallExpr::isUnevaluatedBuiltinCall(const ASTContext &Ctx) const {
1489
2.61M
  if (unsigned BI = getBuiltinCallee())
1490
1.07M
    return Ctx.BuiltinInfo.isUnevaluated(BI);
1491
1.54M
  return false;
1492
1.54M
}
1493
1494
1.14M
QualType CallExpr::getCallReturnType(const ASTContext &Ctx) const {
1495
1.14M
  const Expr *Callee = getCallee();
1496
1.14M
  QualType CalleeType = Callee->getType();
1497
1.14M
  if (const auto *FnTypePtr = CalleeType->getAs<PointerType>()) {
1498
942k
    CalleeType = FnTypePtr->getPointeeType();
1499
942k
  } else 
if (const auto *205k
BPT205k
= CalleeType->getAs<BlockPointerType>()) {
1500
1.42k
    CalleeType = BPT->getPointeeType();
1501
204k
  } else if (CalleeType->isSpecificPlaceholderType(BuiltinType::BoundMember)) {
1502
203k
    if (isa<CXXPseudoDestructorExpr>(Callee->IgnoreParens()))
1503
164
      return Ctx.VoidTy;
1504
203k
1505
203k
    // This should never be overloaded and so should never return null.
1506
203k
    CalleeType = Expr::findBoundMemberType(Callee);
1507
203k
  }
1508
1.14M
1509
1.14M
  const FunctionType *FnType = CalleeType->castAs<FunctionType>();
1510
1.14M
  return FnType->getReturnType();
1511
1.14M
}
1512
1513
367k
const Attr *CallExpr::getUnusedResultAttr(const ASTContext &Ctx) const {
1514
367k
  // If the return type is a struct, union, or enum that is marked nodiscard,
1515
367k
  // then return the return type attribute.
1516
367k
  if (const TagDecl *TD = getCallReturnType(Ctx)->getAsTagDecl())
1517
6.99k
    if (const auto *A = TD->getAttr<WarnUnusedResultAttr>())
1518
92
      return A;
1519
367k
1520
367k
  // Otherwise, see if the callee is marked nodiscard and return that attribute
1521
367k
  // instead.
1522
367k
  const Decl *D = getCalleeDecl();
1523
367k
  return D ? D->getAttr<WarnUnusedResultAttr>() : 
nullptr0
;
1524
367k
}
1525
1526
17.2M
SourceLocation CallExpr::getBeginLoc() const {
1527
17.2M
  if (isa<CXXOperatorCallExpr>(this))
1528
35
    return cast<CXXOperatorCallExpr>(this)->getBeginLoc();
1529
17.2M
1530
17.2M
  SourceLocation begin = getCallee()->getBeginLoc();
1531
17.2M
  if (begin.isInvalid() && 
getNumArgs() > 01.14k
&&
getArg(0)804
)
1532
804
    begin = getArg(0)->getBeginLoc();
1533
17.2M
  return begin;
1534
17.2M
}
1535
2.05M
SourceLocation CallExpr::getEndLoc() const {
1536
2.05M
  if (isa<CXXOperatorCallExpr>(this))
1537
0
    return cast<CXXOperatorCallExpr>(this)->getEndLoc();
1538
2.05M
1539
2.05M
  SourceLocation end = getRParenLoc();
1540
2.05M
  if (end.isInvalid() && 
getNumArgs() > 00
&&
getArg(getNumArgs() - 1)0
)
1541
0
    end = getArg(getNumArgs() - 1)->getEndLoc();
1542
2.05M
  return end;
1543
2.05M
}
1544
1545
OffsetOfExpr *OffsetOfExpr::Create(const ASTContext &C, QualType type,
1546
                                   SourceLocation OperatorLoc,
1547
                                   TypeSourceInfo *tsi,
1548
                                   ArrayRef<OffsetOfNode> comps,
1549
                                   ArrayRef<Expr*> exprs,
1550
303
                                   SourceLocation RParenLoc) {
1551
303
  void *Mem = C.Allocate(
1552
303
      totalSizeToAlloc<OffsetOfNode, Expr *>(comps.size(), exprs.size()));
1553
303
1554
303
  return new (Mem) OffsetOfExpr(C, type, OperatorLoc, tsi, comps, exprs,
1555
303
                                RParenLoc);
1556
303
}
1557
1558
OffsetOfExpr *OffsetOfExpr::CreateEmpty(const ASTContext &C,
1559
3
                                        unsigned numComps, unsigned numExprs) {
1560
3
  void *Mem =
1561
3
      C.Allocate(totalSizeToAlloc<OffsetOfNode, Expr *>(numComps, numExprs));
1562
3
  return new (Mem) OffsetOfExpr(numComps, numExprs);
1563
3
}
1564
1565
OffsetOfExpr::OffsetOfExpr(const ASTContext &C, QualType type,
1566
                           SourceLocation OperatorLoc, TypeSourceInfo *tsi,
1567
                           ArrayRef<OffsetOfNode> comps, ArrayRef<Expr*> exprs,
1568
                           SourceLocation RParenLoc)
1569
  : Expr(OffsetOfExprClass, type, VK_RValue, OK_Ordinary,
1570
         /*TypeDependent=*/false,
1571
         /*ValueDependent=*/tsi->getType()->isDependentType(),
1572
         tsi->getType()->isInstantiationDependentType(),
1573
         tsi->getType()->containsUnexpandedParameterPack()),
1574
    OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi),
1575
    NumComps(comps.size()), NumExprs(exprs.size())
1576
303
{
1577
690
  for (unsigned i = 0; i != comps.size(); 
++i387
) {
1578
387
    setComponent(i, comps[i]);
1579
387
  }
1580
303
1581
346
  for (unsigned i = 0; i != exprs.size(); 
++i43
) {
1582
43
    if (exprs[i]->isTypeDependent() || exprs[i]->isValueDependent())
1583
9
      ExprBits.ValueDependent = true;
1584
43
    if (exprs[i]->containsUnexpandedParameterPack())
1585
1
      ExprBits.ContainsUnexpandedParameterPack = true;
1586
43
1587
43
    setIndexExpr(i, exprs[i]);
1588
43
  }
1589
303
}
1590
1591
15
IdentifierInfo *OffsetOfNode::getFieldName() const {
1592
15
  assert(getKind() == Field || getKind() == Identifier);
1593
15
  if (getKind() == Field)
1594
2
    return getField()->getIdentifier();
1595
13
1596
13
  return reinterpret_cast<IdentifierInfo *> (Data & ~(uintptr_t)Mask);
1597
13
}
1598
1599
UnaryExprOrTypeTraitExpr::UnaryExprOrTypeTraitExpr(
1600
    UnaryExprOrTypeTrait ExprKind, Expr *E, QualType resultType,
1601
    SourceLocation op, SourceLocation rp)
1602
    : Expr(UnaryExprOrTypeTraitExprClass, resultType, VK_RValue, OK_Ordinary,
1603
           false, // Never type-dependent (C++ [temp.dep.expr]p3).
1604
           // Value-dependent if the argument is type-dependent.
1605
           E->isTypeDependent(), E->isInstantiationDependent(),
1606
           E->containsUnexpandedParameterPack()),
1607
27.5k
      OpLoc(op), RParenLoc(rp) {
1608
27.5k
  UnaryExprOrTypeTraitExprBits.Kind = ExprKind;
1609
27.5k
  UnaryExprOrTypeTraitExprBits.IsType = false;
1610
27.5k
  Argument.Ex = E;
1611
27.5k
1612
27.5k
  // Check to see if we are in the situation where alignof(decl) should be
1613
27.5k
  // dependent because decl's alignment is dependent.
1614
27.5k
  if (ExprKind == UETT_AlignOf || 
ExprKind == UETT_PreferredAlignOf27.5k
) {
1615
139
    if (!isValueDependent() || 
!isInstantiationDependent()7
) {
1616
132
      E = E->IgnoreParens();
1617
132
1618
132
      const ValueDecl *D = nullptr;
1619
132
      if (const auto *DRE = dyn_cast<DeclRefExpr>(E))
1620
82
        D = DRE->getDecl();
1621
50
      else if (const auto *ME = dyn_cast<MemberExpr>(E))
1622
26
        D = ME->getMemberDecl();
1623
132
1624
132
      if (D) {
1625
108
        for (const auto *I : D->specific_attrs<AlignedAttr>()) {
1626
32
          if (I->isAlignmentDependent()) {
1627
1
            setValueDependent(true);
1628
1
            setInstantiationDependent(true);
1629
1
            break;
1630
1
          }
1631
32
        }
1632
108
      }
1633
132
    }
1634
139
  }
1635
27.5k
}
1636
1637
MemberExpr::MemberExpr(Expr *Base, bool IsArrow, SourceLocation OperatorLoc,
1638
                       ValueDecl *MemberDecl,
1639
                       const DeclarationNameInfo &NameInfo, QualType T,
1640
                       ExprValueKind VK, ExprObjectKind OK,
1641
                       NonOdrUseReason NOUR)
1642
    : Expr(MemberExprClass, T, VK, OK, Base->isTypeDependent(),
1643
           Base->isValueDependent(), Base->isInstantiationDependent(),
1644
           Base->containsUnexpandedParameterPack()),
1645
      Base(Base), MemberDecl(MemberDecl), MemberDNLoc(NameInfo.getInfo()),
1646
1.09M
      MemberLoc(NameInfo.getLoc()) {
1647
1.09M
  assert(!NameInfo.getName() ||
1648
1.09M
         MemberDecl->getDeclName() == NameInfo.getName());
1649
1.09M
  MemberExprBits.IsArrow = IsArrow;
1650
1.09M
  MemberExprBits.HasQualifierOrFoundDecl = false;
1651
1.09M
  MemberExprBits.HasTemplateKWAndArgsInfo = false;
1652
1.09M
  MemberExprBits.HadMultipleCandidates = false;
1653
1.09M
  MemberExprBits.NonOdrUseReason = NOUR;
1654
1.09M
  MemberExprBits.OperatorLoc = OperatorLoc;
1655
1.09M
}
1656
1657
MemberExpr *MemberExpr::Create(
1658
    const ASTContext &C, Expr *Base, bool IsArrow, SourceLocation OperatorLoc,
1659
    NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
1660
    ValueDecl *MemberDecl, DeclAccessPair FoundDecl,
1661
    DeclarationNameInfo NameInfo, const TemplateArgumentListInfo *TemplateArgs,
1662
1.09M
    QualType T, ExprValueKind VK, ExprObjectKind OK, NonOdrUseReason NOUR) {
1663
1.09M
  bool HasQualOrFound = QualifierLoc || 
FoundDecl.getDecl() != MemberDecl1.08M
||
1664
1.09M
                        
FoundDecl.getAccess() != MemberDecl->getAccess()1.07M
;
1665
1.09M
  bool HasTemplateKWAndArgsInfo = TemplateArgs || 
TemplateKWLoc.isValid()1.08M
;
1666
1.09M
  std::size_t Size =
1667
1.09M
      totalSizeToAlloc<MemberExprNameQualifier, ASTTemplateKWAndArgsInfo,
1668
1.09M
                       TemplateArgumentLoc>(
1669
1.09M
          HasQualOrFound ? 
135.5k
:
01.05M
, HasTemplateKWAndArgsInfo ?
11.82k
:
01.08M
,
1670
1.09M
          TemplateArgs ? 
TemplateArgs->size()1.76k
:
01.08M
);
1671
1.09M
1672
1.09M
  void *Mem = C.Allocate(Size, alignof(MemberExpr));
1673
1.09M
  MemberExpr *E = new (Mem) MemberExpr(Base, IsArrow, OperatorLoc, MemberDecl,
1674
1.09M
                                       NameInfo, T, VK, OK, NOUR);
1675
1.09M
1676
1.09M
  if (isa<FieldDecl>(MemberDecl)) {
1677
769k
    DeclContext *DC = MemberDecl->getDeclContext();
1678
769k
    // dyn_cast_or_null is used to handle objC variables which do not
1679
769k
    // have a declaration context.
1680
769k
    CXXRecordDecl *RD = dyn_cast_or_null<CXXRecordDecl>(DC);
1681
769k
    if (RD && 
RD->isDependentContext()656k
&&
RD->isCurrentInstantiation(DC)342k
)
1682
342k
      E->setTypeDependent(T->isDependentType());
1683
769k
1684
769k
    // Bitfield with value-dependent width is type-dependent.
1685
769k
    FieldDecl *FD = dyn_cast<FieldDecl>(MemberDecl);
1686
769k
    if (FD && FD->isBitField() && 
FD->getBitWidth()->isValueDependent()3.42k
)
1687
2
      E->setTypeDependent(true);
1688
769k
  }
1689
1.09M
1690
1.09M
  if (HasQualOrFound) {
1691
35.5k
    // FIXME: Wrong. We should be looking at the member declaration we found.
1692
35.5k
    if (QualifierLoc && 
QualifierLoc.getNestedNameSpecifier()->isDependent()7.92k
) {
1693
2
      E->setValueDependent(true);
1694
2
      E->setTypeDependent(true);
1695
2
      E->setInstantiationDependent(true);
1696
2
    }
1697
35.5k
    else if (QualifierLoc &&
1698
35.5k
             
QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent()7.92k
)
1699
0
      E->setInstantiationDependent(true);
1700
35.5k
1701
35.5k
    E->MemberExprBits.HasQualifierOrFoundDecl = true;
1702
35.5k
1703
35.5k
    MemberExprNameQualifier *NQ =
1704
35.5k
        E->getTrailingObjects<MemberExprNameQualifier>();
1705
35.5k
    NQ->QualifierLoc = QualifierLoc;
1706
35.5k
    NQ->FoundDecl = FoundDecl;
1707
35.5k
  }
1708
1.09M
1709
1.09M
  E->MemberExprBits.HasTemplateKWAndArgsInfo =
1710
1.09M
      TemplateArgs || 
TemplateKWLoc.isValid()1.08M
;
1711
1.09M
1712
1.09M
  if (TemplateArgs) {
1713
1.76k
    bool Dependent = false;
1714
1.76k
    bool InstantiationDependent = false;
1715
1.76k
    bool ContainsUnexpandedParameterPack = false;
1716
1.76k
    E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1717
1.76k
        TemplateKWLoc, *TemplateArgs,
1718
1.76k
        E->getTrailingObjects<TemplateArgumentLoc>(), Dependent,
1719
1.76k
        InstantiationDependent, ContainsUnexpandedParameterPack);
1720
1.76k
    if (InstantiationDependent)
1721
0
      E->setInstantiationDependent(true);
1722
1.08M
  } else if (TemplateKWLoc.isValid()) {
1723
65
    E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1724
65
        TemplateKWLoc);
1725
65
  }
1726
1.09M
1727
1.09M
  return E;
1728
1.09M
}
1729
1730
MemberExpr *MemberExpr::CreateEmpty(const ASTContext &Context,
1731
                                    bool HasQualifier, bool HasFoundDecl,
1732
                                    bool HasTemplateKWAndArgsInfo,
1733
15.6k
                                    unsigned NumTemplateArgs) {
1734
15.6k
  assert((!NumTemplateArgs || HasTemplateKWAndArgsInfo) &&
1735
15.6k
         "template args but no template arg info?");
1736
15.6k
  bool HasQualOrFound = HasQualifier || 
HasFoundDecl15.4k
;
1737
15.6k
  std::size_t Size =
1738
15.6k
      totalSizeToAlloc<MemberExprNameQualifier, ASTTemplateKWAndArgsInfo,
1739
15.6k
                       TemplateArgumentLoc>(HasQualOrFound ? 
1482
:
015.1k
,
1740
15.6k
                                            HasTemplateKWAndArgsInfo ? 
18
:
015.6k
,
1741
15.6k
                                            NumTemplateArgs);
1742
15.6k
  void *Mem = Context.Allocate(Size, alignof(MemberExpr));
1743
15.6k
  return new (Mem) MemberExpr(EmptyShell());
1744
15.6k
}
1745
1746
4.42M
SourceLocation MemberExpr::getBeginLoc() const {
1747
4.42M
  if (isImplicitAccess()) {
1748
1.83M
    if (hasQualifier())
1749
37.0k
      return getQualifierLoc().getBeginLoc();
1750
1.80M
    return MemberLoc;
1751
1.80M
  }
1752
2.58M
1753
2.58M
  // FIXME: We don't want this to happen. Rather, we should be able to
1754
2.58M
  // detect all kinds of implicit accesses more cleanly.
1755
2.58M
  SourceLocation BaseStartLoc = getBase()->getBeginLoc();
1756
2.58M
  if (BaseStartLoc.isValid())
1757
2.58M
    return BaseStartLoc;
1758
986
  return MemberLoc;
1759
986
}
1760
558k
SourceLocation MemberExpr::getEndLoc() const {
1761
558k
  SourceLocation EndLoc = getMemberNameInfo().getEndLoc();
1762
558k
  if (hasExplicitTemplateArgs())
1763
1.73k
    EndLoc = getRAngleLoc();
1764
556k
  else if (EndLoc.isInvalid())
1765
6.71k
    EndLoc = getBase()->getEndLoc();
1766
558k
  return EndLoc;
1767
558k
}
1768
1769
20.3M
bool CastExpr::CastConsistency() const {
1770
20.3M
  switch (getCastKind()) {
1771
44.1k
  case CK_DerivedToBase:
1772
44.1k
  case CK_UncheckedDerivedToBase:
1773
44.1k
  case CK_DerivedToBaseMemberPointer:
1774
44.1k
  case CK_BaseToDerived:
1775
44.1k
  case CK_BaseToDerivedMemberPointer:
1776
44.1k
    assert(!path_empty() && "Cast kind should have a base path!");
1777
44.1k
    break;
1778
44.1k
1779
44.1k
  case CK_CPointerToObjCPointerCast:
1780
4.31k
    assert(getType()->isObjCObjectPointerType());
1781
4.31k
    assert(getSubExpr()->getType()->isPointerType());
1782
4.31k
    goto CheckNoBasePath;
1783
44.1k
1784
44.1k
  case CK_BlockPointerToObjCPointerCast:
1785
66
    assert(getType()->isObjCObjectPointerType());
1786
66
    assert(getSubExpr()->getType()->isBlockPointerType());
1787
66
    goto CheckNoBasePath;
1788
44.1k
1789
44.1k
  case CK_ReinterpretMemberPointer:
1790
63
    assert(getType()->isMemberPointerType());
1791
63
    assert(getSubExpr()->getType()->isMemberPointerType());
1792
63
    goto CheckNoBasePath;
1793
44.1k
1794
3.39M
  case CK_BitCast:
1795
3.39M
    // Arbitrary casts to C pointer types count as bitcasts.
1796
3.39M
    // Otherwise, we should only have block and ObjC pointer casts
1797
3.39M
    // here if they stay within the type kind.
1798
3.39M
    if (!getType()->isPointerType()) {
1799
3.20M
      assert(getType()->isObjCObjectPointerType() ==
1800
3.20M
             getSubExpr()->getType()->isObjCObjectPointerType());
1801
3.20M
      assert(getType()->isBlockPointerType() ==
1802
3.20M
             getSubExpr()->getType()->isBlockPointerType());
1803
3.20M
    }
1804
3.39M
    goto CheckNoBasePath;
1805
44.1k
1806
44.1k
  case CK_AnyPointerToBlockPointerCast:
1807
50
    assert(getType()->isBlockPointerType());
1808
50
    assert(getSubExpr()->getType()->isAnyPointerType() &&
1809
50
           !getSubExpr()->getType()->isBlockPointerType());
1810
50
    goto CheckNoBasePath;
1811
44.1k
1812
44.1k
  case CK_CopyAndAutoreleaseBlockObject:
1813
12
    assert(getType()->isBlockPointerType());
1814
12
    assert(getSubExpr()->getType()->isBlockPointerType());
1815
12
    goto CheckNoBasePath;
1816
44.1k
1817
1.89M
  case CK_FunctionToPointerDecay:
1818
1.89M
    assert(getType()->isPointerType());
1819
1.89M
    assert(getSubExpr()->getType()->isFunctionType());
1820
1.89M
    goto CheckNoBasePath;
1821
44.1k
1822
44.1k
  case CK_AddressSpaceConversion: {
1823
630
    auto Ty = getType();
1824
630
    auto SETy = getSubExpr()->getType();
1825
630
    assert(getValueKindForType(Ty) == Expr::getValueKindForType(SETy));
1826
630
    if (isRValue()) {
1827
546
      Ty = Ty->getPointeeType();
1828
546
      SETy = SETy->getPointeeType();
1829
546
    }
1830
630
    assert(!Ty.isNull() && !SETy.isNull() &&
1831
630
           Ty.getAddressSpace() != SETy.getAddressSpace());
1832
630
    goto CheckNoBasePath;
1833
44.1k
  }
1834
44.1k
  // These should not have an inheritance path.
1835
3.06M
  case CK_Dynamic:
1836
3.06M
  case CK_ToUnion:
1837
3.06M
  case CK_ArrayToPointerDecay:
1838
3.06M
  case CK_NullToMemberPointer:
1839
3.06M
  case CK_NullToPointer:
1840
3.06M
  case CK_ConstructorConversion:
1841
3.06M
  case CK_IntegralToPointer:
1842
3.06M
  case CK_PointerToIntegral:
1843
3.06M
  case CK_ToVoid:
1844
3.06M
  case CK_VectorSplat:
1845
3.06M
  case CK_IntegralCast:
1846
3.06M
  case CK_BooleanToSignedIntegral:
1847
3.06M
  case CK_IntegralToFloating:
1848
3.06M
  case CK_FloatingToIntegral:
1849
3.06M
  case CK_FloatingCast:
1850
3.06M
  case CK_ObjCObjectLValueCast:
1851
3.06M
  case CK_FloatingRealToComplex:
1852
3.06M
  case CK_FloatingComplexToReal:
1853
3.06M
  case CK_FloatingComplexCast:
1854
3.06M
  case CK_FloatingComplexToIntegralComplex:
1855
3.06M
  case CK_IntegralRealToComplex:
1856
3.06M
  case CK_IntegralComplexToReal:
1857
3.06M
  case CK_IntegralComplexCast:
1858
3.06M
  case CK_IntegralComplexToFloatingComplex:
1859
3.06M
  case CK_ARCProduceObject:
1860
3.06M
  case CK_ARCConsumeObject:
1861
3.06M
  case CK_ARCReclaimReturnedObject:
1862
3.06M
  case CK_ARCExtendBlockObject:
1863
3.06M
  case CK_ZeroToOCLOpaqueType:
1864
3.06M
  case CK_IntToOCLSampler:
1865
3.06M
  case CK_FixedPointCast:
1866
3.06M
  case CK_FixedPointToIntegral:
1867
3.06M
  case CK_IntegralToFixedPoint:
1868
3.06M
    assert(!getType()->isBooleanType() && "unheralded conversion to bool");
1869
3.06M
    goto CheckNoBasePath;
1870
3.06M
1871
11.9M
  case CK_Dependent:
1872
11.9M
  case CK_LValueToRValue:
1873
11.9M
  case CK_NoOp:
1874
11.9M
  case CK_AtomicToNonAtomic:
1875
11.9M
  case CK_NonAtomicToAtomic:
1876
11.9M
  case CK_PointerToBoolean:
1877
11.9M
  case CK_IntegralToBoolean:
1878
11.9M
  case CK_FloatingToBoolean:
1879
11.9M
  case CK_MemberPointerToBoolean:
1880
11.9M
  case CK_FloatingComplexToBoolean:
1881
11.9M
  case CK_IntegralComplexToBoolean:
1882
11.9M
  case CK_LValueBitCast:            // -> bool&
1883
11.9M
  case CK_LValueToRValueBitCast:
1884
11.9M
  case CK_UserDefinedConversion:    // operator bool()
1885
11.9M
  case CK_BuiltinFnToFnPtr:
1886
11.9M
  case CK_FixedPointToBoolean:
1887
20.3M
  CheckNoBasePath:
1888
20.3M
    assert(path_empty() && "Cast kind should not have a base path!");
1889
20.3M
    break;
1890
20.3M
  }
1891
20.3M
  return true;
1892
20.3M
}
1893
1894
4.96k
const char *CastExpr::getCastKindName(CastKind CK) {
1895
4.96k
  switch (CK) {
1896
4.96k
#define CAST_OPERATION(Name) case CK_##Name: return #Name;
1897
0
#include "clang/AST/OperationKinds.def"
1898
4.96k
  }
1899
4.96k
  
llvm_unreachable0
("Unhandled cast kind!");
1900
4.96k
}
1901
1902
namespace {
1903
1.65M
  const Expr *skipImplicitTemporary(const Expr *E) {
1904
1.65M
    // Skip through reference binding to temporary.
1905
1.65M
    if (auto *Materialize = dyn_cast<MaterializeTemporaryExpr>(E))
1906
3.43k
      E = Materialize->getSubExpr();
1907
1.65M
1908
1.65M
    // Skip any temporary bindings; they're implicit.
1909
1.65M
    if (auto *Binder = dyn_cast<CXXBindTemporaryExpr>(E))
1910
14.1k
      E = Binder->getSubExpr();
1911
1.65M
1912
1.65M
    return E;
1913
1.65M
  }
1914
}
1915
1916
1.61M
Expr *CastExpr::getSubExprAsWritten() {
1917
1.61M
  const Expr *SubExpr = nullptr;
1918
1.61M
  const CastExpr *E = this;
1919
1.65M
  do {
1920
1.65M
    SubExpr = skipImplicitTemporary(E->getSubExpr());
1921
1.65M
1922
1.65M
    // Conversions by constructor and conversion functions have a
1923
1.65M
    // subexpression describing the call; strip it off.
1924
1.65M
    if (E->getCastKind() == CK_ConstructorConversion)
1925
2.02k
      SubExpr =
1926
2.02k
        skipImplicitTemporary(cast<CXXConstructExpr>(SubExpr)->getArg(0));
1927
1.65M
    else if (E->getCastKind() == CK_UserDefinedConversion) {
1928
587
      assert((isa<CXXMemberCallExpr>(SubExpr) ||
1929
587
              isa<BlockExpr>(SubExpr)) &&
1930
587
             "Unexpected SubExpr for CK_UserDefinedConversion.");
1931
587
      if (auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
1932
586
        SubExpr = MCE->getImplicitObjectArgument();
1933
587
    }
1934
1.65M
1935
1.65M
    // If the subexpression we're left with is an implicit cast, look
1936
1.65M
    // through that, too.
1937
1.65M
  } while ((E = dyn_cast<ImplicitCastExpr>(SubExpr)));
1938
1.61M
1939
1.61M
  return const_cast<Expr*>(SubExpr);
1940
1.61M
}
1941
1942
739
NamedDecl *CastExpr::getConversionFunction() const {
1943
739
  const Expr *SubExpr = nullptr;
1944
739
1945
1.51k
  for (const CastExpr *E = this; E; 
E = dyn_cast<ImplicitCastExpr>(SubExpr)771
) {
1946
836
    SubExpr = skipImplicitTemporary(E->getSubExpr());
1947
836
1948
836
    if (E->getCastKind() == CK_ConstructorConversion)
1949
0
      return cast<CXXConstructExpr>(SubExpr)->getConstructor();
1950
836
1951
836
    if (E->getCastKind() == CK_UserDefinedConversion) {
1952
65
      if (auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
1953
65
        return MCE->getMethodDecl();
1954
65
    }
1955
836
  }
1956
739
1957
739
  
return nullptr674
;
1958
739
}
1959
1960
2.70M
CXXBaseSpecifier **CastExpr::path_buffer() {
1961
2.70M
  switch (getStmtClass()) {
1962
0
#define ABSTRACT_STMT(x)
1963
0
#define CASTEXPR(Type, Base)                                                   \
1964
2.70M
  case Stmt::Type##Class:                                                      \
1965
2.70M
    return static_cast<Type *>(this)->getTrailingObjects<CXXBaseSpecifier *>();
1966
0
#define STMT(Type, Base)
1967
0
#include "clang/AST/StmtNodes.inc"
1968
0
  default:
1969
0
    llvm_unreachable("non-cast expressions not possible here");
1970
2.70M
  }
1971
2.70M
}
1972
1973
const FieldDecl *CastExpr::getTargetFieldForToUnionCast(QualType unionType,
1974
4
                                                        QualType opType) {
1975
4
  auto RD = unionType->castAs<RecordType>()->getDecl();
1976
4
  return getTargetFieldForToUnionCast(RD, opType);
1977
4
}
1978
1979
const FieldDecl *CastExpr::getTargetFieldForToUnionCast(const RecordDecl *RD,
1980
26
                                                        QualType OpType) {
1981
26
  auto &Ctx = RD->getASTContext();
1982
26
  RecordDecl::field_iterator Field, FieldEnd;
1983
26
  for (Field = RD->field_begin(), FieldEnd = RD->field_end();
1984
43
       Field != FieldEnd; 
++Field17
) {
1985
40
    if (Ctx.hasSameUnqualifiedType(Field->getType(), OpType) &&
1986
40
        
!Field->isUnnamedBitfield()24
) {
1987
23
      return *Field;
1988
23
    }
1989
40
  }
1990
26
  
return nullptr3
;
1991
26
}
1992
1993
ImplicitCastExpr *ImplicitCastExpr::Create(const ASTContext &C, QualType T,
1994
                                           CastKind Kind, Expr *Operand,
1995
                                           const CXXCastPath *BasePath,
1996
15.9M
                                           ExprValueKind VK) {
1997
15.9M
  unsigned PathSize = (BasePath ? 
BasePath->size()135k
:
015.7M
);
1998
15.9M
  void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1999
15.9M
  // Per C++ [conv.lval]p3, lvalue-to-rvalue conversions on class and
2000
15.9M
  // std::nullptr_t have special semantics not captured by CK_LValueToRValue.
2001
15.9M
  assert((Kind != CK_LValueToRValue ||
2002
15.9M
          !(T->isNullPtrType() || T->getAsCXXRecordDecl())) &&
2003
15.9M
         "invalid type for lvalue-to-rvalue conversion");
2004
15.9M
  ImplicitCastExpr *E =
2005
15.9M
    new (Buffer) ImplicitCastExpr(T, Kind, Operand, PathSize, VK);
2006
15.9M
  if (PathSize)
2007
43.1k
    std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
2008
43.1k
                              E->getTrailingObjects<CXXBaseSpecifier *>());
2009
15.9M
  return E;
2010
15.9M
}
2011
2012
ImplicitCastExpr *ImplicitCastExpr::CreateEmpty(const ASTContext &C,
2013
288k
                                                unsigned PathSize) {
2014
288k
  void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
2015
288k
  return new (Buffer) ImplicitCastExpr(EmptyShell(), PathSize);
2016
288k
}
2017
2018
2019
CStyleCastExpr *CStyleCastExpr::Create(const ASTContext &C, QualType T,
2020
                                       ExprValueKind VK, CastKind K, Expr *Op,
2021
                                       const CXXCastPath *BasePath,
2022
                                       TypeSourceInfo *WrittenTy,
2023
3.85M
                                       SourceLocation L, SourceLocation R) {
2024
3.85M
  unsigned PathSize = (BasePath ? 
BasePath->size()3.85M
:
01.79k
);
2025
3.85M
  void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
2026
3.85M
  CStyleCastExpr *E =
2027
3.85M
    new (Buffer) CStyleCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, R);
2028
3.85M
  if (PathSize)
2029
138
    std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
2030
138
                              E->getTrailingObjects<CXXBaseSpecifier *>());
2031
3.85M
  return E;
2032
3.85M
}
2033
2034
CStyleCastExpr *CStyleCastExpr::CreateEmpty(const ASTContext &C,
2035
4.74k
                                            unsigned PathSize) {
2036
4.74k
  void *Buffer = C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
2037
4.74k
  return new (Buffer) CStyleCastExpr(EmptyShell(), PathSize);
2038
4.74k
}
2039
2040
/// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
2041
/// corresponds to, e.g. "<<=".
2042
362k
StringRef BinaryOperator::getOpcodeStr(Opcode Op) {
2043
362k
  switch (Op) {
2044
362k
#define BINARY_OPERATION(Name, Spelling) case BO_##Name: return Spelling;
2045
0
#include "clang/AST/OperationKinds.def"
2046
362k
  }
2047
362k
  
llvm_unreachable0
("Invalid OpCode!");
2048
362k
}
2049
2050
BinaryOperatorKind
2051
62.6k
BinaryOperator::getOverloadedOpcode(OverloadedOperatorKind OO) {
2052
62.6k
  switch (OO) {
2053
0
  default: llvm_unreachable("Not an overloadable binary operator");
2054
10.1k
  case OO_Plus: return BO_Add;
2055
8.05k
  case OO_Minus: return BO_Sub;
2056
885
  case OO_Star: return BO_Mul;
2057
2.36k
  case OO_Slash: return BO_Div;
2058
2
  case OO_Percent: return BO_Rem;
2059
64
  case OO_Caret: return BO_Xor;
2060
142
  case OO_Amp: return BO_And;
2061
36
  case OO_Pipe: return BO_Or;
2062
126
  case OO_Equal: return BO_Assign;
2063
108
  case OO_Spaceship: return BO_Cmp;
2064
7.34k
  case OO_Less: return BO_LT;
2065
7.68k
  case OO_Greater: return BO_GT;
2066
44
  case OO_PlusEqual: return BO_AddAssign;
2067
0
  case OO_MinusEqual: return BO_SubAssign;
2068
0
  case OO_StarEqual: return BO_MulAssign;
2069
0
  case OO_SlashEqual: return BO_DivAssign;
2070
0
  case OO_PercentEqual: return BO_RemAssign;
2071
18
  case OO_CaretEqual: return BO_XorAssign;
2072
0
  case OO_AmpEqual: return BO_AndAssign;
2073
9
  case OO_PipeEqual: return BO_OrAssign;
2074
385
  case OO_LessLess: return BO_Shl;
2075
262
  case OO_GreaterGreater: return BO_Shr;
2076
0
  case OO_LessLessEqual: return BO_ShlAssign;
2077
0
  case OO_GreaterGreaterEqual: return BO_ShrAssign;
2078
14.5k
  case OO_EqualEqual: return BO_EQ;
2079
6.04k
  case OO_ExclaimEqual: return BO_NE;
2080
1.23k
  case OO_LessEqual: return BO_LE;
2081
2.29k
  case OO_GreaterEqual: return BO_GE;
2082
774
  case OO_AmpAmp: return BO_LAnd;
2083
4
  case OO_PipePipe: return BO_LOr;
2084
0
  case OO_Comma: return BO_Comma;
2085
1
  case OO_ArrowStar: return BO_PtrMemI;
2086
62.6k
  }
2087
62.6k
}
2088
2089
3.18M
OverloadedOperatorKind BinaryOperator::getOverloadedOperator(Opcode Opc) {
2090
3.18M
  static const OverloadedOperatorKind OverOps[] = {
2091
3.18M
    /* .* Cannot be overloaded */OO_None, OO_ArrowStar,
2092
3.18M
    OO_Star, OO_Slash, OO_Percent,
2093
3.18M
    OO_Plus, OO_Minus,
2094
3.18M
    OO_LessLess, OO_GreaterGreater,
2095
3.18M
    OO_Spaceship,
2096
3.18M
    OO_Less, OO_Greater, OO_LessEqual, OO_GreaterEqual,
2097
3.18M
    OO_EqualEqual, OO_ExclaimEqual,
2098
3.18M
    OO_Amp,
2099
3.18M
    OO_Caret,
2100
3.18M
    OO_Pipe,
2101
3.18M
    OO_AmpAmp,
2102
3.18M
    OO_PipePipe,
2103
3.18M
    OO_Equal, OO_StarEqual,
2104
3.18M
    OO_SlashEqual, OO_PercentEqual,
2105
3.18M
    OO_PlusEqual, OO_MinusEqual,
2106
3.18M
    OO_LessLessEqual, OO_GreaterGreaterEqual,
2107
3.18M
    OO_AmpEqual, OO_CaretEqual,
2108
3.18M
    OO_PipeEqual,
2109
3.18M
    OO_Comma
2110
3.18M
  };
2111
3.18M
  return OverOps[Opc];
2112
3.18M
}
2113
2114
bool BinaryOperator::isNullPointerArithmeticExtension(ASTContext &Ctx,
2115
                                                      Opcode Opc,
2116
13.2k
                                                      Expr *LHS, Expr *RHS) {
2117
13.2k
  if (Opc != BO_Add)
2118
929
    return false;
2119
12.3k
2120
12.3k
  // Check that we have one pointer and one integer operand.
2121
12.3k
  Expr *PExp;
2122
12.3k
  if (LHS->getType()->isPointerType()) {
2123
12.3k
    if (!RHS->getType()->isIntegerType())
2124
0
      return false;
2125
12.3k
    PExp = LHS;
2126
12.3k
  } else 
if (25
RHS->getType()->isPointerType()25
) {
2127
24
    if (!LHS->getType()->isIntegerType())
2128
0
      return false;
2129
24
    PExp = RHS;
2130
24
  } else {
2131
1
    return false;
2132
1
  }
2133
12.3k
2134
12.3k
  // Check that the pointer is a nullptr.
2135
12.3k
  if (!PExp->IgnoreParenCasts()
2136
12.3k
          ->isNullPointerConstant(Ctx, Expr::NPC_ValueDependentIsNotNull))
2137
11.0k
    return false;
2138
1.33k
2139
1.33k
  // Check that the pointee type is char-sized.
2140
1.33k
  const PointerType *PTy = PExp->getType()->getAs<PointerType>();
2141
1.33k
  if (!PTy || !PTy->getPointeeType()->isCharType())
2142
1.30k
    return false;
2143
34
2144
34
  return true;
2145
34
}
2146
2147
static QualType getDecayedSourceLocExprType(const ASTContext &Ctx,
2148
99
                                            SourceLocExpr::IdentKind Kind) {
2149
99
  switch (Kind) {
2150
36
  case SourceLocExpr::File:
2151
36
  case SourceLocExpr::Function: {
2152
36
    QualType ArrTy = Ctx.getStringLiteralArrayType(Ctx.CharTy, 0);
2153
36
    return Ctx.getPointerType(ArrTy->getAsArrayTypeUnsafe()->getElementType());
2154
36
  }
2155
63
  case SourceLocExpr::Line:
2156
63
  case SourceLocExpr::Column:
2157
63
    return Ctx.UnsignedIntTy;
2158
0
  }
2159
0
  llvm_unreachable("unhandled case");
2160
0
}
2161
2162
SourceLocExpr::SourceLocExpr(const ASTContext &Ctx, IdentKind Kind,
2163
                             SourceLocation BLoc, SourceLocation RParenLoc,
2164
                             DeclContext *ParentContext)
2165
    : Expr(SourceLocExprClass, getDecayedSourceLocExprType(Ctx, Kind),
2166
           VK_RValue, OK_Ordinary, false, false, false, false),
2167
99
      BuiltinLoc(BLoc), RParenLoc(RParenLoc), ParentContext(ParentContext) {
2168
99
  SourceLocExprBits.Kind = Kind;
2169
99
}
2170
2171
0
StringRef SourceLocExpr::getBuiltinStr() const {
2172
0
  switch (getIdentKind()) {
2173
0
  case File:
2174
0
    return "__builtin_FILE";
2175
0
  case Function:
2176
0
    return "__builtin_FUNCTION";
2177
0
  case Line:
2178
0
    return "__builtin_LINE";
2179
0
  case Column:
2180
0
    return "__builtin_COLUMN";
2181
0
  }
2182
0
  llvm_unreachable("unexpected IdentKind!");
2183
0
}
2184
2185
APValue SourceLocExpr::EvaluateInContext(const ASTContext &Ctx,
2186
612
                                         const Expr *DefaultExpr) const {
2187
612
  SourceLocation Loc;
2188
612
  const DeclContext *Context;
2189
612
2190
612
  std::tie(Loc,
2191
612
           Context) = [&]() -> std::pair<SourceLocation, const DeclContext *> {
2192
612
    if (auto *DIE = dyn_cast_or_null<CXXDefaultInitExpr>(DefaultExpr))
2193
184
      return {DIE->getUsedLocation(), DIE->getUsedContext()};
2194
428
    if (auto *DAE = dyn_cast_or_null<CXXDefaultArgExpr>(DefaultExpr))
2195
300
      return {DAE->getUsedLocation(), DAE->getUsedContext()};
2196
128
    return {this->getLocation(), this->getParentContext()};
2197
128
  }();
2198
612
2199
612
  PresumedLoc PLoc = Ctx.getSourceManager().getPresumedLoc(
2200
612
      Ctx.getSourceManager().getExpansionRange(Loc).getEnd());
2201
612
2202
612
  auto MakeStringLiteral = [&](StringRef Tmp) {
2203
264
    using LValuePathEntry = APValue::LValuePathEntry;
2204
264
    StringLiteral *Res = Ctx.getPredefinedStringLiteralFromCache(Tmp);
2205
264
    // Decay the string to a pointer to the first character.
2206
264
    LValuePathEntry Path[1] = {LValuePathEntry::ArrayIndex(0)};
2207
264
    return APValue(Res, CharUnits::Zero(), Path, /*OnePastTheEnd=*/false);
2208
264
  };
2209
612
2210
612
  switch (getIdentKind()) {
2211
126
  case SourceLocExpr::File:
2212
126
    return MakeStringLiteral(PLoc.getFilename());
2213
138
  case SourceLocExpr::Function: {
2214
138
    const Decl *CurDecl = dyn_cast_or_null<Decl>(Context);
2215
138
    return MakeStringLiteral(
2216
138
        CurDecl ? PredefinedExpr::ComputeName(PredefinedExpr::Function, CurDecl)
2217
138
                : 
std::string("")0
);
2218
0
  }
2219
348
  case SourceLocExpr::Line:
2220
348
  case SourceLocExpr::Column: {
2221
348
    llvm::APSInt IntVal(Ctx.getIntWidth(Ctx.UnsignedIntTy),
2222
348
                        /*isUnsigned=*/true);
2223
348
    IntVal = getIdentKind() == SourceLocExpr::Line ? 
PLoc.getLine()235
2224
348
                                                   : 
PLoc.getColumn()113
;
2225
348
    return APValue(IntVal);
2226
0
  }
2227
0
  }
2228
0
  llvm_unreachable("unhandled case");
2229
0
}
2230
2231
InitListExpr::InitListExpr(const ASTContext &C, SourceLocation lbraceloc,
2232
                           ArrayRef<Expr*> initExprs, SourceLocation rbraceloc)
2233
  : Expr(InitListExprClass, QualType(), VK_RValue, OK_Ordinary, false, false,
2234
         false, false),
2235
    InitExprs(C, initExprs.size()),
2236
    LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), AltForm(nullptr, true)
2237
227k
{
2238
227k
  sawArrayRangeDesignator(false);
2239
684k
  for (unsigned I = 0; I != initExprs.size(); 
++I457k
) {
2240
457k
    if (initExprs[I]->isTypeDependent())
2241
3.38k
      ExprBits.TypeDependent = true;
2242
457k
    if (initExprs[I]->isValueDependent())
2243
4.11k
      ExprBits.ValueDependent = true;
2244
457k
    if (initExprs[I]->isInstantiationDependent())
2245
4.11k
      ExprBits.InstantiationDependent = true;
2246
457k
    if (initExprs[I]->containsUnexpandedParameterPack())
2247
17
      ExprBits.ContainsUnexpandedParameterPack = true;
2248
457k
  }
2249
227k
2250
227k
  InitExprs.insert(C, InitExprs.end(), initExprs.begin(), initExprs.end());
2251
227k
}
2252
2253
96.6k
void InitListExpr::reserveInits(const ASTContext &C, unsigned NumInits) {
2254
96.6k
  if (NumInits > InitExprs.size())
2255
74.9k
    InitExprs.reserve(C, NumInits);
2256
96.6k
}
2257
2258
5.40k
void InitListExpr::resizeInits(const ASTContext &C, unsigned NumInits) {
2259
5.40k
  InitExprs.resize(C, NumInits, nullptr);
2260
5.40k
}
2261
2262
447k
Expr *InitListExpr::updateInit(const ASTContext &C, unsigned Init, Expr *expr) {
2263
447k
  if (Init >= InitExprs.size()) {
2264
443k
    InitExprs.insert(C, InitExprs.end(), Init - InitExprs.size() + 1, nullptr);
2265
443k
    setInit(Init, expr);
2266
443k
    return nullptr;
2267
443k
  }
2268
3.98k
2269
3.98k
  Expr *Result = cast_or_null<Expr>(InitExprs[Init]);
2270
3.98k
  setInit(Init, expr);
2271
3.98k
  return Result;
2272
3.98k
}
2273
2274
5.06k
void InitListExpr::setArrayFiller(Expr *filler) {
2275
5.06k
  assert(!hasArrayFiller() && "Filler already set!");
2276
5.06k
  ArrayFillerOrUnionFieldInit = filler;
2277
5.06k
  // Fill out any "holes" in the array due to designated initializers.
2278
5.06k
  Expr **inits = getInits();
2279
16.2k
  for (unsigned i = 0, e = getNumInits(); i != e; 
++i11.1k
)
2280
11.1k
    if (inits[i] == nullptr)
2281
5.25k
      inits[i] = filler;
2282
5.06k
}
2283
2284
5.18k
bool InitListExpr::isStringLiteralInit() const {
2285
5.18k
  if (getNumInits() != 1)
2286
4.59k
    return false;
2287
588
  const ArrayType *AT = getType()->getAsArrayTypeUnsafe();
2288
588
  if (!AT || !AT->getElementType()->isIntegerType())
2289
132
    return false;
2290
456
  // It is possible for getInit() to return null.
2291
456
  const Expr *Init = getInit(0);
2292
456
  if (!Init)
2293
0
    return false;
2294
456
  Init = Init->IgnoreParens();
2295
456
  return isa<StringLiteral>(Init) || 
isa<ObjCEncodeExpr>(Init)367
;
2296
456
}
2297
2298
114k
bool InitListExpr::isTransparent() const {
2299
114k
  assert(isSemanticForm() && "syntactic form never semantically transparent");
2300
114k
2301
114k
  // A glvalue InitListExpr is always just sugar.
2302
114k
  if (isGLValue()) {
2303
58
    assert(getNumInits() == 1 && "multiple inits in glvalue init list");
2304
58
    return true;
2305
58
  }
2306
114k
2307
114k
  // Otherwise, we're sugar if and only if we have exactly one initializer that
2308
114k
  // is of the same type.
2309
114k
  if (getNumInits() != 1 || 
!getInit(0)19.1k
)
2310
94.9k
    return false;
2311
19.1k
2312
19.1k
  // Don't confuse aggregate initialization of a struct X { X &x; }; with a
2313
19.1k
  // transparent struct copy.
2314
19.1k
  if (!getInit(0)->isRValue() && 
getType()->isRecordType()385
)
2315
385
    return false;
2316
18.7k
2317
18.7k
  return getType().getCanonicalType() ==
2318
18.7k
         getInit(0)->getType().getCanonicalType();
2319
18.7k
}
2320
2321
47.7k
bool InitListExpr::isIdiomaticZeroInitializer(const LangOptions &LangOpts) const {
2322
47.7k
  assert(isSyntacticForm() && "only test syntactic form as zero initializer");
2323
47.7k
2324
47.7k
  if (LangOpts.CPlusPlus || 
getNumInits() != 18.04k
||
!getInit(0)1.86k
) {
2325
45.9k
    return false;
2326
45.9k
  }
2327
1.86k
2328
1.86k
  const IntegerLiteral *Lit = dyn_cast<IntegerLiteral>(getInit(0)->IgnoreImplicit());
2329
1.86k
  return Lit && 
Lit->getValue() == 0738
;
2330
1.86k
}
2331
2332
521k
SourceLocation InitListExpr::getBeginLoc() const {
2333
521k
  if (InitListExpr *SyntacticForm = getSyntacticForm())
2334
122k
    return SyntacticForm->getBeginLoc();
2335
399k
  SourceLocation Beg = LBraceLoc;
2336
399k
  if (Beg.isInvalid()) {
2337
179
    // Find the first non-null initializer.
2338
179
    for (InitExprsTy::const_iterator I = InitExprs.begin(),
2339
179
                                     E = InitExprs.end();
2340
179
      I != E; 
++I0
) {
2341
179
      if (Stmt *S = *I) {
2342
179
        Beg = S->getBeginLoc();
2343
179
        break;
2344
179
      }
2345
179
    }
2346
179
  }
2347
399k
  return Beg;
2348
399k
}
2349
2350
348k
SourceLocation InitListExpr::getEndLoc() const {
2351
348k
  if (InitListExpr *SyntacticForm = getSyntacticForm())
2352
70.7k
    return SyntacticForm->getEndLoc();
2353
278k
  SourceLocation End = RBraceLoc;
2354
278k
  if (End.isInvalid()) {
2355
40
    // Find the first non-null initializer from the end.
2356
40
    for (InitExprsTy::const_reverse_iterator I = InitExprs.rbegin(),
2357
40
         E = InitExprs.rend();
2358
40
         I != E; 
++I0
) {
2359
40
      if (Stmt *S = *I) {
2360
40
        End = S->getEndLoc();
2361
40
        break;
2362
40
      }
2363
40
    }
2364
40
  }
2365
278k
  return End;
2366
278k
}
2367
2368
/// getFunctionType - Return the underlying function type for this block.
2369
///
2370
1.57k
const FunctionProtoType *BlockExpr::getFunctionType() const {
2371
1.57k
  // The block pointer is never sugared, but the function type might be.
2372
1.57k
  return cast<BlockPointerType>(getType())
2373
1.57k
           ->getPointeeType()->castAs<FunctionProtoType>();
2374
1.57k
}
2375
2376
23.6k
SourceLocation BlockExpr::getCaretLocation() const {
2377
23.6k
  return TheBlock->getCaretLocation();
2378
23.6k
}
2379
6.05k
const Stmt *BlockExpr::getBody() const {
2380
6.05k
  return TheBlock->getBody();
2381
6.05k
}
2382
817
Stmt *BlockExpr::getBody() {
2383
817
  return TheBlock->getBody();
2384
817
}
2385
2386
2387
//===----------------------------------------------------------------------===//
2388
// Generic Expression Routines
2389
//===----------------------------------------------------------------------===//
2390
2391
/// isUnusedResultAWarning - Return true if this immediate expression should
2392
/// be warned about if the result is unused.  If so, fill in Loc and Ranges
2393
/// with location to warn on and the source range[s] to report with the
2394
/// warning.
2395
bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc,
2396
                                  SourceRange &R1, SourceRange &R2,
2397
2.05M
                                  ASTContext &Ctx) const {
2398
2.05M
  // Don't warn if the expr is type dependent. The type could end up
2399
2.05M
  // instantiating to void.
2400
2.05M
  if (isTypeDependent())
2401
779k
    return false;
2402
1.27M
2403
1.27M
  switch (getStmtClass()) {
2404
16.1k
  default:
2405
16.1k
    if (getType()->isVoidType())
2406
12.8k
      return false;
2407
3.33k
    WarnE = this;
2408
3.33k
    Loc = getExprLoc();
2409
3.33k
    R1 = getSourceRange();
2410
3.33k
    return true;
2411
26.1k
  case ParenExprClass:
2412
26.1k
    return cast<ParenExpr>(this)->getSubExpr()->
2413
26.1k
      isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2414
3.33k
  case GenericSelectionExprClass:
2415
13
    return cast<GenericSelectionExpr>(this)->getResultExpr()->
2416
13
      isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2417
3.33k
  case CoawaitExprClass:
2418
187
  case CoyieldExprClass:
2419
187
    return cast<CoroutineSuspendExpr>(this)->getResumeExpr()->
2420
187
      isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2421
187
  case ChooseExprClass:
2422
6
    return cast<ChooseExpr>(this)->getChosenSubExpr()->
2423
6
      isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2424
186k
  case UnaryOperatorClass: {
2425
186k
    const UnaryOperator *UO = cast<UnaryOperator>(this);
2426
186k
2427
186k
    switch (UO->getOpcode()) {
2428
651
    case UO_Plus:
2429
651
    case UO_Minus:
2430
651
    case UO_AddrOf:
2431
651
    case UO_Not:
2432
651
    case UO_LNot:
2433
651
    case UO_Deref:
2434
651
      break;
2435
182k
    case UO_Coawait:
2436
182k
      // This is just the 'operator co_await' call inside the guts of a
2437
182k
      // dependent co_await call.
2438
182k
    case UO_PostInc:
2439
182k
    case UO_PostDec:
2440
182k
    case UO_PreInc:
2441
182k
    case UO_PreDec:                 // ++/--
2442
182k
      return false;  // Not a warning.
2443
182k
    case UO_Real:
2444
16
    case UO_Imag:
2445
16
      // accessing a piece of a volatile complex is a side-effect.
2446
16
      if (Ctx.getCanonicalType(UO->getSubExpr()->getType())
2447
16
          .isVolatileQualified())
2448
11
        return false;
2449
5
      break;
2450
3.23k
    case UO_Extension:
2451
3.23k
      return UO->getSubExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2452
656
    }
2453
656
    WarnE = this;
2454
656
    Loc = UO->getOperatorLoc();
2455
656
    R1 = UO->getSubExpr()->getSourceRange();
2456
656
    return true;
2457
656
  }
2458
554k
  case BinaryOperatorClass: {
2459
554k
    const BinaryOperator *BO = cast<BinaryOperator>(this);
2460
554k
    switch (BO->getOpcode()) {
2461
547k
      default:
2462
547k
        break;
2463
0
      // Consider the RHS of comma for side effects. LHS was checked by
2464
0
      // Sema::CheckCommaOperands.
2465
7.16k
      case BO_Comma:
2466
7.16k
        // ((foo = <blah>), 0) is an idiom for hiding the result (and
2467
7.16k
        // lvalue-ness) of an assignment written in a macro.
2468
7.16k
        if (IntegerLiteral *IE =
2469
94
              dyn_cast<IntegerLiteral>(BO->getRHS()->IgnoreParens()))
2470
94
          if (IE->getValue() == 0)
2471
45
            return false;
2472
7.12k
        return BO->getRHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2473
7.12k
      // Consider '||', '&&' to have side effects if the LHS or RHS does.
2474
7.12k
      case BO_LAnd:
2475
148
      case BO_LOr:
2476
148
        if (!BO->getLHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx) ||
2477
148
            
!BO->getRHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx)111
)
2478
81
          return false;
2479
67
        break;
2480
547k
    }
2481
547k
    if (BO->isAssignmentOp())
2482
545k
      return false;
2483
1.31k
    WarnE = this;
2484
1.31k
    Loc = BO->getOperatorLoc();
2485
1.31k
    R1 = BO->getLHS()->getSourceRange();
2486
1.31k
    R2 = BO->getRHS()->getSourceRange();
2487
1.31k
    return true;
2488
1.31k
  }
2489
52.8k
  case CompoundAssignOperatorClass:
2490
52.8k
  case VAArgExprClass:
2491
52.8k
  case AtomicExprClass:
2492
52.8k
    return false;
2493
52.8k
2494
52.8k
  case ConditionalOperatorClass: {
2495
505
    // If only one of the LHS or RHS is a warning, the operator might
2496
505
    // be being used for control flow. Only warn if both the LHS and
2497
505
    // RHS are warnings.
2498
505
    const auto *Exp = cast<ConditionalOperator>(this);
2499
505
    return Exp->getLHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx) &&
2500
505
           
Exp->getRHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx)105
;
2501
52.8k
  }
2502
52.8k
  case BinaryConditionalOperatorClass: {
2503
15
    const auto *Exp = cast<BinaryConditionalOperator>(this);
2504
15
    return Exp->getFalseExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2505
52.8k
  }
2506
52.8k
2507
52.8k
  case MemberExprClass:
2508
3.00k
    WarnE = this;
2509
3.00k
    Loc = cast<MemberExpr>(this)->getMemberLoc();
2510
3.00k
    R1 = SourceRange(Loc, Loc);
2511
3.00k
    R2 = cast<MemberExpr>(this)->getBase()->getSourceRange();
2512
3.00k
    return true;
2513
52.8k
2514
52.8k
  case ArraySubscriptExprClass:
2515
382
    WarnE = this;
2516
382
    Loc = cast<ArraySubscriptExpr>(this)->getRBracketLoc();
2517
382
    R1 = cast<ArraySubscriptExpr>(this)->getLHS()->getSourceRange();
2518
382
    R2 = cast<ArraySubscriptExpr>(this)->getRHS()->getSourceRange();
2519
382
    return true;
2520
52.8k
2521
52.8k
  case CXXOperatorCallExprClass: {
2522
22.3k
    // Warn about operator ==,!=,<,>,<=, and >= even when user-defined operator
2523
22.3k
    // overloads as there is no reasonable way to define these such that they
2524
22.3k
    // have non-trivial, desirable side-effects. See the -Wunused-comparison
2525
22.3k
    // warning: operators == and != are commonly typo'ed, and so warning on them
2526
22.3k
    // provides additional value as well. If this list is updated,
2527
22.3k
    // DiagnoseUnusedComparison should be as well.
2528
22.3k
    const CXXOperatorCallExpr *Op = cast<CXXOperatorCallExpr>(this);
2529
22.3k
    switch (Op->getOperator()) {
2530
22.2k
    default:
2531
22.2k
      break;
2532
42
    case OO_EqualEqual:
2533
42
    case OO_ExclaimEqual:
2534
42
    case OO_Less:
2535
42
    case OO_Greater:
2536
42
    case OO_GreaterEqual:
2537
42
    case OO_LessEqual:
2538
42
      if (Op->getCallReturnType(Ctx)->isReferenceType() ||
2539
42
          
Op->getCallReturnType(Ctx)->isVoidType()41
)
2540
8
        break;
2541
34
      WarnE = this;
2542
34
      Loc = Op->getOperatorLoc();
2543
34
      R1 = Op->getSourceRange();
2544
34
      return true;
2545
22.2k
    }
2546
22.2k
2547
22.2k
    // Fallthrough for generic call handling.
2548
22.2k
    LLVM_FALLTHROUGH;
2549
22.2k
  }
2550
360k
  case CallExprClass:
2551
360k
  case CXXMemberCallExprClass:
2552
360k
  case UserDefinedLiteralClass: {
2553
360k
    // If this is a direct call, get the callee.
2554
360k
    const CallExpr *CE = cast<CallExpr>(this);
2555
360k
    if (const Decl *FD = CE->getCalleeDecl()) {
2556
360k
      // If the callee has attribute pure, const, or warn_unused_result, warn
2557
360k
      // about it. void foo() { strlen("bar"); } should warn.
2558
360k
      //
2559
360k
      // Note: If new cases are added here, DiagnoseUnusedExprResult should be
2560
360k
      // updated to match for QoI.
2561
360k
      if (CE->hasUnusedResultAttr(Ctx) ||
2562
360k
          
FD->hasAttr<PureAttr>()360k
||
FD->hasAttr<ConstAttr>()359k
) {
2563
7.19k
        WarnE = this;
2564
7.19k
        Loc = CE->getCallee()->getBeginLoc();
2565
7.19k
        R1 = CE->getCallee()->getSourceRange();
2566
7.19k
2567
7.19k
        if (unsigned NumArgs = CE->getNumArgs())
2568
7.07k
          R2 = SourceRange(CE->getArg(0)->getBeginLoc(),
2569
7.07k
                           CE->getArg(NumArgs - 1)->getEndLoc());
2570
7.19k
        return true;
2571
7.19k
      }
2572
353k
    }
2573
353k
    return false;
2574
353k
  }
2575
353k
2576
353k
  // If we don't know precisely what we're looking at, let's not warn.
2577
353k
  case UnresolvedLookupExprClass:
2578
13
  case CXXUnresolvedConstructExprClass:
2579
13
    return false;
2580
13
2581
678
  case CXXTemporaryObjectExprClass:
2582
678
  case CXXConstructExprClass: {
2583
678
    if (const CXXRecordDecl *Type = getType()->getAsCXXRecordDecl()) {
2584
678
      const auto *WarnURAttr = Type->getAttr<WarnUnusedResultAttr>();
2585
678
      if (Type->hasAttr<WarnUnusedAttr>() ||
2586
678
          
(669
WarnURAttr669
&&
WarnURAttr->IsCXX11NoDiscard()4
)) {
2587
13
        WarnE = this;
2588
13
        Loc = getBeginLoc();
2589
13
        R1 = getSourceRange();
2590
13
        return true;
2591
13
      }
2592
665
    }
2593
665
2594
665
    const auto *CE = cast<CXXConstructExpr>(this);
2595
665
    if (const CXXConstructorDecl *Ctor = CE->getConstructor()) {
2596
665
      const auto *WarnURAttr = Ctor->getAttr<WarnUnusedResultAttr>();
2597
665
      if (WarnURAttr && 
WarnURAttr->IsCXX11NoDiscard()12
) {
2598
9
        WarnE = this;
2599
9
        Loc = getBeginLoc();
2600
9
        R1 = getSourceRange();
2601
9
2602
9
        if (unsigned NumArgs = CE->getNumArgs())
2603
6
          R2 = SourceRange(CE->getArg(0)->getBeginLoc(),
2604
6
                           CE->getArg(NumArgs - 1)->getEndLoc());
2605
9
        return true;
2606
9
      }
2607
656
    }
2608
656
2609
656
    return false;
2610
656
  }
2611
656
2612
9.83k
  case ObjCMessageExprClass: {
2613
9.83k
    const ObjCMessageExpr *ME = cast<ObjCMessageExpr>(this);
2614
9.83k
    if (Ctx.getLangOpts().ObjCAutoRefCount &&
2615
9.83k
        
ME->isInstanceMessage()661
&&
2616
9.83k
        
!ME->getType()->isVoidType()626
&&
2617
9.83k
        
ME->getMethodFamily() == OMF_init174
) {
2618
23
      WarnE = this;
2619
23
      Loc = getExprLoc();
2620
23
      R1 = ME->getSourceRange();
2621
23
      return true;
2622
23
    }
2623
9.81k
2624
9.81k
    if (const ObjCMethodDecl *MD = ME->getMethodDecl())
2625
9.31k
      if (MD->hasAttr<WarnUnusedResultAttr>()) {
2626
2
        WarnE = this;
2627
2
        Loc = getExprLoc();
2628
2
        return true;
2629
2
      }
2630
9.80k
2631
9.80k
    return false;
2632
9.80k
  }
2633
9.80k
2634
9.80k
  case ObjCPropertyRefExprClass:
2635
0
    WarnE = this;
2636
0
    Loc = getExprLoc();
2637
0
    R1 = getSourceRange();
2638
0
    return true;
2639
9.80k
2640
9.80k
  case PseudoObjectExprClass: {
2641
1.11k
    const PseudoObjectExpr *PO = cast<PseudoObjectExpr>(this);
2642
1.11k
2643
1.11k
    // Only complain about things that have the form of a getter.
2644
1.11k
    if (isa<UnaryOperator>(PO->getSyntacticForm()) ||
2645
1.11k
        
isa<BinaryOperator>(PO->getSyntacticForm())1.08k
)
2646
955
      return false;
2647
157
2648
157
    WarnE = this;
2649
157
    Loc = getExprLoc();
2650
157
    R1 = getSourceRange();
2651
157
    return true;
2652
157
  }
2653
157
2654
3.32k
  case StmtExprClass: {
2655
3.32k
    // Statement exprs don't logically have side effects themselves, but are
2656
3.32k
    // sometimes used in macros in ways that give them a type that is unused.
2657
3.32k
    // For example ({ blah; foo(); }) will end up with a type if foo has a type.
2658
3.32k
    // however, if the result of the stmt expr is dead, we don't want to emit a
2659
3.32k
    // warning.
2660
3.32k
    const CompoundStmt *CS = cast<StmtExpr>(this)->getSubStmt();
2661
3.32k
    if (!CS->body_empty()) {
2662
3.27k
      if (const Expr *E = dyn_cast<Expr>(CS->body_back()))
2663
2.05k
        return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2664
1.22k
      if (const LabelStmt *Label = dyn_cast<LabelStmt>(CS->body_back()))
2665
2
        if (const Expr *E = dyn_cast<Expr>(Label->getSubStmt()))
2666
2
          return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2667
1.26k
    }
2668
1.26k
2669
1.26k
    if (getType()->isVoidType())
2670
1.26k
      return false;
2671
3
    WarnE = this;
2672
3
    Loc = cast<StmtExpr>(this)->getLParenLoc();
2673
3
    R1 = getSourceRange();
2674
3
    return true;
2675
3
  }
2676
52.7k
  case CXXFunctionalCastExprClass:
2677
52.7k
  case CStyleCastExprClass: {
2678
52.7k
    // Ignore an explicit cast to void unless the operand is a non-trivial
2679
52.7k
    // volatile lvalue.
2680
52.7k
    const CastExpr *CE = cast<CastExpr>(this);
2681
52.7k
    if (CE->getCastKind() == CK_ToVoid) {
2682
51.8k
      if (CE->getSubExpr()->isGLValue() &&
2683
51.8k
          
CE->getSubExpr()->getType().isVolatileQualified()5.12k
) {
2684
115
        const DeclRefExpr *DRE =
2685
115
            dyn_cast<DeclRefExpr>(CE->getSubExpr()->IgnoreParens());
2686
115
        if (!(DRE && 
isa<VarDecl>(DRE->getDecl())6
&&
2687
115
              
cast<VarDecl>(DRE->getDecl())->hasLocalStorage()6
) &&
2688
115
            
!isa<CallExpr>(CE->getSubExpr()->IgnoreParens())113
) {
2689
107
          return CE->getSubExpr()->isUnusedResultAWarning(WarnE, Loc,
2690
107
                                                          R1, R2, Ctx);
2691
107
        }
2692
51.7k
      }
2693
51.7k
      return false;
2694
51.7k
    }
2695
891
2696
891
    // If this is a cast to a constructor conversion, check the operand.
2697
891
    // Otherwise, the result of the cast is unused.
2698
891
    if (CE->getCastKind() == CK_ConstructorConversion)
2699
69
      return CE->getSubExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2700
822
2701
822
    WarnE = this;
2702
822
    if (const CXXFunctionalCastExpr *CXXCE =
2703
63
            dyn_cast<CXXFunctionalCastExpr>(this)) {
2704
63
      Loc = CXXCE->getBeginLoc();
2705
63
      R1 = CXXCE->getSubExpr()->getSourceRange();
2706
759
    } else {
2707
759
      const CStyleCastExpr *CStyleCE = cast<CStyleCastExpr>(this);
2708
759
      Loc = CStyleCE->getLParenLoc();
2709
759
      R1 = CStyleCE->getSubExpr()->getSourceRange();
2710
759
    }
2711
822
    return true;
2712
822
  }
2713
1.03k
  case ImplicitCastExprClass: {
2714
1.03k
    const CastExpr *ICE = cast<ImplicitCastExpr>(this);
2715
1.03k
2716
1.03k
    // lvalue-to-rvalue conversion on a volatile lvalue is a side-effect.
2717
1.03k
    if (ICE->getCastKind() == CK_LValueToRValue &&
2718
1.03k
        
ICE->getSubExpr()->getType().isVolatileQualified()646
)
2719
59
      return false;
2720
977
2721
977
    return ICE->getSubExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2722
977
  }
2723
977
  case CXXDefaultArgExprClass:
2724
0
    return (cast<CXXDefaultArgExpr>(this)
2725
0
            ->getExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx));
2726
977
  case CXXDefaultInitExprClass:
2727
0
    return (cast<CXXDefaultInitExpr>(this)
2728
0
            ->getExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx));
2729
977
2730
5.50k
  case CXXNewExprClass:
2731
5.50k
    // FIXME: In theory, there might be new expressions that don't have side
2732
5.50k
    // effects (e.g. a placement new with an uninitialized POD).
2733
5.50k
  case CXXDeleteExprClass:
2734
5.50k
    return false;
2735
5.50k
  case MaterializeTemporaryExprClass:
2736
0
    return cast<MaterializeTemporaryExpr>(this)
2737
0
        ->getSubExpr()
2738
0
        ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2739
5.50k
  case CXXBindTemporaryExprClass:
2740
311
    return cast<CXXBindTemporaryExpr>(this)->getSubExpr()
2741
311
               ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2742
5.50k
  case ExprWithCleanupsClass:
2743
17
    return cast<ExprWithCleanups>(this)->getSubExpr()
2744
17
               ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2745
1.27M
  }
2746
1.27M
}
2747
2748
/// isOBJCGCCandidate - Check if an expression is objc gc'able.
2749
/// returns true, if it is; false otherwise.
2750
495
bool Expr::isOBJCGCCandidate(ASTContext &Ctx) const {
2751
495
  const Expr *E = IgnoreParens();
2752
495
  switch (E->getStmtClass()) {
2753
4
  default:
2754
4
    return false;
2755
64
  case ObjCIvarRefExprClass:
2756
64
    return true;
2757
15
  case Expr::UnaryOperatorClass:
2758
15
    return cast<UnaryOperator>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2759
149
  case ImplicitCastExprClass:
2760
149
    return cast<ImplicitCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2761
0
  case MaterializeTemporaryExprClass:
2762
0
    return cast<MaterializeTemporaryExpr>(E)->getSubExpr()->isOBJCGCCandidate(
2763
0
        Ctx);
2764
3
  case CStyleCastExprClass:
2765
3
    return cast<CStyleCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2766
69
  case DeclRefExprClass: {
2767
69
    const Decl *D = cast<DeclRefExpr>(E)->getDecl();
2768
69
2769
69
    if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2770
69
      if (VD->hasGlobalStorage())
2771
56
        return true;
2772
13
      QualType T = VD->getType();
2773
13
      // dereferencing to a  pointer is always a gc'able candidate,
2774
13
      // unless it is __weak.
2775
13
      return T->isPointerType() &&
2776
13
             
(Ctx.getObjCGCAttrKind(T) != Qualifiers::Weak)11
;
2777
13
    }
2778
0
    return false;
2779
0
  }
2780
56
  case MemberExprClass: {
2781
56
    const MemberExpr *M = cast<MemberExpr>(E);
2782
56
    return M->getBase()->isOBJCGCCandidate(Ctx);
2783
0
  }
2784
135
  case ArraySubscriptExprClass:
2785
135
    return cast<ArraySubscriptExpr>(E)->getBase()->isOBJCGCCandidate(Ctx);
2786
495
  }
2787
495
}
2788
2789
0
bool Expr::isBoundMemberFunction(ASTContext &Ctx) const {
2790
0
  if (isTypeDependent())
2791
0
    return false;
2792
0
  return ClassifyLValue(Ctx) == Expr::LV_MemberFunction;
2793
0
}
2794
2795
221k
QualType Expr::findBoundMemberType(const Expr *expr) {
2796
221k
  assert(expr->hasPlaceholderType(BuiltinType::BoundMember));
2797
221k
2798
221k
  // Bound member expressions are always one of these possibilities:
2799
221k
  //   x->m      x.m      x->*y      x.*y
2800
221k
  // (possibly parenthesized)
2801
221k
2802
221k
  expr = expr->IgnoreParens();
2803
221k
  if (const MemberExpr *mem = dyn_cast<MemberExpr>(expr)) {
2804
220k
    assert(isa<CXXMethodDecl>(mem->getMemberDecl()));
2805
220k
    return mem->getMemberDecl()->getType();
2806
220k
  }
2807
460
2808
460
  if (const BinaryOperator *op = dyn_cast<BinaryOperator>(expr)) {
2809
458
    QualType type = op->getRHS()->getType()->castAs<MemberPointerType>()
2810
458
                      ->getPointeeType();
2811
458
    assert(type->isFunctionType());
2812
458
    return type;
2813
458
  }
2814
2
2815
2
  assert(isa<UnresolvedMemberExpr>(expr) || isa<CXXPseudoDestructorExpr>(expr));
2816
2
  return QualType();
2817
2
}
2818
2819
141M
static Expr *IgnoreImpCastsSingleStep(Expr *E) {
2820
141M
  if (auto *ICE = dyn_cast<ImplicitCastExpr>(E))
2821
37.8M
    return ICE->getSubExpr();
2822
103M
2823
103M
  if (auto *FE = dyn_cast<FullExpr>(E))
2824
3.43k
    return FE->getSubExpr();
2825
103M
2826
103M
  return E;
2827
103M
}
2828
2829
131M
static Expr *IgnoreImpCastsExtraSingleStep(Expr *E) {
2830
131M
  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
2831
131M
  // addition to what IgnoreImpCasts() skips to account for the current
2832
131M
  // behaviour of IgnoreParenImpCasts().
2833
131M
  Expr *SubE = IgnoreImpCastsSingleStep(E);
2834
131M
  if (SubE != E)
2835
35.1M
    return SubE;
2836
96.1M
2837
96.1M
  if (auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
2838
245k
    return MTE->getSubExpr();
2839
95.9M
2840
95.9M
  if (auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E))
2841
1.28M
    return NTTP->getReplacement();
2842
94.6M
2843
94.6M
  return E;
2844
94.6M
}
2845
2846
76.2M
static Expr *IgnoreCastsSingleStep(Expr *E) {
2847
76.2M
  if (auto *CE = dyn_cast<CastExpr>(E))
2848
12.7M
    return CE->getSubExpr();
2849
63.5M
2850
63.5M
  if (auto *FE = dyn_cast<FullExpr>(E))
2851
694
    return FE->getSubExpr();
2852
63.5M
2853
63.5M
  if (auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
2854
23.1k
    return MTE->getSubExpr();
2855
63.4M
2856
63.4M
  if (auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E))
2857
257k
    return NTTP->getReplacement();
2858
63.2M
2859
63.2M
  return E;
2860
63.2M
}
2861
2862
37.8k
static Expr *IgnoreLValueCastsSingleStep(Expr *E) {
2863
37.8k
  // Skip what IgnoreCastsSingleStep skips, except that only
2864
37.8k
  // lvalue-to-rvalue casts are skipped.
2865
37.8k
  if (auto *CE = dyn_cast<CastExpr>(E))
2866
3.15k
    if (CE->getCastKind() != CK_LValueToRValue)
2867
285
      return E;
2868
37.5k
2869
37.5k
  return IgnoreCastsSingleStep(E);
2870
37.5k
}
2871
2872
37.6k
static Expr *IgnoreBaseCastsSingleStep(Expr *E) {
2873
37.6k
  if (auto *CE = dyn_cast<CastExpr>(E))
2874
7.33k
    if (CE->getCastKind() == CK_DerivedToBase ||
2875
7.33k
        
CE->getCastKind() == CK_UncheckedDerivedToBase7.25k
||
2876
7.33k
        
CE->getCastKind() == CK_NoOp6.92k
)
2877
3.51k
      return CE->getSubExpr();
2878
34.1k
2879
34.1k
  return E;
2880
34.1k
}
2881
2882
654k
static Expr *IgnoreImplicitSingleStep(Expr *E) {
2883
654k
  Expr *SubE = IgnoreImpCastsSingleStep(E);
2884
654k
  if (SubE != E)
2885
158k
    return SubE;
2886
495k
2887
495k
  if (auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
2888
393
    return MTE->getSubExpr();
2889
495k
2890
495k
  if (auto *BTE = dyn_cast<CXXBindTemporaryExpr>(E))
2891
104
    return BTE->getSubExpr();
2892
495k
2893
495k
  return E;
2894
495k
}
2895
2896
818
static Expr *IgnoreImplicitAsWrittenSingleStep(Expr *E) {
2897
818
  if (auto *ICE = dyn_cast<ImplicitCastExpr>(E))
2898
177
    return ICE->getSubExprAsWritten();
2899
641
2900
641
  return IgnoreImplicitSingleStep(E);
2901
641
}
2902
2903
702
static Expr *IgnoreParensOnlySingleStep(Expr *E) {
2904
702
  if (auto *PE = dyn_cast<ParenExpr>(E))
2905
2
    return PE->getSubExpr();
2906
700
  return E;
2907
700
}
2908
2909
290M
static Expr *IgnoreParensSingleStep(Expr *E) {
2910
290M
  if (auto *PE = dyn_cast<ParenExpr>(E))
2911
8.02M
    return PE->getSubExpr();
2912
282M
2913
282M
  if (auto *UO = dyn_cast<UnaryOperator>(E)) {
2914
4.58M
    if (UO->getOpcode() == UO_Extension)
2915
235k
      return UO->getSubExpr();
2916
277M
  }
2917
277M
2918
277M
  else if (auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
2919
1.26k
    if (!GSE->isResultDependent())
2920
1.26k
      return GSE->getResultExpr();
2921
277M
  }
2922
277M
2923
277M
  else if (auto *CE = dyn_cast<ChooseExpr>(E)) {
2924
208
    if (!CE->isConditionDependent())
2925
205
      return CE->getChosenSubExpr();
2926
277M
  }
2927
277M
2928
277M
  else if (auto *CE = dyn_cast<ConstantExpr>(E))
2929
283k
    return CE->getSubExpr();
2930
281M
2931
281M
  return E;
2932
281M
}
2933
2934
19.0k
static Expr *IgnoreNoopCastsSingleStep(const ASTContext &Ctx, Expr *E) {
2935
19.0k
  if (auto *CE = dyn_cast<CastExpr>(E)) {
2936
2.35k
    // We ignore integer <-> casts that are of the same width, ptr<->ptr and
2937
2.35k
    // ptr<->int casts of the same width. We also ignore all identity casts.
2938
2.35k
    Expr *SubExpr = CE->getSubExpr();
2939
2.35k
    bool IsIdentityCast =
2940
2.35k
        Ctx.hasSameUnqualifiedType(E->getType(), SubExpr->getType());
2941
2.35k
    bool IsSameWidthCast =
2942
2.35k
        (E->getType()->isPointerType() || 
E->getType()->isIntegralType(Ctx)1.48k
) &&
2943
2.35k
        
(1.91k
SubExpr->getType()->isPointerType()1.91k
||
2944
1.91k
         
SubExpr->getType()->isIntegralType(Ctx)1.45k
) &&
2945
2.35k
        
(Ctx.getTypeSize(E->getType()) == Ctx.getTypeSize(SubExpr->getType()))1.49k
;
2946
2.35k
2947
2.35k
    if (IsIdentityCast || 
IsSameWidthCast1.06k
)
2948
1.57k
      return SubExpr;
2949
16.7k
  }
2950
16.7k
2951
16.7k
  else if (auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E))
2952
4
    return NTTP->getReplacement();
2953
17.4k
2954
17.4k
  return E;
2955
17.4k
}
2956
2957
300M
static Expr *IgnoreExprNodesImpl(Expr *E) { return E; }
2958
template <typename FnTy, typename... FnTys>
2959
507M
static Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
2960
507M
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
2961
507M
}
Expr.cpp:clang::Expr* IgnoreExprNodesImpl<clang::Expr* (&)(clang::Expr*)>(clang::Expr*, clang::Expr* (&&&)(clang::Expr*))
Line
Count
Source
2959
300M
static Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
2960
300M
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
2961
300M
}
Expr.cpp:clang::Expr* IgnoreExprNodesImpl<clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*)>(clang::Expr*, clang::Expr* (&&&)(clang::Expr*), clang::Expr* (&&&)(clang::Expr*))
Line
Count
Source
2959
207M
static Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
2960
207M
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
2961
207M
}
Expr.cpp:clang::Expr* IgnoreExprNodesImpl<clang::Expr* (&)(clang::Expr*), clang::Expr::IgnoreParenNoopCasts(clang::ASTContext const&)::$_2>(clang::Expr*, clang::Expr* (&&&)(clang::Expr*), clang::Expr::IgnoreParenNoopCasts(clang::ASTContext const&)::$_2&&)
Line
Count
Source
2959
19.0k
static Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
2960
19.0k
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
2961
19.0k
}
Expr.cpp:clang::Expr* IgnoreExprNodesImpl<clang::Expr::IgnoreParenNoopCasts(clang::ASTContext const&)::$_2>(clang::Expr*, clang::Expr::IgnoreParenNoopCasts(clang::ASTContext const&)::$_2&&)
Line
Count
Source
2959
19.0k
static Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
2960
19.0k
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
2961
19.0k
}
Expr.cpp:clang::Expr* IgnoreExprNodesImpl<clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*)>(clang::Expr*, clang::Expr* (&&&)(clang::Expr*), clang::Expr* (&&&)(clang::Expr*), clang::Expr* (&&&)(clang::Expr*))
Line
Count
Source
2959
702
static Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
2960
702
  return IgnoreExprNodesImpl(Fn(E), std::forward<FnTys>(Fns)...);
2961
702
}
2962
2963
/// Given an expression E and functions Fn_1,...,Fn_n : Expr * -> Expr *,
2964
/// Recursively apply each of the functions to E until reaching a fixed point.
2965
/// Note that a null E is valid; in this case nothing is done.
2966
template <typename... FnTys>
2967
239M
static Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
2968
239M
  Expr *LastE = nullptr;
2969
539M
  while (E != LastE) {
2970
300M
    LastE = E;
2971
300M
    E = IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
2972
300M
  }
2973
239M
  return E;
2974
239M
}
Expr.cpp:clang::Expr* IgnoreExprNodes<clang::Expr* (&)(clang::Expr*)>(clang::Expr*, clang::Expr* (&&&)(clang::Expr*))
Line
Count
Source
2967
87.3M
static Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
2968
87.3M
  Expr *LastE = nullptr;
2969
179M
  while (E != LastE) {
2970
92.6M
    LastE = E;
2971
92.6M
    E = IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
2972
92.6M
  }
2973
87.3M
  return E;
2974
87.3M
}
Expr.cpp:clang::Expr* IgnoreExprNodes<clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*)>(clang::Expr*, clang::Expr* (&&&)(clang::Expr*), clang::Expr* (&&&)(clang::Expr*))
Line
Count
Source
2967
152M
static Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
2968
152M
  Expr *LastE = nullptr;
2969
359M
  while (E != LastE) {
2970
207M
    LastE = E;
2971
207M
    E = IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
2972
207M
  }
2973
152M
  return E;
2974
152M
}
Expr.cpp:clang::Expr* IgnoreExprNodes<clang::Expr* (&)(clang::Expr*), clang::Expr::IgnoreParenNoopCasts(clang::ASTContext const&)::$_2>(clang::Expr*, clang::Expr* (&&&)(clang::Expr*), clang::Expr::IgnoreParenNoopCasts(clang::ASTContext const&)::$_2&&)
Line
Count
Source
2967
17.3k
static Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
2968
17.3k
  Expr *LastE = nullptr;
2969
36.4k
  while (E != LastE) {
2970
19.0k
    LastE = E;
2971
19.0k
    E = IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
2972
19.0k
  }
2973
17.3k
  return E;
2974
17.3k
}
Expr.cpp:clang::Expr* IgnoreExprNodes<clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*), clang::Expr* (&)(clang::Expr*)>(clang::Expr*, clang::Expr* (&&&)(clang::Expr*), clang::Expr* (&&&)(clang::Expr*), clang::Expr* (&&&)(clang::Expr*))
Line
Count
Source
2967
599
static Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
2968
599
  Expr *LastE = nullptr;
2969
1.30k
  while (E != LastE) {
2970
702
    LastE = E;
2971
702
    E = IgnoreExprNodesImpl(E, std::forward<FnTys>(Fns)...);
2972
702
  }
2973
599
  return E;
2974
599
}
2975
2976
6.95M
Expr *Expr::IgnoreImpCasts() {
2977
6.95M
  return IgnoreExprNodes(this, IgnoreImpCastsSingleStep);
2978
6.95M
}
2979
2980
1.07k
Expr *Expr::IgnoreCasts() {
2981
1.07k
  return IgnoreExprNodes(this, IgnoreCastsSingleStep);
2982
1.07k
}
2983
2984
494k
Expr *Expr::IgnoreImplicit() {
2985
494k
  return IgnoreExprNodes(this, IgnoreImplicitSingleStep);
2986
494k
}
2987
2988
623
Expr *Expr::IgnoreImplicitAsWritten() {
2989
623
  return IgnoreExprNodes(this, IgnoreImplicitAsWrittenSingleStep);
2990
623
}
2991
2992
79.8M
Expr *Expr::IgnoreParens() {
2993
79.8M
  return IgnoreExprNodes(this, IgnoreParensSingleStep);
2994
79.8M
}
2995
2996
91.4M
Expr *Expr::IgnoreParenImpCasts() {
2997
91.4M
  return IgnoreExprNodes(this, IgnoreParensSingleStep,
2998
91.4M
                         IgnoreImpCastsExtraSingleStep);
2999
91.4M
}
3000
3001
60.7M
Expr *Expr::IgnoreParenCasts() {
3002
60.7M
  return IgnoreExprNodes(this, IgnoreParensSingleStep, IgnoreCastsSingleStep);
3003
60.7M
}
3004
3005
215k
Expr *Expr::IgnoreConversionOperator() {
3006
215k
  if (auto *MCE = dyn_cast<CXXMemberCallExpr>(this)) {
3007
732
    if (MCE->getMethodDecl() && 
isa<CXXConversionDecl>(MCE->getMethodDecl())730
)
3008
66
      return MCE->getImplicitObjectArgument();
3009
215k
  }
3010
215k
  return this;
3011
215k
}
3012
3013
34.8k
Expr *Expr::IgnoreParenLValueCasts() {
3014
34.8k
  return IgnoreExprNodes(this, IgnoreParensSingleStep,
3015
34.8k
                         IgnoreLValueCastsSingleStep);
3016
34.8k
}
3017
3018
33.9k
Expr *Expr::ignoreParenBaseCasts() {
3019
33.9k
  return IgnoreExprNodes(this, IgnoreParensSingleStep,
3020
33.9k
                         IgnoreBaseCastsSingleStep);
3021
33.9k
}
3022
3023
17.3k
Expr *Expr::IgnoreParenNoopCasts(const ASTContext &Ctx) {
3024
19.0k
  return IgnoreExprNodes(this, IgnoreParensSingleStep, [&Ctx](Expr *E) {
3025
19.0k
    return IgnoreNoopCastsSingleStep(Ctx, E);
3026
19.0k
  });
3027
17.3k
}
3028
3029
491
Expr *Expr::IgnoreUnlessSpelledInSource() {
3030
491
  Expr *E = this;
3031
491
3032
491
  Expr *LastE = nullptr;
3033
1.09k
  while (E != LastE) {
3034
599
    LastE = E;
3035
599
    E = IgnoreExprNodes(E, IgnoreImplicitSingleStep, IgnoreImpCastsSingleStep,
3036
599
                        IgnoreParensOnlySingleStep);
3037
599
3038
599
    auto SR = E->getSourceRange();
3039
599
3040
599
    if (auto *C = dyn_cast<CXXConstructExpr>(E)) {
3041
89
      if (C->getNumArgs() == 1) {
3042
61
        Expr *A = C->getArg(0);
3043
61
        if (A->getSourceRange() == SR || 
!isa<CXXTemporaryObjectExpr>(C)33
)
3044
52
          E = A;
3045
61
      }
3046
89
    }
3047
599
3048
599
    if (auto *C = dyn_cast<CXXMemberCallExpr>(E)) {
3049
9
      Expr *ExprNode = C->getImplicitObjectArgument()->IgnoreParenImpCasts();
3050
9
      if (ExprNode->getSourceRange() == SR)
3051
9
        E = ExprNode;
3052
9
    }
3053
599
  }
3054
491
3055
491
  return E;
3056
491
}
3057
3058
626k
bool Expr::isDefaultArgument() const {
3059
626k
  const Expr *E = this;
3060
626k
  if (const MaterializeTemporaryExpr *M = dyn_cast<MaterializeTemporaryExpr>(E))
3061
113k
    E = M->getSubExpr();
3062
626k
3063
745k
  while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E))
3064
119k
    E = ICE->getSubExprAsWritten();
3065
626k
3066
626k
  return isa<CXXDefaultArgExpr>(E);
3067
626k
}
3068
3069
/// Skip over any no-op casts and any temporary-binding
3070
/// expressions.
3071
126k
static const Expr *skipTemporaryBindingsNoOpCastsAndParens(const Expr *E) {
3072
126k
  if (const MaterializeTemporaryExpr *M = dyn_cast<MaterializeTemporaryExpr>(E))
3073
66.6k
    E = M->getSubExpr();
3074
126k
3075
170k
  while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {
3076
49.3k
    if (ICE->getCastKind() == CK_NoOp)
3077
43.4k
      E = ICE->getSubExpr();
3078
5.95k
    else
3079
5.95k
      break;
3080
49.3k
  }
3081
126k
3082
141k
  while (const CXXBindTemporaryExpr *BE = dyn_cast<CXXBindTemporaryExpr>(E))
3083
14.1k
    E = BE->getSubExpr();
3084
126k
3085
126k
  while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {
3086
11.2k
    if (ICE->getCastKind() == CK_NoOp)
3087
0
      E = ICE->getSubExpr();
3088
11.2k
    else
3089
11.2k
      break;
3090
11.2k
  }
3091
126k
3092
126k
  return E->IgnoreParens();
3093
126k
}
3094
3095
/// isTemporaryObject - Determines if this expression produces a
3096
/// temporary of the given class type.
3097
126k
bool Expr::isTemporaryObject(ASTContext &C, const CXXRecordDecl *TempTy) const {
3098
126k
  if (!C.hasSameUnqualifiedType(getType(), C.getTypeDeclType(TempTy)))
3099
19
    return false;
3100
126k
3101
126k
  const Expr *E = skipTemporaryBindingsNoOpCastsAndParens(this);
3102
126k
3103
126k
  // Temporaries are by definition pr-values of class type.
3104
126k
  if (!E->Classify(C).isPRValue()) {
3105
54.0k
    // In this context, property reference is a message call and is pr-value.
3106
54.0k
    if (!isa<ObjCPropertyRefExpr>(E))
3107
54.0k
      return false;
3108
72.8k
  }
3109
72.8k
3110
72.8k
  // Black-list a few cases which yield pr-values of class type that don't
3111
72.8k
  // refer to temporaries of that type:
3112
72.8k
3113
72.8k
  // - implicit derived-to-base conversions
3114
72.8k
  if (isa<ImplicitCastExpr>(E)) {
3115
9.16k
    switch (cast<ImplicitCastExpr>(E)->getCastKind()) {
3116
0
    case CK_DerivedToBase:
3117
0
    case CK_UncheckedDerivedToBase:
3118
0
      return false;
3119
9.16k
    default:
3120
9.16k
      break;
3121
72.8k
    }
3122
72.8k
  }
3123
72.8k
3124
72.8k
  // - member expressions (all)
3125
72.8k
  if (isa<MemberExpr>(E))
3126
0
    return false;
3127
72.8k
3128
72.8k
  if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E))
3129
48
    if (BO->isPtrMemOp())
3130
0
      return false;
3131
72.8k
3132
72.8k
  // - opaque values (all)
3133
72.8k
  if (isa<OpaqueValueExpr>(E))
3134
13
    return false;
3135
72.8k
3136
72.8k
  return true;
3137
72.8k
}
3138
3139
7.39M
bool Expr::isImplicitCXXThis() const {
3140
7.39M
  const Expr *E = this;
3141
7.39M
3142
7.39M
  // Strip away parentheses and casts we don't care about.
3143
8.68M
  while (true) {
3144
8.68M
    if (const ParenExpr *Paren = dyn_cast<ParenExpr>(E)) {
3145
65.4k
      E = Paren->getSubExpr();
3146
65.4k
      continue;
3147
65.4k
    }
3148
8.62M
3149
8.62M
    if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {
3150
1.14M
      if (ICE->getCastKind() == CK_NoOp ||
3151
1.14M
          
ICE->getCastKind() == CK_LValueToRValue814k
||
3152
1.14M
          
ICE->getCastKind() == CK_DerivedToBase101k
||
3153
1.14M
          
ICE->getCastKind() == CK_UncheckedDerivedToBase101k
) {
3154
1.14M
        E = ICE->getSubExpr();
3155
1.14M
        continue;
3156
1.14M
      }
3157
7.48M
    }
3158
7.48M
3159
7.48M
    if (const UnaryOperator* UnOp = dyn_cast<UnaryOperator>(E)) {
3160
5.10k
      if (UnOp->getOpcode() == UO_Extension) {
3161
0
        E = UnOp->getSubExpr();
3162
0
        continue;
3163
0
      }
3164
7.48M
    }
3165
7.48M
3166
7.48M
    if (const MaterializeTemporaryExpr *M
3167
91.4k
                                      = dyn_cast<MaterializeTemporaryExpr>(E)) {
3168
91.4k
      E = M->getSubExpr();
3169
91.4k
      continue;
3170
91.4k
    }
3171
7.39M
3172
7.39M
    break;
3173
7.39M
  }
3174
7.39M
3175
7.39M
  if (const CXXThisExpr *This = dyn_cast<CXXThisExpr>(E))
3176
2.53M
    return This->isImplicit();
3177
4.85M
3178
4.85M
  return false;
3179
4.85M
}
3180
3181
/// hasAnyTypeDependentArguments - Determines if any of the expressions
3182
/// in Exprs is type-dependent.
3183
12.3M
bool Expr::hasAnyTypeDependentArguments(ArrayRef<Expr *> Exprs) {
3184
24.2M
  for (unsigned I = 0; I < Exprs.size(); 
++I11.8M
)
3185
12.3M
    if (Exprs[I]->isTypeDependent())
3186
448k
      return true;
3187
12.3M
3188
12.3M
  
return false11.9M
;
3189
12.3M
}
3190
3191
bool Expr::isConstantInitializer(ASTContext &Ctx, bool IsForRef,
3192
58.6k
                                 const Expr **Culprit) const {
3193
58.6k
  assert(!isValueDependent() &&
3194
58.6k
         "Expression evaluator can't be called on a dependent expression.");
3195
58.6k
3196
58.6k
  // This function is attempting whether an expression is an initializer
3197
58.6k
  // which can be evaluated at compile-time. It very closely parallels
3198
58.6k
  // ConstExprEmitter in CGExprConstant.cpp; if they don't match, it
3199
58.6k
  // will lead to unexpected results.  Like ConstExprEmitter, it falls back
3200
58.6k
  // to isEvaluatable most of the time.
3201
58.6k
  //
3202
58.6k
  // If we ever capture reference-binding directly in the AST, we can
3203
58.6k
  // kill the second parameter.
3204
58.6k
3205
58.6k
  if (IsForRef) {
3206
23
    EvalResult Result;
3207
23
    if (EvaluateAsLValue(Result, Ctx) && 
!Result.HasSideEffects19
)
3208
19
      return true;
3209
4
    if (Culprit)
3210
4
      *Culprit = this;
3211
4
    return false;
3212
4
  }
3213
58.6k
3214
58.6k
  switch (getStmtClass()) {
3215
11.7k
  default: break;
3216
211
  case StringLiteralClass:
3217
211
  case ObjCEncodeExprClass:
3218
211
    return true;
3219
2.98k
  case CXXTemporaryObjectExprClass:
3220
2.98k
  case CXXConstructExprClass: {
3221
2.98k
    const CXXConstructExpr *CE = cast<CXXConstructExpr>(this);
3222
2.98k
3223
2.98k
    if (CE->getConstructor()->isTrivial() &&
3224
2.98k
        
CE->getConstructor()->getParent()->hasTrivialDestructor()2.83k
) {
3225
2.83k
      // Trivial default constructor
3226
2.83k
      if (!CE->getNumArgs()) 
return true2.73k
;
3227
104
3228
104
      // Trivial copy constructor
3229
104
      assert(CE->getNumArgs() == 1 && "trivial ctor with > 1 argument");
3230
104
      return CE->getArg(0)->isConstantInitializer(Ctx, false, Culprit);
3231
104
    }
3232
151
3233
151
    break;
3234
151
  }
3235
4.81k
  case ConstantExprClass: {
3236
4.81k
    // FIXME: We should be able to return "true" here, but it can lead to extra
3237
4.81k
    // error messages. E.g. in Sema/array-init.c.
3238
4.81k
    const Expr *Exp = cast<ConstantExpr>(this)->getSubExpr();
3239
4.81k
    return Exp->isConstantInitializer(Ctx, false, Culprit);
3240
151
  }
3241
151
  case CompoundLiteralExprClass: {
3242
66
    // This handles gcc's extension that allows global initializers like
3243
66
    // "struct x {int x;} x = (struct x) {};".
3244
66
    // FIXME: This accepts other cases it shouldn't!
3245
66
    const Expr *Exp = cast<CompoundLiteralExpr>(this)->getInitializer();
3246
66
    return Exp->isConstantInitializer(Ctx, false, Culprit);
3247
151
  }
3248
151
  case DesignatedInitUpdateExprClass: {
3249
23
    const DesignatedInitUpdateExpr *DIUE = cast<DesignatedInitUpdateExpr>(this);
3250
23
    return DIUE->getBase()->isConstantInitializer(Ctx, false, Culprit) &&
3251
23
           
DIUE->getUpdater()->isConstantInitializer(Ctx, false, Culprit)17
;
3252
151
  }
3253
8.52k
  case InitListExprClass: {
3254
8.52k
    const InitListExpr *ILE = cast<InitListExpr>(this);
3255
8.52k
    assert(ILE->isSemanticForm() && "InitListExpr must be in semantic form");
3256
8.52k
    if (ILE->getType()->isArrayType()) {
3257
3.44k
      unsigned numInits = ILE->getNumInits();
3258
23.2k
      for (unsigned i = 0; i < numInits; 
i++19.8k
) {
3259
19.9k
        if (!ILE->getInit(i)->isConstantInitializer(Ctx, false, Culprit))
3260
115
          return false;
3261
19.9k
      }
3262
3.44k
      
return true3.33k
;
3263
5.07k
    }
3264
5.07k
3265
5.07k
    if (ILE->getType()->isRecordType()) {
3266
4.39k
      unsigned ElementNo = 0;
3267
4.39k
      RecordDecl *RD = ILE->getType()->castAs<RecordType>()->getDecl();
3268
9.54k
      for (const auto *Field : RD->fields()) {
3269
9.54k
        // If this is a union, skip all the fields that aren't being initialized.
3270
9.54k
        if (RD->isUnion() && 
ILE->getInitializedFieldInUnion() != Field1.08k
)
3271
537
          continue;
3272
9.00k
3273
9.00k
        // Don't emit anonymous bitfields, they just affect layout.
3274
9.00k
        if (Field->isUnnamedBitfield())
3275
60
          continue;
3276
8.94k
3277
8.94k
        if (ElementNo < ILE->getNumInits()) {
3278
8.85k
          const Expr *Elt = ILE->getInit(ElementNo++);
3279
8.85k
          if (Field->isBitField()) {
3280
187
            // Bitfields have to evaluate to an integer.
3281
187
            EvalResult Result;
3282
187
            if (!Elt->EvaluateAsInt(Result, Ctx)) {
3283
1
              if (Culprit)
3284
1
                *Culprit = Elt;
3285
1
              return false;
3286
1
            }
3287
8.67k
          } else {
3288
8.67k
            bool RefType = Field->getType()->isReferenceType();
3289
8.67k
            if (!Elt->isConstantInitializer(Ctx, RefType, Culprit))
3290
132
              return false;
3291
8.67k
          }
3292
8.85k
        }
3293
8.94k
      }
3294
4.39k
      
return true4.26k
;
3295
681
    }
3296
681
3297
681
    break;
3298
681
  }
3299
6.49k
  case ImplicitValueInitExprClass:
3300
6.49k
  case NoInitExprClass:
3301
6.49k
    return true;
3302
6.49k
  case ParenExprClass:
3303
522
    return cast<ParenExpr>(this)->getSubExpr()
3304
522
      ->isConstantInitializer(Ctx, IsForRef, Culprit);
3305
6.49k
  case GenericSelectionExprClass:
3306
3
    return cast<GenericSelectionExpr>(this)->getResultExpr()
3307
3
      ->isConstantInitializer(Ctx, IsForRef, Culprit);
3308
6.49k
  case ChooseExprClass:
3309
4
    if (cast<ChooseExpr>(this)->isConditionDependent()) {
3310
0
      if (Culprit)
3311
0
        *Culprit = this;
3312
0
      return false;
3313
0
    }
3314
4
    return cast<ChooseExpr>(this)->getChosenSubExpr()
3315
4
      ->isConstantInitializer(Ctx, IsForRef, Culprit);
3316
355
  case UnaryOperatorClass: {
3317
355
    const UnaryOperator* Exp = cast<UnaryOperator>(this);
3318
355
    if (Exp->getOpcode() == UO_Extension)
3319
8
      return Exp->getSubExpr()->isConstantInitializer(Ctx, false, Culprit);
3320
347
    break;
3321
347
  }
3322
22.8k
  case CXXFunctionalCastExprClass:
3323
22.8k
  case CXXStaticCastExprClass:
3324
22.8k
  case ImplicitCastExprClass:
3325
22.8k
  case CStyleCastExprClass:
3326
22.8k
  case ObjCBridgedCastExprClass:
3327
22.8k
  case CXXDynamicCastExprClass:
3328
22.8k
  case CXXReinterpretCastExprClass:
3329
22.8k
  case CXXConstCastExprClass: {
3330
22.8k
    const CastExpr *CE = cast<CastExpr>(this);
3331
22.8k
3332
22.8k
    // Handle misc casts we want to ignore.
3333
22.8k
    if (CE->getCastKind() == CK_NoOp ||
3334
22.8k
        
CE->getCastKind() == CK_LValueToRValue22.4k
||
3335
22.8k
        
CE->getCastKind() == CK_ToUnion21.0k
||
3336
22.8k
        
CE->getCastKind() == CK_ConstructorConversion21.0k
||
3337
22.8k
        
CE->getCastKind() == CK_NonAtomicToAtomic21.0k
||
3338
22.8k
        
CE->getCastKind() == CK_AtomicToNonAtomic20.9k
||
3339
22.8k
        
CE->getCastKind() == CK_IntToOCLSampler20.9k
)
3340
1.95k
      return CE->getSubExpr()->isConstantInitializer(Ctx, false, Culprit);
3341
20.9k
3342
20.9k
    break;
3343
20.9k
  }
3344
20.9k
  case MaterializeTemporaryExprClass:
3345
0
    return cast<MaterializeTemporaryExpr>(this)
3346
0
        ->getSubExpr()
3347
0
        ->isConstantInitializer(Ctx, false, Culprit);
3348
20.9k
3349
20.9k
  case SubstNonTypeTemplateParmExprClass:
3350
2
    return cast<SubstNonTypeTemplateParmExpr>(this)->getReplacement()
3351
2
      ->isConstantInitializer(Ctx, false, Culprit);
3352
20.9k
  case CXXDefaultArgExprClass:
3353
0
    return cast<CXXDefaultArgExpr>(this)->getExpr()
3354
0
      ->isConstantInitializer(Ctx, false, Culprit);
3355
20.9k
  case CXXDefaultInitExprClass:
3356
0
    return cast<CXXDefaultInitExpr>(this)->getExpr()
3357
0
      ->isConstantInitializer(Ctx, false, Culprit);
3358
33.8k
  }
3359
33.8k
  // Allow certain forms of UB in constant initializers: signed integer
3360
33.8k
  // overflow and floating-point division by zero. We'll give a warning on
3361
33.8k
  // these, but they're common enough that we have to accept them.
3362
33.8k
  if (isEvaluatable(Ctx, SE_AllowUndefinedBehavior))
3363
32.1k
    return true;
3364
1.72k
  if (Culprit)
3365
95
    *Culprit = this;
3366
1.72k
  return false;
3367
1.72k
}
3368
3369
156k
bool CallExpr::isBuiltinAssumeFalse(const ASTContext &Ctx) const {
3370
156k
  const FunctionDecl* FD = getDirectCallee();
3371
156k
  if (!FD || (FD->getBuiltinID() != Builtin::BI__assume &&
3372
156k
              FD->getBuiltinID() != Builtin::BI__builtin_assume))
3373
156k
    return false;
3374
55
3375
55
  const Expr* Arg = getArg(0);
3376
55
  bool ArgVal;
3377
55
  return !Arg->isValueDependent() &&
3378
55
         Arg->EvaluateAsBooleanCondition(ArgVal, Ctx) && 
!ArgVal21
;
3379
55
}
3380
3381
namespace {
3382
  /// Look for any side effects within a Stmt.
3383
  class SideEffectFinder : public ConstEvaluatedExprVisitor<SideEffectFinder> {
3384
    typedef ConstEvaluatedExprVisitor<SideEffectFinder> Inherited;
3385
    const bool IncludePossibleEffects;
3386
    bool HasSideEffects;
3387
3388
  public:
3389
    explicit SideEffectFinder(const ASTContext &Context, bool IncludePossible)
3390
      : Inherited(Context),
3391
21
        IncludePossibleEffects(IncludePossible), HasSideEffects(false) { }
3392
3393
21
    bool hasSideEffects() const { return HasSideEffects; }
3394
3395
40
    void VisitExpr(const Expr *E) {
3396
40
      if (!HasSideEffects &&
3397
40
          
E->HasSideEffects(Context, IncludePossibleEffects)34
)
3398
10
        HasSideEffects = true;
3399
40
    }
3400
  };
3401
}
3402
3403
bool Expr::HasSideEffects(const ASTContext &Ctx,
3404
592k
                          bool IncludePossibleEffects) const {
3405
592k
  // In circumstances where we care about definite side effects instead of
3406
592k
  // potential side effects, we want to ignore expressions that are part of a
3407
592k
  // macro expansion as a potential side effect.
3408
592k
  if (!IncludePossibleEffects && 
getExprLoc().isMacroID()69.6k
)
3409
27.5k
    return false;
3410
564k
3411
564k
  if (isInstantiationDependent())
3412
26.0k
    return IncludePossibleEffects;
3413
538k
3414
538k
  switch (getStmtClass()) {
3415
0
  case NoStmtClass:
3416
0
  #define ABSTRACT_STMT(Type)
3417
0
  #define STMT(Type, Base) case Type##Class:
3418
0
  #define EXPR(Type, Base)
3419
0
  #include "clang/AST/StmtNodes.inc"
3420
0
    llvm_unreachable("unexpected Expr kind");
3421
0
3422
0
  case DependentScopeDeclRefExprClass:
3423
0
  case CXXUnresolvedConstructExprClass:
3424
0
  case CXXDependentScopeMemberExprClass:
3425
0
  case UnresolvedLookupExprClass:
3426
0
  case UnresolvedMemberExprClass:
3427
0
  case PackExpansionExprClass:
3428
0
  case SubstNonTypeTemplateParmPackExprClass:
3429
0
  case FunctionParmPackExprClass:
3430
0
  case TypoExprClass:
3431
0
  case CXXFoldExprClass:
3432
0
    llvm_unreachable("shouldn't see dependent / unresolved nodes here");
3433
0
3434
197k
  case DeclRefExprClass:
3435
197k
  case ObjCIvarRefExprClass:
3436
197k
  case PredefinedExprClass:
3437
197k
  case IntegerLiteralClass:
3438
197k
  case FixedPointLiteralClass:
3439
197k
  case FloatingLiteralClass:
3440
197k
  case ImaginaryLiteralClass:
3441
197k
  case StringLiteralClass:
3442
197k
  case CharacterLiteralClass:
3443
197k
  case OffsetOfExprClass:
3444
197k
  case ImplicitValueInitExprClass:
3445
197k
  case UnaryExprOrTypeTraitExprClass:
3446
197k
  case AddrLabelExprClass:
3447
197k
  case GNUNullExprClass:
3448
197k
  case ArrayInitIndexExprClass:
3449
197k
  case NoInitExprClass:
3450
197k
  case CXXBoolLiteralExprClass:
3451
197k
  case CXXNullPtrLiteralExprClass:
3452
197k
  case CXXThisExprClass:
3453
197k
  case CXXScalarValueInitExprClass:
3454
197k
  case TypeTraitExprClass:
3455
197k
  case ArrayTypeTraitExprClass:
3456
197k
  case ExpressionTraitExprClass:
3457
197k
  case CXXNoexceptExprClass:
3458
197k
  case SizeOfPackExprClass:
3459
197k
  case ObjCStringLiteralClass:
3460
197k
  case ObjCEncodeExprClass:
3461
197k
  case ObjCBoolLiteralExprClass:
3462
197k
  case ObjCAvailabilityCheckExprClass:
3463
197k
  case CXXUuidofExprClass:
3464
197k
  case OpaqueValueExprClass:
3465
197k
  case SourceLocExprClass:
3466
197k
  case ConceptSpecializationExprClass:
3467
197k
  case RequiresExprClass:
3468
197k
    // These never have a side-effect.
3469
197k
    return false;
3470
197k
3471
197k
  case ConstantExprClass:
3472
11.4k
    // FIXME: Move this into the "return false;" block above.
3473
11.4k
    return cast<ConstantExpr>(this)->getSubExpr()->HasSideEffects(
3474
11.4k
        Ctx, IncludePossibleEffects);
3475
197k
3476
197k
  case CallExprClass:
3477
11.1k
  case CXXOperatorCallExprClass:
3478
11.1k
  case CXXMemberCallExprClass:
3479
11.1k
  case CUDAKernelCallExprClass:
3480
11.1k
  case UserDefinedLiteralClass: {
3481
11.1k
    // We don't know a call definitely has side effects, except for calls
3482
11.1k
    // to pure/const functions that definitely don't.
3483
11.1k
    // If the call itself is considered side-effect free, check the operands.
3484
11.1k
    const Decl *FD = cast<CallExpr>(this)->getCalleeDecl();
3485
11.1k
    bool IsPure = FD && 
(11.1k
FD->hasAttr<ConstAttr>()11.1k
||
FD->hasAttr<PureAttr>()11.0k
);
3486
11.1k
    if (IsPure || 
!IncludePossibleEffects11.0k
)
3487
783
      break;
3488
10.4k
    return true;
3489
10.4k
  }
3490
10.4k
3491
10.4k
  case BlockExprClass:
3492
210
  case CXXBindTemporaryExprClass:
3493
210
    if (!IncludePossibleEffects)
3494
139
      break;
3495
71
    return true;
3496
71
3497
1.26k
  case MSPropertyRefExprClass:
3498
1.26k
  case MSPropertySubscriptExprClass:
3499
1.26k
  case CompoundAssignOperatorClass:
3500
1.26k
  case VAArgExprClass:
3501
1.26k
  case AtomicExprClass:
3502
1.26k
  case CXXThrowExprClass:
3503
1.26k
  case CXXNewExprClass:
3504
1.26k
  case CXXDeleteExprClass:
3505
1.26k
  case CoawaitExprClass:
3506
1.26k
  case DependentCoawaitExprClass:
3507
1.26k
  case CoyieldExprClass:
3508
1.26k
    // These always have a side-effect.
3509
1.26k
    return true;
3510
1.26k
3511
1.26k
  case StmtExprClass: {
3512
21
    // StmtExprs have a side-effect if any substatement does.
3513
21
    SideEffectFinder Finder(Ctx, IncludePossibleEffects);
3514
21
    Finder.Visit(cast<StmtExpr>(this)->getSubStmt());
3515
21
    return Finder.hasSideEffects();
3516
1.26k
  }
3517
1.26k
3518
11.7k
  case ExprWithCleanupsClass:
3519
11.7k
    if (IncludePossibleEffects)
3520
11.7k
      if (cast<ExprWithCleanups>(this)->cleanupsHaveSideEffects())
3521
246
        return true;
3522
11.5k
    break;
3523
11.5k
3524
63.3k
  case ParenExprClass:
3525
63.3k
  case ArraySubscriptExprClass:
3526
63.3k
  case OMPArraySectionExprClass:
3527
63.3k
  case MemberExprClass:
3528
63.3k
  case ConditionalOperatorClass:
3529
63.3k
  case BinaryConditionalOperatorClass:
3530
63.3k
  case CompoundLiteralExprClass:
3531
63.3k
  case ExtVectorElementExprClass:
3532
63.3k
  case DesignatedInitExprClass:
3533
63.3k
  case DesignatedInitUpdateExprClass:
3534
63.3k
  case ArrayInitLoopExprClass:
3535
63.3k
  case ParenListExprClass:
3536
63.3k
  case CXXPseudoDestructorExprClass:
3537
63.3k
  case CXXRewrittenBinaryOperatorClass:
3538
63.3k
  case CXXStdInitializerListExprClass:
3539
63.3k
  case SubstNonTypeTemplateParmExprClass:
3540
63.3k
  case MaterializeTemporaryExprClass:
3541
63.3k
  case ShuffleVectorExprClass:
3542
63.3k
  case ConvertVectorExprClass:
3543
63.3k
  case AsTypeExprClass:
3544
63.3k
    // These have a side-effect if any subexpression does.
3545
63.3k
    break;
3546
63.3k
3547
63.3k
  case UnaryOperatorClass:
3548
9.30k
    if (cast<UnaryOperator>(this)->isIncrementDecrementOp())
3549
356
      return true;
3550
8.95k
    break;
3551
8.95k
3552
13.8k
  case BinaryOperatorClass:
3553
13.8k
    if (cast<BinaryOperator>(this)->isAssignmentOp())
3554
623
      return true;
3555
13.2k
    break;
3556
13.2k
3557
16.9k
  case InitListExprClass:
3558
16.9k
    // FIXME: The children for an InitListExpr doesn't include the array filler.
3559
16.9k
    if (const Expr *E = cast<InitListExpr>(this)->getArrayFiller())
3560
542
      if (E->HasSideEffects(Ctx, IncludePossibleEffects))
3561
4
        return true;
3562
16.9k
    break;
3563
16.9k
3564
16.9k
  case GenericSelectionExprClass:
3565
1
    return cast<GenericSelectionExpr>(this)->getResultExpr()->
3566
1
        HasSideEffects(Ctx, IncludePossibleEffects);
3567
16.9k
3568
16.9k
  case ChooseExprClass:
3569
4
    return cast<ChooseExpr>(this)->getChosenSubExpr()->HasSideEffects(
3570
4
        Ctx, IncludePossibleEffects);
3571
16.9k
3572
16.9k
  case CXXDefaultArgExprClass:
3573
3
    return cast<CXXDefaultArgExpr>(this)->getExpr()->HasSideEffects(
3574
3
        Ctx, IncludePossibleEffects);
3575
16.9k
3576
16.9k
  case CXXDefaultInitExprClass: {
3577
1.48k
    const FieldDecl *FD = cast<CXXDefaultInitExpr>(this)->getField();
3578
1.48k
    if (const Expr *E = FD->getInClassInitializer())
3579
1.48k
      return E->HasSideEffects(Ctx, IncludePossibleEffects);
3580
0
    // If we've not yet parsed the initializer, assume it has side-effects.
3581
0
    return true;
3582
0
  }
3583
0
3584
71
  case CXXDynamicCastExprClass: {
3585
71
    // A dynamic_cast expression has side-effects if it can throw.
3586
71
    const CXXDynamicCastExpr *DCE = cast<CXXDynamicCastExpr>(this);
3587
71
    if (DCE->getTypeAsWritten()->isReferenceType() &&
3588
71
        
DCE->getCastKind() == CK_Dynamic22
)
3589
22
      return true;
3590
49
    }
3591
49
    LLVM_FALLTHROUGH;
3592
166k
  case ImplicitCastExprClass:
3593
166k
  case CStyleCastExprClass:
3594
166k
  case CXXStaticCastExprClass:
3595
166k
  case CXXReinterpretCastExprClass:
3596
166k
  case CXXConstCastExprClass:
3597
166k
  case CXXFunctionalCastExprClass:
3598
166k
  case BuiltinBitCastExprClass: {
3599
166k
    // While volatile reads are side-effecting in both C and C++, we treat them
3600
166k
    // as having possible (not definite) side-effects. This allows idiomatic
3601
166k
    // code to behave without warning, such as sizeof(*v) for a volatile-
3602
166k
    // qualified pointer.
3603
166k
    if (!IncludePossibleEffects)
3604
2.21k
      break;
3605
164k
3606
164k
    const CastExpr *CE = cast<CastExpr>(this);
3607
164k
    if (CE->getCastKind() == CK_LValueToRValue &&
3608
164k
        
CE->getSubExpr()->getType().isVolatileQualified()69.8k
)
3609
1.14k
      return true;
3610
163k
    break;
3611
163k
  }
3612
163k
3613
163k
  case CXXTypeidExprClass:
3614
42
    // typeid might throw if its subexpression is potentially-evaluated, so has
3615
42
    // side-effects in that case whether or not its subexpression does.
3616
42
    return cast<CXXTypeidExpr>(this)->isPotentiallyEvaluated();
3617
163k
3618
163k
  case CXXConstructExprClass:
3619
32.4k
  case CXXTemporaryObjectExprClass: {
3620
32.4k
    const CXXConstructExpr *CE = cast<CXXConstructExpr>(this);
3621
32.4k
    if (!CE->getConstructor()->isTrivial() && 
IncludePossibleEffects13.4k
)
3622
13.2k
      return true;
3623
19.1k
    // A trivial constructor does not add any side-effects of its own. Just look
3624
19.1k
    // at its arguments.
3625
19.1k
    break;
3626
19.1k
  }
3627
19.1k
3628
19.1k
  case CXXInheritedCtorInitExprClass: {
3629
0
    const auto *ICIE = cast<CXXInheritedCtorInitExpr>(this);
3630
0
    if (!ICIE->getConstructor()->isTrivial() && IncludePossibleEffects)
3631
0
      return true;
3632
0
    break;
3633
0
  }
3634
0
3635
946
  case LambdaExprClass: {
3636
946
    const LambdaExpr *LE = cast<LambdaExpr>(this);
3637
946
    for (Expr *E : LE->capture_inits())
3638
88
      if (E->HasSideEffects(Ctx, IncludePossibleEffects))
3639
6
        return true;
3640
946
    
return false940
;
3641
946
  }
3642
946
3643
946
  case PseudoObjectExprClass: {
3644
15
    // Only look for side-effects in the semantic form, and look past
3645
15
    // OpaqueValueExpr bindings in that form.
3646
15
    const PseudoObjectExpr *PO = cast<PseudoObjectExpr>(this);
3647
15
    for (PseudoObjectExpr::const_semantics_iterator I = PO->semantics_begin(),
3648
15
                                                    E = PO->semantics_end();
3649
41
         I != E; 
++I26
) {
3650
28
      const Expr *Subexpr = *I;
3651
28
      if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(Subexpr))
3652
13
        Subexpr = OVE->getSourceExpr();
3653
28
      if (Subexpr->HasSideEffects(Ctx, IncludePossibleEffects))
3654
2
        return true;
3655
28
    }
3656
15
    
return false13
;
3657
15
  }
3658
15
3659
58
  case ObjCBoxedExprClass:
3660
58
  case ObjCArrayLiteralClass:
3661
58
  case ObjCDictionaryLiteralClass:
3662
58
  case ObjCSelectorExprClass:
3663
58
  case ObjCProtocolExprClass:
3664
58
  case ObjCIsaExprClass:
3665
58
  case ObjCIndirectCopyRestoreExprClass:
3666
58
  case ObjCSubscriptRefExprClass:
3667
58
  case ObjCBridgedCastExprClass:
3668
58
  case ObjCMessageExprClass:
3669
58
  case ObjCPropertyRefExprClass:
3670
58
  // FIXME: Classify these cases better.
3671
58
    if (IncludePossibleEffects)
3672
39
      return true;
3673
19
    break;
3674
299k
  }
3675
299k
3676
299k
  // Recurse to children.
3677
299k
  for (const Stmt *SubStmt : children())
3678
337k
    if (SubStmt &&
3679
337k
        
cast<Expr>(SubStmt)->HasSideEffects(Ctx, IncludePossibleEffects)337k
)
3680
14.7k
      return true;
3681
299k
3682
299k
  
return false285k
;
3683
299k
}
3684
3685
namespace {
3686
  /// Look for a call to a non-trivial function within an expression.
3687
  class NonTrivialCallFinder : public ConstEvaluatedExprVisitor<NonTrivialCallFinder>
3688
  {
3689
    typedef ConstEvaluatedExprVisitor<NonTrivialCallFinder> Inherited;
3690
3691
    bool NonTrivial;
3692
3693
  public:
3694
    explicit NonTrivialCallFinder(const ASTContext &Context)
3695
3.23k
      : Inherited(Context), NonTrivial(false) { }
3696
3697
3.23k
    bool hasNonTrivialCall() const { return NonTrivial; }
3698
3699
352
    void VisitCallExpr(const CallExpr *E) {
3700
352
      if (const CXXMethodDecl *Method
3701
246
          = dyn_cast_or_null<const CXXMethodDecl>(E->getCalleeDecl())) {
3702
246
        if (Method->isTrivial()) {
3703
164
          // Recurse to children of the call.
3704
164
          Inherited::VisitStmt(E);
3705
164
          return;
3706
164
        }
3707
188
      }
3708
188
3709
188
      NonTrivial = true;
3710
188
    }
3711
3712
224
    void VisitCXXConstructExpr(const CXXConstructExpr *E) {
3713
224
      if (E->getConstructor()->isTrivial()) {
3714
184
        // Recurse to children of the call.
3715
184
        Inherited::VisitStmt(E);
3716
184
        return;
3717
184
      }
3718
40
3719
40
      NonTrivial = true;
3720
40
    }
3721
3722
119
    void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *E) {
3723
119
      if (E->getTemporary()->getDestructor()->isTrivial()) {
3724
0
        Inherited::VisitStmt(E);
3725
0
        return;
3726
0
      }
3727
119
3728
119
      NonTrivial = true;
3729
119
    }
3730
  };
3731
}
3732
3733
3.23k
bool Expr::hasNonTrivialCall(const ASTContext &Ctx) const {
3734
3.23k
  NonTrivialCallFinder Finder(Ctx);
3735
3.23k
  Finder.Visit(this);
3736
3.23k
  return Finder.hasNonTrivialCall();
3737
3.23k
}
3738
3739
/// isNullPointerConstant - C99 6.3.2.3p3 - Return whether this is a null
3740
/// pointer constant or not, as well as the specific kind of constant detected.
3741
/// Null pointer constants can be integer constant expressions with the
3742
/// value zero, casts of zero to void*, nullptr (C++0X), or __null
3743
/// (a GNU extension).
3744
Expr::NullPointerConstantKind
3745
Expr::isNullPointerConstant(ASTContext &Ctx,
3746
2.39M
                            NullPointerConstantValueDependence NPC) const {
3747
2.39M
  if (isValueDependent() &&
3748
2.39M
      
(18.8k
!Ctx.getLangOpts().CPlusPlus1118.8k
||
Ctx.getLangOpts().MSVCCompat18.8k
)) {
3749
21
    switch (NPC) {
3750
0
    case NPC_NeverValueDependent:
3751
0
      llvm_unreachable("Unexpected value dependent expression!");
3752
17
    case NPC_ValueDependentIsNull:
3753
17
      if (isTypeDependent() || getType()->isIntegralType(Ctx))
3754
7
        return NPCK_ZeroExpression;
3755
10
      else
3756
10
        return NPCK_NotNull;
3757
0
3758
4
    case NPC_ValueDependentIsNotNull:
3759
4
      return NPCK_NotNull;
3760
2.39M
    }
3761
2.39M
  }
3762
2.39M
3763
2.39M
  // Strip off a cast to void*, if it exists. Except in C++.
3764
2.39M
  if (const ExplicitCastExpr *CE = dyn_cast<ExplicitCastExpr>(this)) {
3765
144k
    if (!Ctx.getLangOpts().CPlusPlus) {
3766
122k
      // Check that it is a cast to void*.
3767
122k
      if (const PointerType *PT = CE->getType()->getAs<PointerType>()) {
3768
120k
        QualType Pointee = PT->getPointeeType();
3769
120k
        Qualifiers Qs = Pointee.getQualifiers();
3770
120k
        // Only (void*)0 or equivalent are treated as nullptr. If pointee type
3771
120k
        // has non-default address space it is not treated as nullptr.
3772
120k
        // (__generic void*)0 in OpenCL 2.0 should not be treated as nullptr
3773
120k
        // since it cannot be assigned to a pointer to constant address space.
3774
120k
        if ((Ctx.getLangOpts().OpenCLVersion >= 200 &&
3775
120k
             
Pointee.getAddressSpace() == LangAS::opencl_generic1.30k
) ||
3776
120k
            
(120k
Ctx.getLangOpts().OpenCL120k
&&
3777
120k
             
Ctx.getLangOpts().OpenCLVersion < 2002.72k
&&
3778
120k
             
Pointee.getAddressSpace() == LangAS::opencl_private1.94k
))
3779
892
          Qs.removeAddressSpace();
3780
120k
3781
120k
        if (Pointee->isVoidType() && 
Qs.empty()6.78k
&& // to void*
3782
120k
            
CE->getSubExpr()->getType()->isIntegerType()6.30k
) // from int
3783
5.39k
          return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3784
2.25M
      }
3785
122k
    }
3786
2.25M
  } else if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(this)) {
3787
121k
    // Ignore the ImplicitCastExpr type entirely.
3788
121k
    return ICE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3789
2.13M
  } else if (const ParenExpr *PE = dyn_cast<ParenExpr>(this)) {
3790
26.5k
    // Accept ((void*)0) as a null pointer constant, as many other
3791
26.5k
    // implementations do.
3792
26.5k
    return PE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3793
2.10M
  } else if (const GenericSelectionExpr *GE =
3794
1
               dyn_cast<GenericSelectionExpr>(this)) {
3795
1
    if (GE->isResultDependent())
3796
0
      return NPCK_NotNull;
3797
1
    return GE->getResultExpr()->isNullPointerConstant(Ctx, NPC);
3798
2.10M
  } else if (const ChooseExpr *CE = dyn_cast<ChooseExpr>(this)) {
3799
1
    if (CE->isConditionDependent())
3800
0
      return NPCK_NotNull;
3801
1
    return CE->getChosenSubExpr()->isNullPointerConstant(Ctx, NPC);
3802
2.10M
  } else if (const CXXDefaultArgExpr *DefaultArg
3803
96
               = dyn_cast<CXXDefaultArgExpr>(this)) {
3804
96
    // See through default argument expressions.
3805
96
    return DefaultArg->getExpr()->isNullPointerConstant(Ctx, NPC);
3806
2.10M
  } else if (const CXXDefaultInitExpr *DefaultInit
3807
0
               = dyn_cast<CXXDefaultInitExpr>(this)) {
3808
0
    // See through default initializer expressions.
3809
0
    return DefaultInit->getExpr()->isNullPointerConstant(Ctx, NPC);
3810
2.10M
  } else if (isa<GNUNullExpr>(this)) {
3811
7.98k
    // The GNU __null extension is always a null pointer constant.
3812
7.98k
    return NPCK_GNUNull;
3813
2.09M
  } else if (const MaterializeTemporaryExpr *M
3814
4
                                   = dyn_cast<MaterializeTemporaryExpr>(this)) {
3815
4
    return M->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3816
2.09M
  } else if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(this)) {
3817
2.09k
    if (const Expr *Source = OVE->getSourceExpr())
3818
1.64k
      return Source->isNullPointerConstant(Ctx, NPC);
3819
2.23M
  }
3820
2.23M
3821
2.23M
  // C++11 nullptr_t is always a null pointer constant.
3822
2.23M
  if (getType()->isNullPtrType())
3823
34.8k
    return NPCK_CXX11_nullptr;
3824
2.19M
3825
2.19M
  if (const RecordType *UT = getType()->getAsUnionType())
3826
6
    if (!Ctx.getLangOpts().CPlusPlus11 &&
3827
6
        UT && UT->getDecl()->hasAttr<TransparentUnionAttr>())
3828
6
      if (const CompoundLiteralExpr *CLE = dyn_cast<CompoundLiteralExpr>(this)){
3829
0
        const Expr *InitExpr = CLE->getInitializer();
3830
0
        if (const InitListExpr *ILE = dyn_cast<InitListExpr>(InitExpr))
3831
0
          return ILE->getInit(0)->isNullPointerConstant(Ctx, NPC);
3832
2.19M
      }
3833
2.19M
  // This expression must be an integer type.
3834
2.19M
  if (!getType()->isIntegerType() ||
3835
2.19M
      
(587k
Ctx.getLangOpts().CPlusPlus587k
&&
getType()->isEnumeralType()479k
))
3836
1.61M
    return NPCK_NotNull;
3837
585k
3838
585k
  if (Ctx.getLangOpts().CPlusPlus11) {
3839
435k
    // C++11 [conv.ptr]p1: A null pointer constant is an integer literal with
3840
435k
    // value zero or a prvalue of type std::nullptr_t.
3841
435k
    // Microsoft mode permits C++98 rules reflecting MSVC behavior.
3842
435k
    const IntegerLiteral *Lit = dyn_cast<IntegerLiteral>(this);
3843
435k
    if (Lit && 
!Lit->getValue()244k
)
3844
176k
      return NPCK_ZeroLiteral;
3845
258k
    else if (!Ctx.getLangOpts().MSVCCompat || 
!isCXX98IntegralConstantExpr(Ctx)396
)
3846
258k
      return NPCK_NotNull;
3847
149k
  } else {
3848
149k
    // If we have an integer constant expression, we need to *evaluate* it and
3849
149k
    // test for the value 0.
3850
149k
    if (!isIntegerConstantExpr(Ctx))
3851
77.2k
      return NPCK_NotNull;
3852
72.7k
  }
3853
72.7k
3854
72.7k
  if (EvaluateKnownConstInt(Ctx) != 0)
3855
28.3k
    return NPCK_NotNull;
3856
44.4k
3857
44.4k
  if (isa<IntegerLiteral>(this))
3858
42.9k
    return NPCK_ZeroLiteral;
3859
1.50k
  return NPCK_ZeroExpression;
3860
1.50k
}
3861
3862
/// If this expression is an l-value for an Objective C
3863
/// property, find the underlying property reference expression.
3864
0
const ObjCPropertyRefExpr *Expr::getObjCProperty() const {
3865
0
  const Expr *E = this;
3866
0
  while (true) {
3867
0
    assert((E->getValueKind() == VK_LValue &&
3868
0
            E->getObjectKind() == OK_ObjCProperty) &&
3869
0
           "expression is not a property reference");
3870
0
    E = E->IgnoreParenCasts();
3871
0
    if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
3872
0
      if (BO->getOpcode() == BO_Comma) {
3873
0
        E = BO->getRHS();
3874
0
        continue;
3875
0
      }
3876
0
    }
3877
0
3878
0
    break;
3879
0
  }
3880
0
3881
0
  return cast<ObjCPropertyRefExpr>(E);
3882
0
}
3883
3884
356
bool Expr::isObjCSelfExpr() const {
3885
356
  const Expr *E = IgnoreParenImpCasts();
3886
356
3887
356
  const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E);
3888
356
  if (!DRE)
3889
140
    return false;
3890
216
3891
216
  const ImplicitParamDecl *Param = dyn_cast<ImplicitParamDecl>(DRE->getDecl());
3892
216
  if (!Param)
3893
101
    return false;
3894
115
3895
115
  const ObjCMethodDecl *M = dyn_cast<ObjCMethodDecl>(Param->getDeclContext());
3896
115
  if (!M)
3897
0
    return false;
3898
115
3899
115
  return M->getSelfDecl() == Param;
3900
115
}
3901
3902
12.1M
FieldDecl *Expr::getSourceBitField() {
3903
12.1M
  Expr *E = this->IgnoreParens();
3904
12.1M
3905
14.4M
  while (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {
3906
2.35M
    if (ICE->getCastKind() == CK_LValueToRValue ||
3907
2.35M
        
(28.7k
ICE->getValueKind() != VK_RValue28.7k
&&
ICE->getCastKind() == CK_NoOp47
))
3908
2.32M
      E = ICE->getSubExpr()->IgnoreParens();
3909
28.7k
    else
3910
28.7k
      break;
3911
2.35M
  }
3912
12.1M
3913
12.1M
  if (MemberExpr *MemRef = dyn_cast<MemberExpr>(E))
3914
179k
    if (FieldDecl *Field = dyn_cast<FieldDecl>(MemRef->getMemberDecl()))
3915
179k
      if (Field->isBitField())
3916
3.64k
        return Field;
3917
12.1M
3918
12.1M
  if (ObjCIvarRefExpr *IvarRef = dyn_cast<ObjCIvarRefExpr>(E)) {
3919
1.51k
    FieldDecl *Ivar = IvarRef->getDecl();
3920
1.51k
    if (Ivar->isBitField())
3921
157
      return Ivar;
3922
12.1M
  }
3923
12.1M
3924
12.1M
  if (DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E)) {
3925
4.06M
    if (FieldDecl *Field = dyn_cast<FieldDecl>(DeclRef->getDecl()))
3926
15
      if (Field->isBitField())
3927
0
        return Field;
3928
4.06M
3929
4.06M
    if (BindingDecl *BD = dyn_cast<BindingDecl>(DeclRef->getDecl()))
3930
236
      if (Expr *E = BD->getBinding())
3931
236
        return E->getSourceBitField();
3932
12.1M
  }
3933
12.1M
3934
12.1M
  if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(E)) {
3935
1.67M
    if (BinOp->isAssignmentOp() && 
BinOp->getLHS()940
)
3936
940
      return BinOp->getLHS()->getSourceBitField();
3937
1.67M
3938
1.67M
    if (BinOp->getOpcode() == BO_Comma && 
BinOp->getRHS()118
)
3939
118
      return BinOp->getRHS()->getSourceBitField();
3940
12.1M
  }
3941
12.1M
3942
12.1M
  if (UnaryOperator *UnOp = dyn_cast<UnaryOperator>(E))
3943
86.5k
    if (UnOp->isPrefix() && 
UnOp->isIncrementDecrementOp()2.75k
)
3944
2.75k
      return UnOp->getSubExpr()->getSourceBitField();
3945
12.1M
3946
12.1M
  return nullptr;
3947
12.1M
}
3948
3949
304k
bool Expr::refersToVectorElement() const {
3950
304k
  // FIXME: Why do we not just look at the ObjectKind here?
3951
304k
  const Expr *E = this->IgnoreParens();
3952
304k
3953
309k
  while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {
3954
11.6k
    if (ICE->getValueKind() != VK_RValue &&
3955
11.6k
        ICE->getCastKind() == CK_NoOp)
3956
4.81k
      E = ICE->getSubExpr()->IgnoreParens();
3957
6.80k
    else
3958
6.80k
      break;
3959
11.6k
  }
3960
304k
3961
304k
  if (const ArraySubscriptExpr *ASE = dyn_cast<ArraySubscriptExpr>(E))
3962
2.27k
    return ASE->getBase()->getType()->isVectorType();
3963
301k
3964
301k
  if (isa<ExtVectorElementExpr>(E))
3965
6
    return true;
3966
301k
3967
301k
  if (auto *DRE = dyn_cast<DeclRefExpr>(E))
3968
166k
    if (auto *BD = dyn_cast<BindingDecl>(DRE->getDecl()))
3969
1
      if (auto *E = BD->getBinding())
3970
1
        return E->refersToVectorElement();
3971
301k
3972
301k
  return false;
3973
301k
}
3974
3975
886
bool Expr::refersToGlobalRegisterVar() const {
3976
886
  const Expr *E = this->IgnoreParenImpCasts();
3977
886
3978
886
  if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
3979
606
    if (const auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
3980
606
      if (VD->getStorageClass() == SC_Register &&
3981
606
          
VD->hasAttr<AsmLabelAttr>()145
&&
!VD->isLocalVarDecl()2
)
3982
2
        return true;
3983
884
3984
884
  return false;
3985
884
}
3986
3987
484k
bool Expr::isSameComparisonOperand(const Expr* E1, const Expr* E2) {
3988
484k
  E1 = E1->IgnoreParens();
3989
484k
  E2 = E2->IgnoreParens();
3990
484k
3991
484k
  if (E1->getStmtClass() != E2->getStmtClass())
3992
252k
    return false;
3993
231k
3994
231k
  switch (E1->getStmtClass()) {
3995
56.5k
    default:
3996
56.5k
      return false;
3997
9
    case CXXThisExprClass:
3998
9
      return true;
3999
4.44k
    case DeclRefExprClass: {
4000
4.44k
      // DeclRefExpr without an ImplicitCastExpr can happen for integral
4001
4.44k
      // template parameters.
4002
4.44k
      const auto *DRE1 = cast<DeclRefExpr>(E1);
4003
4.44k
      const auto *DRE2 = cast<DeclRefExpr>(E2);
4004
4.44k
      return DRE1->isRValue() && 
DRE2->isRValue()4.07k
&&
4005
4.44k
             
DRE1->getDecl() == DRE2->getDecl()4.07k
;
4006
0
    }
4007
170k
    case ImplicitCastExprClass: {
4008
170k
      // Peel off implicit casts.
4009
171k
      while (true) {
4010
171k
        const auto *ICE1 = dyn_cast<ImplicitCastExpr>(E1);
4011
171k
        const auto *ICE2 = dyn_cast<ImplicitCastExpr>(E2);
4012
171k
        if (!ICE1 || 
!ICE2170k
)
4013
1.18k
          return false;
4014
170k
        if (ICE1->getCastKind() != ICE2->getCastKind())
4015
959
          return false;
4016
169k
        E1 = ICE1->getSubExpr()->IgnoreParens();
4017
169k
        E2 = ICE2->getSubExpr()->IgnoreParens();
4018
169k
        // The final cast must be one of these types.
4019
169k
        if (ICE1->getCastKind() == CK_LValueToRValue ||
4020
169k
            
ICE1->getCastKind() == CK_ArrayToPointerDecay1.43k
||
4021
169k
            
ICE1->getCastKind() == CK_FunctionToPointerDecay1.22k
) {
4022
168k
          break;
4023
168k
        }
4024
169k
      }
4025
170k
4026
170k
      const auto *DRE1 = dyn_cast<DeclRefExpr>(E1);
4027
168k
      const auto *DRE2 = dyn_cast<DeclRefExpr>(E2);
4028
168k
      if (DRE1 && 
DRE2160k
)
4029
155k
        return declaresSameEntity(DRE1->getDecl(), DRE2->getDecl());
4030
12.2k
4031
12.2k
      const auto *Ivar1 = dyn_cast<ObjCIvarRefExpr>(E1);
4032
12.2k
      const auto *Ivar2 = dyn_cast<ObjCIvarRefExpr>(E2);
4033
12.2k
      if (Ivar1 && 
Ivar217
) {
4034
8
        return Ivar1->isFreeIvar() && 
Ivar2->isFreeIvar()7
&&
4035
8
               
declaresSameEntity(Ivar1->getDecl(), Ivar2->getDecl())7
;
4036
8
      }
4037
12.2k
4038
12.2k
      const auto *Array1 = dyn_cast<ArraySubscriptExpr>(E1);
4039
12.2k
      const auto *Array2 = dyn_cast<ArraySubscriptExpr>(E2);
4040
12.2k
      if (Array1 && 
Array2301
) {
4041
289
        if (!isSameComparisonOperand(Array1->getBase(), Array2->getBase()))
4042
206
          return false;
4043
83
4044
83
        auto Idx1 = Array1->getIdx();
4045
83
        auto Idx2 = Array2->getIdx();
4046
83
        const auto Integer1 = dyn_cast<IntegerLiteral>(Idx1);
4047
83
        const auto Integer2 = dyn_cast<IntegerLiteral>(Idx2);
4048
83
        if (Integer1 && 
Integer275
) {
4049
75
          if (!llvm::APInt::isSameValue(Integer1->getValue(),
4050
75
                                        Integer2->getValue()))
4051
72
            return false;
4052
8
        } else {
4053
8
          if (!isSameComparisonOperand(Idx1, Idx2))
4054
3
            return false;
4055
8
        }
4056
8
4057
8
        return true;
4058
8
      }
4059
11.9k
4060
11.9k
      // Walk the MemberExpr chain.
4061
14.3k
      
while (11.9k
isa<MemberExpr>(E1) &&
isa<MemberExpr>(E2)5.69k
) {
4062
4.26k
        const auto *ME1 = cast<MemberExpr>(E1);
4063
4.26k
        const auto *ME2 = cast<MemberExpr>(E2);
4064
4.26k
        if (!declaresSameEntity(ME1->getMemberDecl(), ME2->getMemberDecl()))
4065
1.83k
          return false;
4066
2.42k
        if (const auto *D = dyn_cast<VarDecl>(ME1->getMemberDecl()))
4067
1
          if (D->isStaticDataMember())
4068
1
            return true;
4069
2.42k
        E1 = ME1->getBase()->IgnoreParenImpCasts();
4070
2.42k
        E2 = ME2->getBase()->IgnoreParenImpCasts();
4071
2.42k
      }
4072
11.9k
4073
11.9k
      
if (10.1k
isa<CXXThisExpr>(E1)10.1k
&&
isa<CXXThisExpr>(E2)134
)
4074
2
        return true;
4075
10.1k
4076
10.1k
      // A static member variable can end the MemberExpr chain with either
4077
10.1k
      // a MemberExpr or a DeclRefExpr.
4078
20.2k
      
auto getAnyDecl = [](const Expr *E) -> const ValueDecl * 10.1k
{
4079
20.2k
        if (const auto *DRE = dyn_cast<DeclRefExpr>(E))
4080
12.0k
          return DRE->getDecl();
4081
8.22k
        if (const auto *ME = dyn_cast<MemberExpr>(E))
4082
5.80k
          return ME->getMemberDecl();
4083
2.42k
        return nullptr;
4084
2.42k
      };
4085
10.1k
4086
10.1k
      const ValueDecl *VD1 = getAnyDecl(E1);
4087
10.1k
      const ValueDecl *VD2 = getAnyDecl(E2);
4088
10.1k
      return declaresSameEntity(VD1, VD2);
4089
10.1k
    }
4090
231k
  }
4091
231k
}
4092
4093
/// isArrow - Return true if the base expression is a pointer to vector,
4094
/// return false if the base expression is a vector.
4095
361
bool ExtVectorElementExpr::isArrow() const {
4096
361
  return getBase()->getType()->isPointerType();
4097
361
}
4098
4099
288
unsigned ExtVectorElementExpr::getNumElements() const {
4100
288
  if (const VectorType *VT = getType()->getAs<VectorType>())
4101
63
    return VT->getNumElements();
4102
225
  return 1;
4103
225
}
4104
4105
/// containsDuplicateElements - Return true if any element access is repeated.
4106
87
bool ExtVectorElementExpr::containsDuplicateElements() const {
4107
87
  // FIXME: Refactor this code to an accessor on the AST node which returns the
4108
87
  // "type" of component access, and share with code below and in Sema.
4109
87
  StringRef Comp = Accessor->getName();
4110
87
4111
87
  // Halving swizzles do not contain duplicate elements.
4112
87
  if (Comp == "hi" || 
Comp == "lo"85
||
Comp == "even"71
||
Comp == "odd"60
)
4113
28
    return false;
4114
59
4115
59
  // Advance past s-char prefix on hex swizzles.
4116
59
  if (Comp[0] == 's' || Comp[0] == 'S')
4117
0
    Comp = Comp.substr(1);
4118
59
4119
132
  for (unsigned i = 0, e = Comp.size(); i != e; 
++i73
)
4120
81
    if (Comp.substr(i + 1).find(Comp[i]) != StringRef::npos)
4121
8
        return true;
4122
59
4123
59
  
return false51
;
4124
59
}
4125
4126
/// getEncodedElementAccess - We encode the fields as a llvm ConstantArray.
4127
void ExtVectorElementExpr::getEncodedElementAccess(
4128
288
    SmallVectorImpl<uint32_t> &Elts) const {
4129
288
  StringRef Comp = Accessor->getName();
4130
288
  bool isNumericAccessor = false;
4131
288
  if (Comp[0] == 's' || 
Comp[0] == 'S'281
) {
4132
7
    Comp = Comp.substr(1);
4133
7
    isNumericAccessor = true;
4134
7
  }
4135
288
4136
288
  bool isHi =   Comp == "hi";
4137
288
  bool isLo =   Comp == "lo";
4138
288
  bool isEven = Comp == "even";
4139
288
  bool isOdd  = Comp == "odd";
4140
288
4141
693
  for (unsigned i = 0, e = getNumElements(); i != e; 
++i405
) {
4142
405
    uint64_t Index;
4143
405
4144
405
    if (isHi)
4145
14
      Index = e + i;
4146
391
    else if (isLo)
4147
46
      Index = i;
4148
345
    else if (isEven)
4149
5
      Index = 2 * i;
4150
340
    else if (isOdd)
4151
2
      Index = 2 * i + 1;
4152
338
    else
4153
338
      Index = ExtVectorType::getAccessorIdx(Comp[i], isNumericAccessor);
4154
405
4155
405
    Elts.push_back(Index);
4156
405
  }
4157
288
}
4158
4159
ShuffleVectorExpr::ShuffleVectorExpr(const ASTContext &C, ArrayRef<Expr*> args,
4160
                                     QualType Type, SourceLocation BLoc,
4161
                                     SourceLocation RP)
4162
   : Expr(ShuffleVectorExprClass, Type, VK_RValue, OK_Ordinary,
4163
          Type->isDependentType(), Type->isDependentType(),
4164
          Type->isInstantiationDependentType(),
4165
          Type->containsUnexpandedParameterPack()),
4166
     BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(args.size())
4167
140k
{
4168
140k
  SubExprs = new (C) Stmt*[args.size()];
4169
1.35M
  for (unsigned i = 0; i != args.size(); 
i++1.21M
) {
4170
1.21M
    if (args[i]->isTypeDependent())
4171
0
      ExprBits.TypeDependent = true;
4172
1.21M
    if (args[i]->isValueDependent())
4173
2
      ExprBits.ValueDependent = true;
4174
1.21M
    if (args[i]->isInstantiationDependent())
4175
2
      ExprBits.InstantiationDependent = true;
4176
1.21M
    if (args[i]->containsUnexpandedParameterPack())
4177
0
      ExprBits.ContainsUnexpandedParameterPack = true;
4178
1.21M
4179
1.21M
    SubExprs[i] = args[i];
4180
1.21M
  }
4181
140k
}
4182
4183
2
void ShuffleVectorExpr::setExprs(const ASTContext &C, ArrayRef<Expr *> Exprs) {
4184
2
  if (SubExprs) 
C.Deallocate(SubExprs)0
;
4185
2
4186
2
  this->NumExprs = Exprs.size();
4187
2
  SubExprs = new (C) Stmt*[NumExprs];
4188
2
  memcpy(SubExprs, Exprs.data(), sizeof(Expr *) * Exprs.size());
4189
2
}
4190
4191
GenericSelectionExpr::GenericSelectionExpr(
4192
    const ASTContext &, SourceLocation GenericLoc, Expr *ControllingExpr,
4193
    ArrayRef<TypeSourceInfo *> AssocTypes, ArrayRef<Expr *> AssocExprs,
4194
    SourceLocation DefaultLoc, SourceLocation RParenLoc,
4195
    bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
4196
    : Expr(GenericSelectionExprClass, AssocExprs[ResultIndex]->getType(),
4197
           AssocExprs[ResultIndex]->getValueKind(),
4198
           AssocExprs[ResultIndex]->getObjectKind(),
4199
           AssocExprs[ResultIndex]->isTypeDependent(),
4200
           AssocExprs[ResultIndex]->isValueDependent(),
4201
           AssocExprs[ResultIndex]->isInstantiationDependent(),
4202
           ContainsUnexpandedParameterPack),
4203
      NumAssocs(AssocExprs.size()), ResultIndex(ResultIndex),
4204
313
      DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4205
313
  assert(AssocTypes.size() == AssocExprs.size() &&
4206
313
         "Must have the same number of association expressions"
4207
313
         " and TypeSourceInfo!");
4208
313
  assert(ResultIndex < NumAssocs && "ResultIndex is out-of-bounds!");
4209
313
4210
313
  GenericSelectionExprBits.GenericLoc = GenericLoc;
4211
313
  getTrailingObjects<Stmt *>()[ControllingIndex] = ControllingExpr;
4212
313
  std::copy(AssocExprs.begin(), AssocExprs.end(),
4213
313
            getTrailingObjects<Stmt *>() + AssocExprStartIndex);
4214
313
  std::copy(AssocTypes.begin(), AssocTypes.end(),
4215
313
            getTrailingObjects<TypeSourceInfo *>());
4216
313
}
4217
4218
GenericSelectionExpr::GenericSelectionExpr(
4219
    const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr,
4220
    ArrayRef<TypeSourceInfo *> AssocTypes, ArrayRef<Expr *> AssocExprs,
4221
    SourceLocation DefaultLoc, SourceLocation RParenLoc,
4222
    bool ContainsUnexpandedParameterPack)
4223
    : Expr(GenericSelectionExprClass, Context.DependentTy, VK_RValue,
4224
           OK_Ordinary,
4225
           /*isTypeDependent=*/true,
4226
           /*isValueDependent=*/true,
4227
           /*isInstantiationDependent=*/true, ContainsUnexpandedParameterPack),
4228
      NumAssocs(AssocExprs.size()), ResultIndex(ResultDependentIndex),
4229
4
      DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4230
4
  assert(AssocTypes.size() == AssocExprs.size() &&
4231
4
         "Must have the same number of association expressions"
4232
4
         " and TypeSourceInfo!");
4233
4
4234
4
  GenericSelectionExprBits.GenericLoc = GenericLoc;
4235
4
  getTrailingObjects<Stmt *>()[ControllingIndex] = ControllingExpr;
4236
4
  std::copy(AssocExprs.begin(), AssocExprs.end(),
4237
4
            getTrailingObjects<Stmt *>() + AssocExprStartIndex);
4238
4
  std::copy(AssocTypes.begin(), AssocTypes.end(),
4239
4
            getTrailingObjects<TypeSourceInfo *>());
4240
4
}
4241
4242
GenericSelectionExpr::GenericSelectionExpr(EmptyShell Empty, unsigned NumAssocs)
4243
1
    : Expr(GenericSelectionExprClass, Empty), NumAssocs(NumAssocs) {}
4244
4245
GenericSelectionExpr *GenericSelectionExpr::Create(
4246
    const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr,
4247
    ArrayRef<TypeSourceInfo *> AssocTypes, ArrayRef<Expr *> AssocExprs,
4248
    SourceLocation DefaultLoc, SourceLocation RParenLoc,
4249
313
    bool ContainsUnexpandedParameterPack, unsigned ResultIndex) {
4250
313
  unsigned NumAssocs = AssocExprs.size();
4251
313
  void *Mem = Context.Allocate(
4252
313
      totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4253
313
      alignof(GenericSelectionExpr));
4254
313
  return new (Mem) GenericSelectionExpr(
4255
313
      Context, GenericLoc, ControllingExpr, AssocTypes, AssocExprs, DefaultLoc,
4256
313
      RParenLoc, ContainsUnexpandedParameterPack, ResultIndex);
4257
313
}
4258
4259
GenericSelectionExpr *GenericSelectionExpr::Create(
4260
    const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr,
4261
    ArrayRef<TypeSourceInfo *> AssocTypes, ArrayRef<Expr *> AssocExprs,
4262
    SourceLocation DefaultLoc, SourceLocation RParenLoc,
4263
4
    bool ContainsUnexpandedParameterPack) {
4264
4
  unsigned NumAssocs = AssocExprs.size();
4265
4
  void *Mem = Context.Allocate(
4266
4
      totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4267
4
      alignof(GenericSelectionExpr));
4268
4
  return new (Mem) GenericSelectionExpr(
4269
4
      Context, GenericLoc, ControllingExpr, AssocTypes, AssocExprs, DefaultLoc,
4270
4
      RParenLoc, ContainsUnexpandedParameterPack);
4271
4
}
4272
4273
GenericSelectionExpr *
4274
GenericSelectionExpr::CreateEmpty(const ASTContext &Context,
4275
1
                                  unsigned NumAssocs) {
4276
1
  void *Mem = Context.Allocate(
4277
1
      totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4278
1
      alignof(GenericSelectionExpr));
4279
1
  return new (Mem) GenericSelectionExpr(EmptyShell(), NumAssocs);
4280
1
}
4281
4282
//===----------------------------------------------------------------------===//
4283
//  DesignatedInitExpr
4284
//===----------------------------------------------------------------------===//
4285
4286
3.90k
IdentifierInfo *DesignatedInitExpr::Designator::getFieldName() const {
4287
3.90k
  assert(Kind == FieldDesignator && "Only valid on a field designator");
4288
3.90k
  if (Field.NameOrField & 0x01)
4289
3.72k
    return reinterpret_cast<IdentifierInfo *>(Field.NameOrField&~0x01);
4290
177
  else
4291
177
    return getField()->getIdentifier();
4292
3.90k
}
4293
4294
DesignatedInitExpr::DesignatedInitExpr(const ASTContext &C, QualType Ty,
4295
                                       llvm::ArrayRef<Designator> Designators,
4296
                                       SourceLocation EqualOrColonLoc,
4297
                                       bool GNUSyntax,
4298
                                       ArrayRef<Expr*> IndexExprs,
4299
                                       Expr *Init)
4300
  : Expr(DesignatedInitExprClass, Ty,
4301
         Init->getValueKind(), Init->getObjectKind(),
4302
         Init->isTypeDependent(), Init->isValueDependent(),
4303
         Init->isInstantiationDependent(),
4304
         Init->containsUnexpandedParameterPack()),
4305
    EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax),
4306
1.82k
    NumDesignators(Designators.size()), NumSubExprs(IndexExprs.size() + 1) {
4307
1.82k
  this->Designators = new (C) Designator[NumDesignators];
4308
1.82k
4309
1.82k
  // Record the initializer itself.
4310
1.82k
  child_iterator Child = child_begin();
4311
1.82k
  *Child++ = Init;
4312
1.82k
4313
1.82k
  // Copy the designators and their subexpressions, computing
4314
1.82k
  // value-dependence along the way.
4315
1.82k
  unsigned IndexIdx = 0;
4316
3.97k
  for (unsigned I = 0; I != NumDesignators; 
++I2.15k
) {
4317
2.15k
    this->Designators[I] = Designators[I];
4318
2.15k
4319
2.15k
    if (this->Designators[I].isArrayDesignator()) {
4320
338
      // Compute type- and value-dependence.
4321
338
      Expr *Index = IndexExprs[IndexIdx];
4322
338
      if (Index->isTypeDependent() || Index->isValueDependent())
4323
7
        ExprBits.TypeDependent = ExprBits.ValueDependent = true;
4324
338
      if (Index->isInstantiationDependent())
4325
7
        ExprBits.InstantiationDependent = true;
4326
338
      // Propagate unexpanded parameter packs.
4327
338
      if (Index->containsUnexpandedParameterPack())
4328
0
        ExprBits.ContainsUnexpandedParameterPack = true;
4329
338
4330
338
      // Copy the index expressions into permanent storage.
4331
338
      *Child++ = IndexExprs[IndexIdx++];
4332
1.81k
    } else if (this->Designators[I].isArrayRangeDesignator()) {
4333
27
      // Compute type- and value-dependence.
4334
27
      Expr *Start = IndexExprs[IndexIdx];
4335
27
      Expr *End = IndexExprs[IndexIdx + 1];
4336
27
      if (Start->isTypeDependent() || Start->isValueDependent() ||
4337
27
          
End->isTypeDependent()24
||
End->isValueDependent()24
) {
4338
3
        ExprBits.TypeDependent = ExprBits.ValueDependent = true;
4339
3
        ExprBits.InstantiationDependent = true;
4340
24
      } else if (Start->isInstantiationDependent() ||
4341
24
                 End->isInstantiationDependent()) {
4342
0
        ExprBits.InstantiationDependent = true;
4343
0
      }
4344
27
4345
27
      // Propagate unexpanded parameter packs.
4346
27
      if (Start->containsUnexpandedParameterPack() ||
4347
27
          End->containsUnexpandedParameterPack())
4348
0
        ExprBits.ContainsUnexpandedParameterPack = true;
4349
27
4350
27
      // Copy the start/end expressions into permanent storage.
4351
27
      *Child++ = IndexExprs[IndexIdx++];
4352
27
      *Child++ = IndexExprs[IndexIdx++];
4353
27
    }
4354
2.15k
  }
4355
1.82k
4356
1.82k
  assert(IndexIdx == IndexExprs.size() && "Wrong number of index expressions");
4357
1.82k
}
4358
4359
DesignatedInitExpr *
4360
DesignatedInitExpr::Create(const ASTContext &C,
4361
                           llvm::ArrayRef<Designator> Designators,
4362
                           ArrayRef<Expr*> IndexExprs,
4363
                           SourceLocation ColonOrEqualLoc,
4364
1.82k
                           bool UsesColonSyntax, Expr *Init) {
4365
1.82k
  void *Mem = C.Allocate(totalSizeToAlloc<Stmt *>(IndexExprs.size() + 1),
4366
1.82k
                         alignof(DesignatedInitExpr));
4367
1.82k
  return new (Mem) DesignatedInitExpr(C, C.VoidTy, Designators,
4368
1.82k
                                      ColonOrEqualLoc, UsesColonSyntax,
4369
1.82k
                                      IndexExprs, Init);
4370
1.82k
}
4371
4372
DesignatedInitExpr *DesignatedInitExpr::CreateEmpty(const ASTContext &C,
4373
30
                                                    unsigned NumIndexExprs) {
4374
30
  void *Mem = C.Allocate(totalSizeToAlloc<Stmt *>(NumIndexExprs + 1),
4375
30
                         alignof(DesignatedInitExpr));
4376
30
  return new (Mem) DesignatedInitExpr(NumIndexExprs + 1);
4377
30
}
4378
4379
void DesignatedInitExpr::setDesignators(const ASTContext &C,
4380
                                        const Designator *Desigs,
4381
30
                                        unsigned NumDesigs) {
4382
30
  Designators = new (C) Designator[NumDesigs];
4383
30
  NumDesignators = NumDesigs;
4384
69
  for (unsigned I = 0; I != NumDesigs; 
++I39
)
4385
39
    Designators[I] = Desigs[I];
4386
30
}
4387
4388
66
SourceRange DesignatedInitExpr::getDesignatorsSourceRange() const {
4389
66
  DesignatedInitExpr *DIE = const_cast<DesignatedInitExpr*>(this);
4390
66
  if (size() == 1)
4391
0
    return DIE->getDesignator(0)->getSourceRange();
4392
66
  return SourceRange(DIE->getDesignator(0)->getBeginLoc(),
4393
66
                     DIE->getDesignator(size() - 1)->getEndLoc());
4394
66
}
4395
4396
4.74k
SourceLocation DesignatedInitExpr::getBeginLoc() const {
4397
4.74k
  SourceLocation StartLoc;
4398
4.74k
  auto *DIE = const_cast<DesignatedInitExpr *>(this);
4399
4.74k
  Designator &First = *DIE->getDesignator(0);
4400
4.74k
  if (First.isFieldDesignator()) {
4401
4.44k
    if (GNUSyntax)
4402
24
      StartLoc = SourceLocation::getFromRawEncoding(First.Field.FieldLoc);
4403
4.42k
    else
4404
4.42k
      StartLoc = SourceLocation::getFromRawEncoding(First.Field.DotLoc);
4405
4.44k
  } else
4406
298
    StartLoc =
4407
298
      SourceLocation::getFromRawEncoding(First.ArrayOrRange.LBracketLoc);
4408
4.74k
  return StartLoc;
4409
4.74k
}
4410
4411
906
SourceLocation DesignatedInitExpr::getEndLoc() const {
4412
906
  return getInit()->getEndLoc();
4413
906
}
4414
4415
690
Expr *DesignatedInitExpr::getArrayIndex(const Designator& D) const {
4416
690
  assert(D.Kind == Designator::ArrayDesignator && "Requires array designator");
4417
690
  return getSubExpr(D.ArrayOrRange.Index + 1);
4418
690
}
4419
4420
63
Expr *DesignatedInitExpr::getArrayRangeStart(const Designator &D) const {
4421
63
  assert(D.Kind == Designator::ArrayRangeDesignator &&
4422
63
         "Requires array range designator");
4423
63
  return getSubExpr(D.ArrayOrRange.Index + 1);
4424
63
}
4425
4426
105
Expr *DesignatedInitExpr::getArrayRangeEnd(const Designator &D) const {
4427
105
  assert(D.Kind == Designator::ArrayRangeDesignator &&
4428
105
         "Requires array range designator");
4429
105
  return getSubExpr(D.ArrayOrRange.Index + 2);
4430
105
}
4431
4432
/// Replaces the designator at index @p Idx with the series
4433
/// of designators in [First, Last).
4434
void DesignatedInitExpr::ExpandDesignator(const ASTContext &C, unsigned Idx,
4435
                                          const Designator *First,
4436
30
                                          const Designator *Last) {
4437
30
  unsigned NumNewDesignators = Last - First;
4438
30
  if (NumNewDesignators == 0) {
4439
0
    std::copy_backward(Designators + Idx + 1,
4440
0
                       Designators + NumDesignators,
4441
0
                       Designators + Idx);
4442
0
    --NumNewDesignators;
4443
0
    return;
4444
30
  } else if (NumNewDesignators == 1) {
4445
0
    Designators[Idx] = *First;
4446
0
    return;
4447
0
  }
4448
30
4449
30
  Designator *NewDesignators
4450
30
    = new (C) Designator[NumDesignators - 1 + NumNewDesignators];
4451
30
  std::copy(Designators, Designators + Idx, NewDesignators);
4452
30
  std::copy(First, Last, NewDesignators + Idx);
4453
30
  std::copy(Designators + Idx + 1, Designators + NumDesignators,
4454
30
            NewDesignators + Idx + NumNewDesignators);
4455
30
  Designators = NewDesignators;
4456
30
  NumDesignators = NumDesignators - 1 + NumNewDesignators;
4457
30
}
4458
4459
DesignatedInitUpdateExpr::DesignatedInitUpdateExpr(const ASTContext &C,
4460
    SourceLocation lBraceLoc, Expr *baseExpr, SourceLocation rBraceLoc)
4461
  : Expr(DesignatedInitUpdateExprClass, baseExpr->getType(), VK_RValue,
4462
53
         OK_Ordinary, false, false, false, false) {
4463
53
  BaseAndUpdaterExprs[0] = baseExpr;
4464
53
4465
53
  InitListExpr *ILE = new (C) InitListExpr(C, lBraceLoc, None, rBraceLoc);