32 #include "llvm/ADT/SmallVector.h" 33 #include "llvm/ADT/StringExtras.h" 34 #include "llvm/ADT/StringRef.h" 35 #include "llvm/Support/Casting.h" 36 #include "llvm/Support/Compiler.h" 37 #include "llvm/Support/ErrorHandling.h" 38 #include "llvm/Support/MathExtras.h" 39 #include "llvm/Support/raw_ostream.h" 46 using namespace clang;
61 #define ABSTRACT_STMT(STMT) 62 #define STMT(CLASS, PARENT) \ 63 StmtClassInfo[(unsigned)Stmt::CLASS##Class].Name = #CLASS; \ 64 StmtClassInfo[(unsigned)Stmt::CLASS##Class].Size = sizeof(CLASS); 65 #include "clang/AST/StmtNodes.inc" 72 return ::operator
new(
bytes,
C, alignment);
84 llvm::errs() <<
"\n*** Stmt/Expr Stats:\n";
85 for (
int i = 0; i != Stmt::lastStmtConstant+1; i++) {
89 llvm::errs() <<
" " << sum <<
" stmts/exprs total.\n";
91 for (
int i = 0; i != Stmt::lastStmtConstant+1; i++) {
101 llvm::errs() <<
"Total bytes = " << sum <<
"\n";
108 bool Stmt::StatisticsEnabled =
false;
110 StatisticsEnabled =
true;
116 if (
auto *ewc = dyn_cast<ExprWithCleanups>(s))
117 s = ewc->getSubExpr();
119 if (
auto *mte = dyn_cast<MaterializeTemporaryExpr>(s))
120 s = mte->GetTemporaryExpr();
122 if (
auto *bte = dyn_cast<CXXBindTemporaryExpr>(s))
123 s = bte->getSubExpr();
125 while (
auto *ice = dyn_cast<ImplicitCastExpr>(s))
126 s = ice->getSubExpr();
136 if (
auto CapS = dyn_cast_or_null<CapturedStmt>(S))
137 S = CapS->getCapturedStmt();
139 if (
auto AS = dyn_cast_or_null<AttributedStmt>(S))
140 S = AS->getSubStmt();
141 else if (
auto CS = dyn_cast_or_null<CompoundStmt>(S)) {
156 const Stmt *S =
this;
158 if (
const auto *LS = dyn_cast<LabelStmt>(S))
159 S = LS->getSubStmt();
160 else if (
const auto *SC = dyn_cast<SwitchCase>(S))
161 S = SC->getSubStmt();
162 else if (
const auto *AS = dyn_cast<AttributedStmt>(S))
163 S = AS->getSubStmt();
177 static good is_good(good) {
return good(); }
180 template <
class T> good implements_children(children_t T::*) {
183 LLVM_ATTRIBUTE_UNUSED
184 static bad implements_children(children_t
Stmt::*) {
189 template <
class T> good implements_getLocStart(getLocStart_t T::*) {
192 LLVM_ATTRIBUTE_UNUSED
193 static bad implements_getLocStart(getLocStart_t
Stmt::*) {
198 template <
class T> good implements_getLocEnd(getLocEnd_t T::*) {
201 LLVM_ATTRIBUTE_UNUSED
202 static bad implements_getLocEnd(getLocEnd_t
Stmt::*) {
206 #define ASSERT_IMPLEMENTS_children(type) \ 207 (void) is_good(implements_children(&type::children)) 208 #define ASSERT_IMPLEMENTS_getLocStart(type) \ 209 (void) is_good(implements_getLocStart(&type::getLocStart)) 210 #define ASSERT_IMPLEMENTS_getLocEnd(type) \ 211 (void) is_good(implements_getLocEnd(&type::getLocEnd)) 217 LLVM_ATTRIBUTE_UNUSED
219 #define ABSTRACT_STMT(type) 220 #define STMT(type, base) \ 221 ASSERT_IMPLEMENTS_children(type); \ 222 ASSERT_IMPLEMENTS_getLocStart(type); \ 223 ASSERT_IMPLEMENTS_getLocEnd(type); 224 #include "clang/AST/StmtNodes.inc" 228 switch (getStmtClass()) {
230 #define ABSTRACT_STMT(type) 231 #define STMT(type, base) \ 232 case Stmt::type##Class: \ 233 return static_cast<type*>(this)->children(); 234 #include "clang/AST/StmtNodes.inc" 236 llvm_unreachable(
"unknown statement kind!");
247 template <
class S,
class T>
260 return SourceRange(static_cast<const S*>(stmt)->getLocStart(),
261 static_cast<const S*>(stmt)->getLocEnd());
267 switch (getStmtClass()) {
269 #define ABSTRACT_STMT(type) 270 #define STMT(type, base) \ 271 case Stmt::type##Class: \ 272 return getSourceRangeImpl<type>(this, &type::getSourceRange); 273 #include "clang/AST/StmtNodes.inc" 275 llvm_unreachable(
"unknown statement kind!");
280 switch (getStmtClass()) {
282 #define ABSTRACT_STMT(type) 283 #define STMT(type, base) \ 284 case Stmt::type##Class: \ 285 return static_cast<const type*>(this)->getLocStart(); 286 #include "clang/AST/StmtNodes.inc" 288 llvm_unreachable(
"unknown statement kind");
292 switch (getStmtClass()) {
294 #define ABSTRACT_STMT(type) 295 #define STMT(type, base) \ 296 case Stmt::type##Class: \ 297 return static_cast<const type*>(this)->getLocEnd(); 298 #include "clang/AST/StmtNodes.inc" 300 llvm_unreachable(
"unknown statement kind");
305 :
Stmt(CompoundStmtClass), LBraceLoc(LB), RBraceLoc(RB) {
306 CompoundStmtBits.NumStmts = Stmts.size();
311 assert(CompoundStmtBits.NumStmts == Stmts.size() &&
312 "NumStmts doesn't fit in bits of CompoundStmtBits.NumStmts!");
314 std::copy(Stmts.begin(), Stmts.end(), body_begin());
334 return getDecl()->getIdentifier()->getNameStart();
340 assert(!Attrs.empty() &&
"Attrs should not be empty");
341 void *Mem = C.
Allocate(totalSizeToAlloc<const Attr *>(Attrs.size()),
348 assert(NumAttrs > 0 &&
"NumAttrs should be greater than zero");
349 void *Mem = C.
Allocate(totalSizeToAlloc<const Attr *>(NumAttrs),
355 if (
const auto *gccAsmStmt = dyn_cast<GCCAsmStmt>(
this))
356 return gccAsmStmt->generateAsmString(C);
357 if (
const auto *msAsmStmt = dyn_cast<MSAsmStmt>(
this))
358 return msAsmStmt->generateAsmString(C);
359 llvm_unreachable(
"unknown asm statement kind!");
363 if (
const auto *gccAsmStmt = dyn_cast<GCCAsmStmt>(
this))
364 return gccAsmStmt->getOutputConstraint(i);
365 if (
const auto *msAsmStmt = dyn_cast<MSAsmStmt>(
this))
366 return msAsmStmt->getOutputConstraint(i);
367 llvm_unreachable(
"unknown asm statement kind!");
371 if (
const auto *gccAsmStmt = dyn_cast<GCCAsmStmt>(
this))
372 return gccAsmStmt->getOutputExpr(i);
373 if (
const auto *msAsmStmt = dyn_cast<MSAsmStmt>(
this))
374 return msAsmStmt->getOutputExpr(i);
375 llvm_unreachable(
"unknown asm statement kind!");
379 if (
const auto *gccAsmStmt = dyn_cast<GCCAsmStmt>(
this))
380 return gccAsmStmt->getInputConstraint(i);
381 if (
const auto *msAsmStmt = dyn_cast<MSAsmStmt>(
this))
382 return msAsmStmt->getInputConstraint(i);
383 llvm_unreachable(
"unknown asm statement kind!");
387 if (
const auto *gccAsmStmt = dyn_cast<GCCAsmStmt>(
this))
388 return gccAsmStmt->getInputExpr(i);
389 if (
const auto *msAsmStmt = dyn_cast<MSAsmStmt>(
this))
390 return msAsmStmt->getInputExpr(i);
391 llvm_unreachable(
"unknown asm statement kind!");
395 if (
const auto *gccAsmStmt = dyn_cast<GCCAsmStmt>(
this))
396 return gccAsmStmt->getClobber(i);
397 if (
const auto *msAsmStmt = dyn_cast<MSAsmStmt>(
this))
398 return msAsmStmt->getClobber(i);
399 llvm_unreachable(
"unknown asm statement kind!");
406 for (
unsigned i = 0, e = getNumOutputs(); i != e; ++i)
407 if (isOutputPlusConstraint(i))
413 assert(isOperand() &&
"Only Operands can have modifiers.");
414 return isLetter(Str[0]) ? Str[0] :
'\0';
418 return getClobberStringLiteral(i)->getString();
422 return cast<Expr>(Exprs[i]);
429 return getOutputConstraintLiteral(i)->getString();
433 return cast<Expr>(Exprs[i + NumOutputs]);
437 Exprs[i + NumOutputs] = E;
443 return getInputConstraintLiteral(i)->getString();
446 void GCCAsmStmt::setOutputsAndInputsAndClobbers(
const ASTContext &
C,
453 unsigned NumClobbers) {
454 this->NumOutputs = NumOutputs;
455 this->NumInputs = NumInputs;
456 this->NumClobbers = NumClobbers;
458 unsigned NumExprs = NumOutputs + NumInputs;
462 std::copy(Names, Names + NumExprs, this->Names);
465 this->Exprs =
new (
C)
Stmt*[NumExprs];
466 std::copy(Exprs, Exprs + NumExprs, this->Exprs);
470 std::copy(Constraints, Constraints + NumExprs, this->Constraints);
474 std::copy(Clobbers, Clobbers + NumClobbers, this->Clobbers);
481 unsigned NumPlusOperands = 0;
484 for (
unsigned i = 0, e = getNumOutputs(); i != e; ++i) {
485 if (getOutputName(i) == SymbolicName)
489 for (
unsigned i = 0, e = getNumInputs(); i != e; ++i)
490 if (getInputName(i) == SymbolicName)
491 return getNumOutputs() + NumPlusOperands + i;
501 const ASTContext &C,
unsigned &DiagOffs)
const {
502 StringRef Str = getAsmString()->getString();
503 const char *StrStart = Str.begin();
504 const char *StrEnd = Str.end();
505 const char *CurPtr = StrStart;
511 for (; CurPtr != StrEnd; ++CurPtr) {
527 std::string CurStringPiece;
531 unsigned LastAsmStringToken = 0;
532 unsigned LastAsmStringOffset = 0;
536 if (CurPtr == StrEnd) {
537 if (!CurStringPiece.empty())
542 char CurChar = *CurPtr++;
544 case '$': CurStringPiece +=
"$$";
continue;
545 case '{': CurStringPiece += (HasVariants ?
"$(" :
"{");
continue;
546 case '|': CurStringPiece += (HasVariants ?
"$|" :
"|");
continue;
547 case '}': CurStringPiece += (HasVariants ?
"$)" :
"}");
continue;
551 CurStringPiece += CurChar;
556 if (CurPtr == StrEnd) {
558 DiagOffs = CurPtr-StrStart-1;
559 return diag::err_asm_invalid_escape;
562 char EscapedChar = *CurPtr++;
563 switch (EscapedChar) {
569 CurStringPiece += EscapedChar;
572 CurStringPiece +=
"${:uid}";
578 if (!CurStringPiece.empty()) {
580 CurStringPiece.clear();
586 const char *
Begin = CurPtr - 1;
587 const char *Percent = Begin - 1;
590 if (CurPtr == StrEnd) {
591 DiagOffs = CurPtr-StrStart-1;
592 return diag::err_asm_invalid_escape;
594 EscapedChar = *CurPtr++;
607 while (CurPtr != StrEnd &&
isDigit(*CurPtr))
608 N = N*10 + ((*CurPtr++)-
'0');
610 unsigned NumOperands =
611 getNumOutputs() + getNumPlusOperands() + getNumInputs();
612 if (N >= NumOperands) {
613 DiagOffs = CurPtr-StrStart-1;
614 return diag::err_asm_invalid_operand_number;
618 std::string Str(Begin, CurPtr - Begin);
623 Percent - StrStart, SM, LO, TI, &LastAsmStringToken,
624 &LastAsmStringOffset);
626 CurPtr - StrStart, SM, LO, TI, &LastAsmStringToken,
627 &LastAsmStringOffset);
629 Pieces.emplace_back(N, std::move(Str), BeginLoc, EndLoc);
634 if (EscapedChar ==
'[') {
635 DiagOffs = CurPtr-StrStart-1;
638 const char *NameEnd = (
const char*)memchr(CurPtr,
']', StrEnd-CurPtr);
639 if (NameEnd ==
nullptr)
640 return diag::err_asm_unterminated_symbolic_operand_name;
641 if (NameEnd == CurPtr)
642 return diag::err_asm_empty_symbolic_operand_name;
644 StringRef SymbolicName(CurPtr, NameEnd - CurPtr);
646 int N = getNamedOperand(SymbolicName);
649 DiagOffs = CurPtr-StrStart;
650 return diag::err_asm_unknown_symbolic_operand_name;
654 std::string Str(Begin, NameEnd + 1 - Begin);
659 Percent - StrStart, SM, LO, TI, &LastAsmStringToken,
660 &LastAsmStringOffset);
662 NameEnd + 1 - StrStart, SM, LO, TI, &LastAsmStringToken,
663 &LastAsmStringOffset);
665 Pieces.emplace_back(N, std::move(Str), BeginLoc, EndLoc);
671 DiagOffs = CurPtr-StrStart-1;
672 return diag::err_asm_invalid_escape;
682 AnalyzeAsmString(Pieces, C, DiagOffs);
684 std::string AsmString;
685 for (
const auto &Piece : Pieces) {
686 if (Piece.isString())
687 AsmString += Piece.getString();
688 else if (Piece.getModifier() ==
'\0')
689 AsmString +=
'$' + llvm::utostr(Piece.getOperandNo());
691 AsmString +=
"${" + llvm::utostr(Piece.getOperandNo()) +
':' +
692 Piece.getModifier() +
'}';
704 return cast<Expr>(Exprs[i]);
708 return cast<Expr>(Exprs[i + NumOutputs]);
712 Exprs[i + NumOutputs] = E;
720 bool issimple,
bool isvolatile,
unsigned numoutputs,
725 :
AsmStmt(GCCAsmStmtClass, asmloc, issimple, isvolatile, numoutputs,
726 numinputs, numclobbers), RParenLoc(rparenloc), AsmStr(asmstr) {
730 std::copy(names, names + NumExprs, Names);
732 Exprs =
new (
C)
Stmt*[NumExprs];
733 std::copy(exprs, exprs + NumExprs, Exprs);
736 std::copy(constraints, constraints + NumExprs, Constraints);
739 std::copy(clobbers, clobbers +
NumClobbers, Clobbers);
749 :
AsmStmt(MSAsmStmtClass, asmloc, issimple, isvolatile, numoutputs,
750 numinputs, clobbers.size()), LBraceLoc(lbraceloc),
751 EndLoc(endloc), NumAsmToks(asmtoks.size()) {
752 initialize(C, asmstr, asmtoks, constraints, exprs, clobbers);
759 void MSAsmStmt::initialize(
const ASTContext &C, StringRef asmstr,
764 assert(NumAsmToks == asmtoks.size());
768 assert(exprs.size() == constraints.size());
772 Exprs =
new (
C)
Stmt*[exprs.size()];
773 std::copy(exprs.begin(), exprs.end(),
Exprs);
775 AsmToks =
new (
C)
Token[asmtoks.size()];
776 std::copy(asmtoks.begin(), asmtoks.end(), AsmToks);
778 Constraints =
new (
C) StringRef[exprs.size()];
779 std::transform(constraints.begin(), constraints.end(), Constraints,
780 [&](StringRef Constraint) {
786 std::transform(clobbers.begin(), clobbers.end(), Clobbers,
787 [&](StringRef Clobber) {
795 :
Stmt(IfStmtClass), IfLoc(IL), ElseLoc(EL) {
798 SubExprs[INIT] = init;
799 SubExprs[COND] = cond;
800 SubExprs[THEN] = then;
801 SubExprs[ELSE] = elsev;
808 auto *DS = cast<DeclStmt>(SubExprs[VAR]);
809 return cast<VarDecl>(DS->getSingleDecl());
814 SubExprs[VAR] =
nullptr;
824 return isa<ObjCAvailabilityCheckExpr>(SubExprs[COND]);
830 :
Stmt(ForStmtClass), ForLoc(FL), LParenLoc(LP), RParenLoc(RP)
832 SubExprs[INIT] = Init;
834 SubExprs[COND] = Cond;
836 SubExprs[BODY] = Body;
840 if (!SubExprs[CONDVAR])
843 auto *DS = cast<DeclStmt>(SubExprs[CONDVAR]);
844 return cast<VarDecl>(DS->getSingleDecl());
849 SubExprs[CONDVAR] =
nullptr;
860 :
Stmt(SwitchStmtClass), FirstCase(nullptr,
false) {
862 SubExprs[INIT] = init;
863 SubExprs[COND] = cond;
864 SubExprs[BODY] =
nullptr;
871 auto *DS = cast<DeclStmt>(SubExprs[VAR]);
872 return cast<VarDecl>(DS->getSingleDecl());
877 SubExprs[VAR] =
nullptr;
887 if (isa<CaseStmt>(
this))
888 return cast<CaseStmt>(
this)->getSubStmt();
889 return cast<DefaultStmt>(
this)->getSubStmt();
894 :
Stmt(WhileStmtClass) {
896 SubExprs[COND] = cond;
897 SubExprs[BODY] = body;
905 auto *DS = cast<DeclStmt>(SubExprs[VAR]);
906 return cast<VarDecl>(DS->getSingleDecl());
911 SubExprs[VAR] =
nullptr;
922 if (
auto *E = dyn_cast<AddrLabelExpr>(getTarget()->IgnoreParenImpCasts()))
923 return E->getLabel();
929 return cast_or_null<Expr>(RetExpr);
932 return cast_or_null<Expr>(RetExpr);
937 :
Stmt(SEHTryStmtClass), IsCXXTry(IsCXXTry), TryLoc(TryLoc) {
938 Children[TRY] = TryBlock;
939 Children[HANDLER] = Handler;
945 return new(
C)
SEHTryStmt(IsCXXTry,TryLoc,TryBlock,Handler);
957 :
Stmt(SEHExceptStmtClass), Loc(Loc) {
958 Children[FILTER_EXPR] = FilterExpr;
959 Children[
BLOCK] = Block;
968 :
Stmt(SEHFinallyStmtClass), Loc(Loc), Block(Block) {}
977 : VarAndKind(Var, Kind), Loc(Loc) {
980 assert(!Var &&
"'this' capture cannot have a variable!");
983 assert(Var &&
"capturing by reference must have a variable!");
986 assert(Var &&
"capturing by copy must have a variable!");
993 "captures by copy are expected to have a scalar type!");
997 "Variable-length array type capture cannot have a variable!");
1004 return VarAndKind.getInt();
1009 "No variable available for 'this' or VAT capture");
1010 return VarAndKind.getPointer();
1017 unsigned FirstCaptureOffset = llvm::alignTo(Size,
alignof(
Capture));
1019 return reinterpret_cast<Capture *
>(
1020 reinterpret_cast<char *
>(
const_cast<CapturedStmt *
>(
this))
1021 + FirstCaptureOffset);
1029 :
Stmt(CapturedStmtClass), NumCaptures(Captures.size()),
1030 CapDeclAndKind(CD,
Kind), TheRecordDecl(RD) {
1031 assert( S &&
"null captured statement");
1032 assert(CD &&
"null captured declaration for captured statement");
1033 assert(RD &&
"null record declaration for captured statement");
1036 Stmt **Stored = getStoredStmts();
1037 for (
unsigned I = 0, N = NumCaptures; I != N; ++I)
1038 *Stored++ = CaptureInits[I];
1044 Capture *Buffer = getStoredCaptures();
1045 std::copy(Captures.begin(), Captures.end(), Buffer);
1048 CapturedStmt::CapturedStmt(
EmptyShell Empty,
unsigned NumCaptures)
1049 :
Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures),
1051 getStoredStmts()[NumCaptures] =
nullptr;
1069 assert(CaptureInits.size() == Captures.size() &&
"wrong number of arguments");
1071 unsigned Size =
sizeof(
CapturedStmt) +
sizeof(
Stmt *) * (Captures.size() + 1);
1072 if (!Captures.empty()) {
1074 Size = llvm::alignTo(Size,
alignof(
Capture));
1075 Size +=
sizeof(
Capture) * Captures.size();
1078 void *Mem = Context.
Allocate(Size);
1079 return new (Mem)
CapturedStmt(S, Kind, Captures, CaptureInits, CD, RD);
1083 unsigned NumCaptures) {
1085 if (NumCaptures > 0) {
1087 Size = llvm::alignTo(Size,
alignof(
Capture));
1088 Size +=
sizeof(
Capture) * NumCaptures;
1091 void *Mem = Context.
Allocate(Size);
1097 return child_range(getStoredStmts(), getStoredStmts() + NumCaptures);
1101 return CapDeclAndKind.getPointer();
1105 return CapDeclAndKind.getPointer();
1110 assert(D &&
"null CapturedDecl");
1111 CapDeclAndKind.setPointer(D);
1116 return CapDeclAndKind.getInt();
1121 CapDeclAndKind.setInt(Kind);
1126 if (!I.capturesVariable() && !I.capturesVariableByCopy())
static AttributedStmt * CreateEmpty(const ASTContext &C, unsigned NumAttrs)
void setConditionVariable(const ASTContext &C, VarDecl *V)
Defines the clang::ASTContext interface.
Capture(SourceLocation Loc, VariableCaptureKind Kind, VarDecl *Var=nullptr)
Create a new capture.
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
Stmt - This represents one statement.
VarDecl * getCapturedVar() const
Retrieve the declaration of the variable being captured.
C Language Family Type Representation.
Represents an attribute applied to a statement.
GCCAsmStmt(const ASTContext &C, SourceLocation asmloc, bool issimple, bool isvolatile, unsigned numoutputs, unsigned numinputs, IdentifierInfo **names, StringLiteral **constraints, Expr **exprs, StringLiteral *asmstr, unsigned numclobbers, StringLiteral **clobbers, SourceLocation rparenloc)
llvm::iterator_range< child_iterator > child_range
const TargetInfo & getTargetInfo() const
Stmt * IgnoreImplicit()
Skip past any implicit AST nodes which might surround this statement, such as ExprWithCleanups or Imp...
static AttributedStmt * Create(const ASTContext &C, SourceLocation Loc, ArrayRef< const Attr *> Attrs, Stmt *SubStmt)
static void addStmtClass(const StmtClass s)
void setConditionVariable(const ASTContext &C, VarDecl *V)
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "while" statement, if any.
bool capturesVariable(const VarDecl *Var) const
True if this variable has been captured.
void setInputExpr(unsigned i, Expr *E)
void setInputExpr(unsigned i, Expr *E)
Represents a variable declaration or definition.
unsigned AnalyzeAsmString(SmallVectorImpl< AsmStringPiece > &Pieces, const ASTContext &C, unsigned &DiagOffs) const
AnalyzeAsmString - Analyze the asm string of the current asm, decomposing it into pieces...
const char * getName() const
Defines the Objective-C statement AST node classes.
static StringRef bytes(const std::vector< T, Allocator > &v)
int getNamedOperand(StringRef SymbolicName) const
getNamedOperand - Given a symbolic operand reference like %[foo], translate this into a numeric value...
Defines the clang::Expr interface and subclasses for C++ expressions.
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "switch" statement, if any.
Stmt(StmtClass SC, EmptyShell)
Construct an empty statement.
static struct StmtClassNameTable StmtClassInfo[Stmt::lastStmtConstant+1]
const char * getStmtClassName() const
Represents a struct/union/class.
One of these records is kept for each identifier that is lexed.
IfStmt(const ASTContext &C, SourceLocation IL, bool IsConstexpr, Stmt *init, VarDecl *var, Expr *cond, Stmt *then, SourceLocation EL=SourceLocation(), Stmt *elsev=nullptr)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
WhileStmt(const ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body, SourceLocation WL)
LLVM_READONLY bool isLetter(unsigned char c)
Return true if this character is an ASCII letter: [a-zA-Z].
SourceLocation getBeginLoc() const LLVM_READONLY
const Expr * getRetValue() const
bool isReferenceType() const
Token - This structure provides full information about a lexed token.
void setCapturedDecl(CapturedDecl *D)
Set the outlined function declaration.
bool hasNoAsmVariants() const
Return true if {|} are normal characters in the asm string.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
static CapturedStmt * Create(const ASTContext &Context, Stmt *S, CapturedRegionKind Kind, ArrayRef< Capture > Captures, ArrayRef< Expr *> CaptureInits, CapturedDecl *CD, RecordDecl *RD)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
const Expr * getOutputExpr(unsigned i) const
Expr * getOutputExpr(unsigned i)
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt *> Stmts, SourceLocation LB, SourceLocation RB)
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
unsigned getNumPlusOperands() const
getNumPlusOperands - Return the number of output operands that have a "+" constraint.
bool isScalarType() const
Represents the body of a CapturedStmt, and serves as its DeclContext.
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "for" statement, if any.
MSAsmStmt(const ASTContext &C, SourceLocation asmloc, SourceLocation lbraceloc, bool issimple, bool isvolatile, ArrayRef< Token > asmtoks, unsigned numoutputs, unsigned numinputs, ArrayRef< StringRef > constraints, ArrayRef< Expr *> exprs, StringRef asmstr, ArrayRef< StringRef > clobbers, SourceLocation endloc)
static SEHTryStmt * Create(const ASTContext &C, bool isCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
StringRef getClobber(unsigned i) const
CompoundStmt - This represents a group of statements like { stmt stmt }.
Describes the capture of either a variable, or 'this', or variable-length array type.
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
Exposes information about the current target.
Expr - This represents one expression.
Stmt * IgnoreContainers(bool IgnoreCaptured=false)
Skip no-op (attributed, compound) container stmts and skip captured stmt at the top, if IgnoreCaptured is true.
const T * castAs() const
Member-template castAs<specific type>.
AsmStringPiece - this is part of a decomposed asm string specification (for use with the AnalyzeAsmSt...
VariableCaptureKind getCaptureKind() const
Determine the kind of capture.
LabelDecl * getConstantTarget()
getConstantTarget - Returns the fixed target of this indirect goto, if one exists.
CompoundStmtBitfields CompoundStmtBits
static StringRef copyIntoContext(const ASTContext &C, StringRef str)
StringRef getInputConstraint(unsigned i) const
getInputConstraint - Return the specified input constraint.
SourceLocation getEnd() const
Expr * getInputExpr(unsigned i)
Expr * getOutputExpr(unsigned i)
StringRef getClobber(unsigned i) const
The result type of a method or function.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SourceLocation getEndLoc() const LLVM_READONLY
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
StringRef getInputConstraint(unsigned i) const
getInputConstraint - Return the specified input constraint.
This captures a statement into a function.
StringRef getOutputConstraint(unsigned i) const
getOutputConstraint - Return the constraint string for the specified output operand.
Encodes a location in the source.
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
void setConstexpr(bool C)
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Represents the declaration of a label.
bool capturesVariable() const
Determine whether this capture handles a variable (by reference).
void setConditionVariable(const ASTContext &C, VarDecl *V)
StringRef getOutputConstraint(unsigned i) const
getOutputConstraint - Return the constraint string for the specified output operand.
Expr * getInputExpr(unsigned i)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
void * Allocate(size_t Size, unsigned Align=8) const
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "if" statement, if any.
Dataflow Directional Tag Classes.
static CapturedStmt * CreateDeserialized(const ASTContext &Context, unsigned NumCaptures)
const Stmt * stripLabelLikeStatements() const
Strip off all label-like statements.
SEHExceptStmt * getExceptHandler() const
Returns 0 if not defined.
static LLVM_ATTRIBUTE_UNUSED void check_implementations()
Check whether the various Stmt classes implement their member functions.
char getModifier() const
getModifier - Get the modifier for this operand, if present.
bool isObjCAvailabilityCheck() const
static CompoundStmt * CreateEmpty(const ASTContext &C, unsigned NumStmts)
bool capturesVariableByCopy() const
Determine whether this capture handles a variable by copy.
LLVM_READONLY bool isDigit(unsigned char c)
Return true if this character is an ASCII digit: [0-9].
void setConditionVariable(const ASTContext &C, VarDecl *V)
This file defines OpenMP AST classes for executable directives and clauses.
SwitchStmt(const ASTContext &C, Stmt *Init, VarDecl *Var, Expr *cond)
Base for LValueReferenceType and RValueReferenceType.
const Expr * getInputExpr(unsigned i) const
ForStmt(const ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar, Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP, SourceLocation RP)
SourceManager & getSourceManager()
SEHFinallyStmt * getFinallyHandler() const
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
void Deallocate(void *Ptr) const
Defines the clang::SourceLocation class and associated facilities.
VariableCaptureKind
The different capture forms: by 'this', by reference, capture for variable-length array type etc...
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CapturedRegionKind
The different kinds of captured statement.
static StmtClassNameTable & getStmtInfoTableEntry(Stmt::StmtClass E)
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
const LangOptions & getLangOpts() const
static SEHExceptStmt * Create(const ASTContext &C, SourceLocation ExceptLoc, Expr *FilterExpr, Stmt *Block)
This class handles loading and caching of source files into memory.
void setCapturedRegionKind(CapturedRegionKind Kind)
Set the captured region kind.
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
static void EnableStatistics()
#define BLOCK(DERIVED, BASE)