26#include "llvm/ADT/ArrayRef.h"
27#include "llvm/ADT/StringExtras.h"
28#include "llvm/ADT/StringSet.h"
29#include "llvm/MC/MCParser/MCAsmParser.h"
30#include "llvm/Support/TextEncoding.h"
38 Expr *ExprUnderCast =
nullptr;
42 ParentsToUpdate.push_back(Parent);
43 if (
auto *ParenE = dyn_cast<ParenExpr>(Parent)) {
44 Parent = ParenE->getSubExpr();
48 Expr *Child =
nullptr;
49 CastExpr *ParentCast = dyn_cast<CastExpr>(Parent);
55 if (
auto *CastE = dyn_cast<CastExpr>(Child))
56 if (CastE->getCastKind() == CK_LValueToRValue) {
57 ExprUnderCast = CastE->getSubExpr();
66 assert(ExprUnderCast &&
67 "Should be reachable only if LValueToRValue cast was found!");
69 for (
Expr *E : ParentsToUpdate)
115 for (
unsigned p = 0, e = AsmStrPieces.size(); p != e; ++p) {
132 if (!
Func->hasAttr<NakedAttr>())
136 WorkList.push_back(E);
137 while (WorkList.size()) {
138 Expr *E = WorkList.pop_back_val();
141 S.
Diag(
Func->getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
146 S.
Diag(DRE->getBeginLoc(), diag::err_asm_naked_parm_ref);
147 S.
Diag(
Func->getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
152 if (
Expr *E = dyn_cast_or_null<Expr>(Child))
153 WorkList.push_back(E);
163 bool is_input_expr) {
169 } EType = ExprSafeType;
174 EType = ExprBitfield;
176 EType = ExprVectorElt;
178 EType = ExprGlobalRegVar;
180 if (EType != ExprSafeType) {
181 S.
Diag(E->
getBeginLoc(), diag::err_asm_non_addr_value_in_memory_constraint)
197 const VarDecl *Variable = dyn_cast<VarDecl>(AsmDeclRef->getDecl());
198 if (Variable && Variable->getStorageClass() ==
SC_Register) {
199 if (AsmLabelAttr *
Attr = Variable->getAttr<AsmLabelAttr>())
200 if (
Target.isValidGCCRegisterName(
Attr->getLabel()))
201 return Target.getNormalizedGCCRegisterName(
Attr->getLabel(),
true);
212 Expr **Clobbers,
int NumClobbers,
unsigned NumLabels,
214 llvm::StringSet<> InOutVars;
217 for (
unsigned int i = 0; i < Exprs.size() - NumLabels; ++i) {
218 std::string Constraint =
220 StringRef InOutReg =
Target.getConstraintRegister(
223 InOutVars.insert(InOutReg);
227 for (
int i = 0; i < NumClobbers; ++i) {
228 std::string Clobber =
232 if (Clobber ==
"cc" || Clobber ==
"memory" || Clobber ==
"unwind")
234 Clobber =
Target.getNormalizedGCCRegisterName(Clobber,
true);
236 if (InOutVars.count(Clobber))
247 if (
auto *SL = dyn_cast<StringLiteral>(
Expr)) {
248 assert(SL->isOrdinary());
249 if (ForAsmLabel && SL->getString().empty()) {
251 << SL->getSourceRange();
255 PP.getTextEncoding().getzOSFromAsmLiteralEncodingConverter() !=
258 [[maybe_unused]] std::error_code EC =
259 PP.getTextEncoding().getzOSFromAsmLiteralEncodingConverter()->convert(
260 SL->getString(), ConvertedAsm);
261 assert(!EC &&
"This conversion should always succeed");
263 ConvertedAsm.size());
266 false, StrTy, SL->getBeginLoc());
279 if (ForAsmLabel &&
V.getArrayInitializedElts() == 0) {
285 if (llvm::TextEncodingConverter *FromLiteral =
286 PP.getTextEncoding().getFromLiteralEncodingConverter()) {
287 std::string Raw =
V.getCharArrayAsString();
289 if (std::error_code EC = FromLiteral->convert(Raw, Converted)) {
291 << EC.message() << 2;
295 Context.CharTy->isUnsignedIntegerType());
297 for (
unsigned I = 0; I < Converted.size(); ++I) {
298 Proto =
static_cast<unsigned char>(Converted[I]);
299 V.getArrayInitializedElt(I) =
APValue(Proto);
307 bool IsVolatile,
unsigned NumOutputs,
313 unsigned NumClobbers = clobbers.size();
318 llvm::StringMap<bool> FeatureMap;
319 Context.getFunctionFeatureMap(FeatureMap, FD);
321 auto CreateGCCAsmStmt = [&] {
324 Names, constraints.data(), Exprs.data(), asmString,
325 NumClobbers, clobbers.data(), NumLabels, RParenLoc);
331 [](
Expr *E) { return E->getDependence() != ExprDependence::None; }) ||
332 llvm::any_of(clobbers, [](
Expr *E) {
333 return E->getDependence() != ExprDependence::None;
335 return CreateGCCAsmStmt();
337 for (
unsigned i = 0; i != NumOutputs; i++) {
338 Expr *Constraint = constraints[i];
339 StringRef OutputName;
341 OutputName = Names[i]->
getName();
343 std::string ConstraintStr =
346 if (ConstraintStr.find(
'\0') != std::string::npos) {
347 Diag(Constraint->
getBeginLoc(), diag::err_asm_constraint_embedded_null)
349 return CreateGCCAsmStmt();
353 if (!
Context.getTargetInfo().validateOutputConstraint(Info) &&
356 diag::err_asm_invalid_output_constraint)
358 return CreateGCCAsmStmt();
367 Expr *OutputExpr = Exprs[i];
386 OutputConstraintInfos.push_back(Info);
410 diag::err_dereference_incomplete_type))
415 diag::err_asm_invalid_lvalue_in_output)
420 if (!
Context.getTargetInfo().validateOutputSize(
426 return CreateGCCAsmStmt();
432 for (
unsigned i = NumOutputs, e = NumOutputs + NumInputs; i != e; i++) {
433 Expr *Constraint = constraints[i];
437 InputName = Names[i]->
getName();
439 std::string ConstraintStr =
442 if (ConstraintStr.find(
'\0') != std::string::npos) {
443 Diag(Constraint->
getBeginLoc(), diag::err_asm_constraint_embedded_null)
445 return CreateGCCAsmStmt();
449 if (!
Context.getTargetInfo().validateInputConstraint(OutputConstraintInfos,
452 diag::err_asm_invalid_input_constraint)
454 return CreateGCCAsmStmt();
462 Expr *InputExpr = Exprs[i];
466 diag::err_asm_pmf_through_constraint_not_permitted)
482 diag::err_asm_invalid_lvalue_in_input)
490 InputExpr = Exprs[i] =
Result.get();
501 llvm::APSInt IntResult;
507 diag::err_invalid_asm_value_for_constraint)
530 InputConstraintInfos.push_back(Info);
532 const Type *Ty = Exprs[i]->getType().getTypePtr();
538 diag::err_dereference_incomplete_type))
541 unsigned Size =
Context.getTypeSize(Ty);
542 if (!
Context.getTargetInfo().validateInputSize(FeatureMap, ConstraintStr,
545 diag::err_asm_invalid_input_size)
549 std::optional<SourceLocation> UnwindClobberLoc;
552 for (
unsigned i = 0; i != NumClobbers; i++) {
553 Expr *ClobberExpr = clobbers[i];
555 std::string Clobber =
558 if (Clobber.find(
'\0') != std::string::npos) {
559 Diag(ClobberExpr->
getBeginLoc(), diag::err_asm_constraint_embedded_null)
561 return CreateGCCAsmStmt();
564 if (!
Context.getTargetInfo().isValidClobber(Clobber)) {
566 diag::err_asm_unknown_register_name)
569 Context, AsmLoc, IsSimple, IsVolatile, NumOutputs, NumInputs, Names,
570 constraints.data(), Exprs.data(), asmString, NumClobbers,
571 clobbers.data(), NumLabels, RParenLoc);
574 if (Clobber ==
"unwind") {
580 if (UnwindClobberLoc && NumLabels > 0) {
581 targetDiag(*UnwindClobberLoc, diag::err_asm_unwind_and_goto);
582 return CreateGCCAsmStmt();
589 auto GetLocation = [
this](
const Expr *Str,
unsigned Offset) {
590 if (
auto *SL = dyn_cast<StringLiteral>(Str))
597 if (
unsigned DiagID =
NS->AnalyzeAsmString(Pieces,
Context, DiagOffs)) {
598 targetDiag(GetLocation(asmString, DiagOffs), DiagID)
604 for (
unsigned i = 0, e = Pieces.size(); i != e; ++i) {
610 unsigned NumOperands =
NS->getNumOutputs() +
NS->getNumInputs();
612 if (
NS->isAsmGoto() && ConstraintIdx >= NumOperands)
616 if (ConstraintIdx >= NumOperands) {
617 unsigned I = 0, E =
NS->getNumOutputs();
619 for (
unsigned Cnt = ConstraintIdx - NumOperands; I != E; ++I)
620 if (OutputConstraintInfos[I].isReadWrite() && Cnt-- == 0) {
625 assert(I != E &&
"Invalid operand number should have been caught in "
626 " AnalyzeAsmString");
630 Expr *Constraint = constraints[ConstraintIdx];
631 const Type *Ty = Exprs[ConstraintIdx]->getType().getTypePtr();
635 unsigned Size =
Context.getTypeSize(Ty);
636 std::string SuggestedModifier;
637 if (!
Context.getTargetInfo().validateConstraintModifier(
640 targetDiag(Exprs[ConstraintIdx]->getBeginLoc(),
641 diag::warn_asm_mismatched_size_modifier);
643 if (!SuggestedModifier.empty()) {
645 diag::note_asm_missing_constraint_modifier)
646 << SuggestedModifier;
648 SuggestedModifier =
"%" + SuggestedModifier + Piece.
getString();
657 unsigned NumAlternatives = ~0
U;
658 for (
unsigned i = 0, e = OutputConstraintInfos.size(); i != e; ++i) {
661 unsigned AltCount = ConstraintStr.count(
',') + 1;
662 if (NumAlternatives == ~0
U) {
663 NumAlternatives = AltCount;
664 }
else if (NumAlternatives != AltCount) {
666 diag::err_asm_unexpected_constraint_alternatives)
667 << NumAlternatives << AltCount;
673 for (
unsigned i = 0, e = InputConstraintInfos.size(); i != e; ++i) {
676 unsigned AltCount = ConstraintStr.count(
',') + 1;
677 if (NumAlternatives == ~0
U) {
678 NumAlternatives = AltCount;
679 }
else if (NumAlternatives != AltCount) {
681 diag::err_asm_unexpected_constraint_alternatives)
682 << NumAlternatives << AltCount;
692 unsigned InputOpNo = i+NumOutputs;
693 Expr *OutputExpr = Exprs[TiedTo];
694 Expr *InputExpr = Exprs[InputOpNo];
697 assert(TiedTo < InputMatchedToOutput.size() &&
"TiedTo value out of range");
698 if (InputMatchedToOutput[TiedTo] != ~0
U) {
700 diag::err_asm_input_duplicate_match)
702 targetDiag(
NS->getInputExpr(InputMatchedToOutput[TiedTo])->getBeginLoc(),
703 diag::note_asm_input_duplicate_first)
707 InputMatchedToOutput[TiedTo] = i;
714 if (
Context.hasSameType(InTy, OutTy))
720 AD_Int, AD_FP, AD_Other
721 } InputDomain, OutputDomain;
724 InputDomain = AD_Int;
728 InputDomain = AD_Other;
731 OutputDomain = AD_Int;
733 OutputDomain = AD_FP;
735 OutputDomain = AD_Other;
743 uint64_t OutSize =
Context.getTypeSize(OutTy);
744 uint64_t InSize =
Context.getTypeSize(InTy);
745 if (OutSize == InSize && InputDomain == OutputDomain &&
746 InputDomain != AD_Other)
752 bool SmallerValueMentioned =
false;
760 SmallerValueMentioned |= InSize < OutSize;
765 SmallerValueMentioned |= OutSize < InSize;
770 bool FPTiedToInt = (InputDomain == AD_FP) ^ (OutputDomain == AD_FP);
775 if (!SmallerValueMentioned && !FPTiedToInt && InputDomain != AD_Other &&
776 OutputConstraintInfos[TiedTo].allowsRegister()) {
781 bool FitsInGeneralPurposeRegister =
782 OutSize <=
Context.getTargetInfo().getRegisterWidth() &&
783 !
Context.getIntTypeForBitwidth(OutSize,
false).isNull();
784 if (OutputDomain == AD_Other && !FitsInGeneralPurposeRegister) {
796 if (InputDomain == AD_Int && OutputDomain == AD_Int &&
800 (OutTy->
isBooleanType() ? CK_IntegralToBoolean : CK_IntegralCast);
802 Exprs[InputOpNo] = InputExpr;
803 NS->setInputExpr(i, InputExpr);
815 Exprs, constraints.data(), clobbers.data(), NumClobbers, NumLabels,
818 targetDiag(ConstraintLoc, diag::error_inoutput_conflict_with_clobber);
821 typedef std::pair<StringRef , Expr *> NamedOperand;
823 for (
unsigned i = 0, e = NumOutputs + NumInputs + NumLabels; i != e; ++i)
825 NamedOperandList.emplace_back(
826 std::make_pair(Names[i]->getName(), Exprs[i]));
828 llvm::stable_sort(NamedOperandList, llvm::less_first());
831 std::adjacent_find(begin(NamedOperandList), end(NamedOperandList),
832 [](
const NamedOperand &LHS,
const NamedOperand &RHS) {
833 return LHS.first == RHS.first;
835 if (
Found != NamedOperandList.end()) {
837 diag::error_duplicate_asm_operand_name)
838 << (
Found + 1)->first;
839 Diag(
Found->second->getBeginLoc(), diag::note_duplicate_asm_operand_name)
852 llvm::InlineAsmIdentifierInfo &Info) {
855 if (
T->isFunctionType() ||
T->isDependentType())
856 return Info.setLabel(Res);
859 if (
DeclRefExpr *DRE = dyn_cast<clang::DeclRefExpr>(Res))
860 if (DRE->getDecl()->getKind() == Decl::EnumConstant)
863 return Info.setEnum(Eval.
Val.
getInt().getSExtValue());
865 return Info.setLabel(Res);
867 unsigned Size =
Context.getTypeSizeInChars(
T).getQuantity();
868 unsigned Type = Size;
869 if (
const auto *ATy =
Context.getAsArrayType(
T))
870 Type =
Context.getTypeSizeInChars(ATy->getElementType()).getQuantity();
871 bool IsGlobalLV =
false;
874 Info.setVar(Res, IsGlobalLV, Size,
Type);
880 bool IsUnevaluatedContext) {
882 if (IsUnevaluatedContext)
893 if (IsUnevaluatedContext)
907 if (
T->isDependentType()) {
912 if (
T->isFunctionType()) {
928 Member.split(Members,
".");
935 FoundDecl = PT->getPointeeType()->getAsTagDecl();
946 for (StringRef NextMember : Members) {
947 const RecordType *RT =
nullptr;
948 if (
VarDecl *VD = dyn_cast<VarDecl>(FoundDecl))
949 RT = VD->getType()->getAsCanonical<RecordType>();
953 QualType QT = TD->getUnderlyingType();
957 }
else if (
TypeDecl *TD = dyn_cast<TypeDecl>(FoundDecl))
960 else if (
FieldDecl *TD = dyn_cast<FieldDecl>(FoundDecl))
961 RT = TD->getType()->getAsCanonical<RecordType>();
966 diag::err_asm_incomplete_type))
981 FieldDecl *FD = dyn_cast<FieldDecl>(FoundDecl);
988 Offset += (unsigned)
Result.getQuantity();
999 if (
T->isDependentType()) {
1006 nullptr, NameInfo,
nullptr);
1009 auto *RD =
T->getAsRecordDecl();
1023 FD = dyn_cast<IndirectFieldDecl>(FieldResult.
getFoundDecl());
1037 StringRef AsmString,
1038 unsigned NumOutputs,
unsigned NumInputs,
1043 bool IsSimple = (NumOutputs != 0 || NumInputs != 0);
1046 bool InvalidOperand =
false;
1047 for (uint64_t I = 0; I < NumOutputs + NumInputs; ++I) {
1050 InvalidOperand =
true;
1052 << E->
getType() << (I < NumOutputs)
1055 InvalidOperand =
true;
1067 true, AsmToks, NumOutputs, NumInputs,
1068 Constraints, Exprs, AsmString,
1075 bool AlwaysCreate) {
1084 std::string InternalName;
1085 llvm::raw_string_ostream
OS(InternalName);
1091 OS <<
"__MSASMLABEL_.${:uid}__";
1092 for (
char C : ExternalLabelName) {
Defines the clang::Expr interface and subclasses for C++ expressions.
llvm::MachO::Target Target
Defines the clang::Preprocessor interface.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
This file declares semantic analysis functions specific to BPF.
static bool isOperandMentioned(unsigned OpNo, ArrayRef< GCCAsmStmt::AsmStringPiece > AsmStrPieces)
isOperandMentioned - Return true if the specified operand # is mentioned anywhere in the decomposed a...
static SourceLocation getClobberConflictLocation(MultiExprArg Exprs, Expr **Constraints, Expr **Clobbers, int NumClobbers, unsigned NumLabels, const TargetInfo &Target, ASTContext &Cont)
static bool CheckAsmLValue(Expr *E, Sema &S)
CheckAsmLValue - GNU C has an extremely ugly extension whereby they silently ignore "noop" casts in p...
static StringRef extractRegisterName(const Expr *Expression, const TargetInfo &Target)
static bool CheckNakedParmReference(Expr *E, Sema &S)
static bool checkExprMemoryConstraintCompat(Sema &S, Expr *E, TargetInfo::ConstraintInfo &Info, bool is_input_expr)
Returns true if given expression is not compatible with inline assembly's memory constraint; false ot...
static void removeLValueToRValueCast(Expr *E)
Remove the upper-level LValueToRValue cast from an expression.
static void emitAndFixInvalidAsmCastLValue(const Expr *LVal, Expr *BadArgument, Sema &S)
Emit a warning about usage of "noop"-like casts for lvalues (GNU extension) and fix the argument with...
Defines the clang::TypeLoc interface and its subclasses.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
bool toIntegralConstant(APSInt &Result, QualType SrcTy, const ASTContext &Ctx) const
Try to convert this value to an integral constant.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
Attr - This represents one attribute.
static CXXDependentScopeMemberExpr * Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Represents a C++ nested-name-specifier or a global scope specifier.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
SourceLocation getBegin() const
This is an opaque type for sizes expressed in character units.
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
A reference to a declared variable, function, enum, etc.
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
SourceLocation getLocation() const
void setLocation(SourceLocation L)
This represents one expression.
Expr * IgnoreParenNoopCasts(const ASTContext &Ctx) LLVM_READONLY
Skip past any parentheses and casts which do not change the value (including ptr->int casts of the sa...
isModifiableLvalueResult isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc=nullptr) const
isModifiableLvalue - C99 6.3.2.1: an lvalue that does not have array type, does not have an incomplet...
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool refersToVectorElement() const
Returns whether this expression refers to a vector element.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool EvaluateAsLValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsLValue - Evaluate an expression to see if we can fold it to an lvalue with link time known ...
bool isEvaluatable(const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
isEvaluatable - Call EvaluateAsRValue to see if this expression can be constant folded without side-e...
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
bool refersToGlobalRegisterVar() const
Returns whether this expression refers to a global register variable.
ExprDependence getDependence() const
Represents a member of a struct/union/class.
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
Represents a function declaration or definition.
AsmStringPiece - this is part of a decomposed asm string specification (for use with the AnalyzeAsmSt...
const std::string & getString() const
unsigned getOperandNo() const
CharSourceRange getRange() const
char getModifier() const
getModifier - Get the modifier for this operand, if present.
This represents a GCC inline-assembly statement extension.
static std::string ExtractStringFromGCCAsmStmtComponent(const Expr *E)
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
Represents the declaration of a label.
void setMSAsmLabel(StringRef Name)
void setMSAsmLabelResolved()
bool isMSAsmLabel() const
Represents the results of name lookup.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
This represents a Microsoft inline-assembly statement extension.
This represents a decl that may have a name.
A C++ nested-name-specifier augmented with source location information.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
Represents a struct/union/class.
RecordDecl * getDefinitionOrSelf() const
Expr * checkAsmImmediateOperand(Expr *E)
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Sema - This implements semantic analysis and AST building for C.
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
Scope * getCurScope() const
Retrieve the parser's current scope.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, ArrayRef< Token > AsmToks, StringRef AsmString, unsigned NumOutputs, unsigned NumInputs, ArrayRef< StringRef > Constraints, ArrayRef< StringRef > Clobbers, ArrayRef< Expr * > Exprs, SourceLocation EndLoc)
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
void setFunctionHasBranchIntoScope()
ExprResult LookupInlineAsmIdentifier(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool IsUnevaluatedContext)
void CleanupVarDeclMarking()
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
ASTContext & getASTContext() const
void PopExpressionEvaluationContext()
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
const LangOptions & getLangOpts() const
bool RequireCompleteExprType(Expr *E, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type of the given expression is complete.
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false)
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
const LangOptions & LangOpts
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
DeclContext * getCurLexicalContext() const
bool EvaluateAsString(Expr *Message, APValue &Result, ASTContext &Ctx, StringEvaluationContext EvalContext, bool ErrorOnInvalidMessage)
SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL, unsigned ByteNo) const
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void FillInlineAsmIdentifierInfo(Expr *Res, llvm::InlineAsmIdentifierInfo &Info)
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset, SourceLocation AsmLoc)
ExprResult LookupInlineAsmVarDeclField(Expr *RefExpr, StringRef Member, SourceLocation AsmLoc)
LabelDecl * LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc, SourceLocation GnuLabelLoc=SourceLocation(), bool IsLabelStmt=false)
LookupOrCreateLabel - Do a name lookup of a label with the specified name.
void setFunctionHasBranchProtectedScope()
@ UnevaluatedAbstract
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
ExprResult ActOnGCCAsmStmtString(Expr *Stm, bool ForAsmLabel, bool IsConstexpr=false)
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
void DiscardCleanupsInEvaluationContext()
LabelDecl * GetOrCreateMSAsmLabel(StringRef ExternalLabelName, SourceLocation Location, bool AlwaysCreate)
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, bool IsVolatile, unsigned NumOutputs, unsigned NumInputs, IdentifierInfo **Names, MultiExprArg Constraints, MultiExprArg Exprs, Expr *AsmString, MultiExprArg Clobbers, unsigned NumLabels, SourceLocation RParenLoc)
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
Stmt - This represents one statement.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringLiteralKind Kind, bool Pascal, QualType Ty, ArrayRef< SourceLocation > Locs)
This is the "fully general" constructor that allows representation of strings formed from one or more...
Exposes information about the current target.
Represents a declaration of a type.
The base class of the type hierarchy.
bool isBooleanType() const
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isBitIntType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isMemberPointerType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isRealFloatingType() const
Floating point categories.
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
const T * getAs() const
Member-template getAs<specific type>'.
Base class for declarations which introduce a typedef-name.
Represents a C++ unqualified-id that has been parsed.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
Defines the clang::TargetInfo interface.
Top level wrappers for InstallAPI frontend operations.
bool isa(CodeGen::Address addr)
MutableArrayRef< Expr * > MultiExprArg
@ Result
The result type of a method or function.
const FunctionProtoType * T
ActionResult< CXXBaseSpecifier * > BaseResult
CastKind
CastKind - The kind of operation required for a conversion.
ActionResult< Expr * > ExprResult
ActionResult< Stmt * > StmtResult
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
bool isGlobalLValue() const
Return true if the evaluated lvalue expression is global.
const std::string & getConstraintStr() const
unsigned getTiedOperand() const
bool allowsMemory() const
bool isValidAsmImmediate(const llvm::APInt &Value) const
bool requiresImmediateConstant() const
bool hasTiedOperand() const
Return true if this input operand is a matching constraint that ties it to an output operand.
bool allowsRegister() const