18#include "llvm/ADT/SmallString.h"
19#include "llvm/ADT/StringExtras.h"
20#include "llvm/MC/MCAsmInfo.h"
21#include "llvm/MC/MCContext.h"
22#include "llvm/MC/MCInstPrinter.h"
23#include "llvm/MC/MCInstrInfo.h"
24#include "llvm/MC/MCObjectFileInfo.h"
25#include "llvm/MC/MCParser/MCAsmParser.h"
26#include "llvm/MC/MCParser/MCTargetAsmParser.h"
27#include "llvm/MC/MCRegisterInfo.h"
28#include "llvm/MC/MCStreamer.h"
29#include "llvm/MC/MCSubtargetInfo.h"
30#include "llvm/MC/MCTargetOptions.h"
31#include "llvm/MC/TargetRegistry.h"
32#include "llvm/Support/SourceMgr.h"
33#include "llvm/Support/TargetSelect.h"
37class ClangAsmParserCallback :
public llvm::MCAsmParserSemaCallback {
51 : TheParser(
P), AsmLoc(
Loc), AsmString(AsmString), AsmToks(Toks),
52 AsmTokOffsets(Offsets) {
53 assert(AsmToks.size() == AsmTokOffsets.size());
56 void LookupInlineAsmIdentifier(StringRef &LineBuf,
57 llvm::InlineAsmIdentifierInfo &Info,
58 bool IsUnevaluatedContext)
override;
60 StringRef LookupInlineAsmLabel(StringRef
Identifier, llvm::SourceMgr &LSM,
64 bool LookupInlineAsmField(StringRef
Base, StringRef
Member,
65 unsigned &Offset)
override {
70 static void DiagHandlerCallback(
const llvm::SMDiagnostic &
D,
void *Context) {
71 ((ClangAsmParserCallback *)Context)->handleDiagnostic(
D);
77 const Token *&FirstOrigToken)
const;
82 void handleDiagnostic(
const llvm::SMDiagnostic &
D);
86void ClangAsmParserCallback::LookupInlineAsmIdentifier(
87 StringRef &LineBuf, llvm::InlineAsmIdentifierInfo &Info,
88 bool IsUnevaluatedContext) {
91 const Token *FirstOrigToken =
nullptr;
92 findTokensForString(LineBuf, LineToks, FirstOrigToken);
94 unsigned NumConsumedToks;
96 IsUnevaluatedContext);
100 if (NumConsumedToks == 0 || NumConsumedToks == LineToks.size()) {
105 assert(FirstOrigToken &&
"not using original tokens?");
108 assert(FirstOrigToken[NumConsumedToks].getLocation() ==
109 LineToks[NumConsumedToks].getLocation());
110 unsigned FirstIndex = FirstOrigToken - AsmToks.begin();
111 unsigned LastIndex = FirstIndex + NumConsumedToks - 1;
115 unsigned TotalOffset =
116 (AsmTokOffsets[LastIndex] + AsmToks[LastIndex].getLength() -
117 AsmTokOffsets[FirstIndex]);
118 LineBuf = LineBuf.substr(0, TotalOffset);
122 if (!Result.isUsable())
127StringRef ClangAsmParserCallback::LookupInlineAsmLabel(StringRef
Identifier,
128 llvm::SourceMgr &LSM,
129 llvm::SMLoc Location,
134 return Label->getMSAsmLabel();
137void ClangAsmParserCallback::findTokensForString(
139 const Token *&FirstOrigToken)
const {
142 assert(!std::less<const char *>()(Str.begin(), AsmString.begin()) &&
143 !std::less<const char *>()(AsmString.end(), Str.end()));
146 unsigned FirstCharOffset = Str.begin() - AsmString.begin();
147 const unsigned *FirstTokOffset =
148 llvm::lower_bound(AsmTokOffsets, FirstCharOffset);
152 assert(*FirstTokOffset == FirstCharOffset);
156 unsigned FirstTokIndex = FirstTokOffset - AsmTokOffsets.begin();
157 FirstOrigToken = &AsmToks[FirstTokIndex];
158 unsigned LastCharOffset = Str.end() - AsmString.begin();
159 for (
unsigned i = FirstTokIndex, e = AsmTokOffsets.size(); i != e; ++i) {
160 if (AsmTokOffsets[i] >= LastCharOffset)
162 TempToks.push_back(AsmToks[i]);
167ClangAsmParserCallback::translateLocation(
const llvm::SourceMgr &LSM,
172 const llvm::MemoryBuffer *LBuf =
173 LSM.getMemoryBuffer(LSM.FindBufferContainingLoc(SMLoc));
174 unsigned Offset = SMLoc.getPointer() - LBuf->getBufferStart();
177 const unsigned *TokOffsetPtr = llvm::lower_bound(AsmTokOffsets, Offset);
178 unsigned TokIndex = TokOffsetPtr - AsmTokOffsets.begin();
179 unsigned TokOffset = *TokOffsetPtr;
185 if (TokIndex < AsmToks.size()) {
186 const Token &Tok = AsmToks[TokIndex];
193void ClangAsmParserCallback::handleDiagnostic(
const llvm::SMDiagnostic &
D) {
194 const llvm::SourceMgr &LSM = *
D.getSourceMgr();
196 TheParser.
Diag(
Loc, diag::err_inline_ms_asm_parsing) <<
D.getMessage();
201 unsigned &NumLineToksConsumed,
202 bool IsUnevaluatedContext) {
207 Token EndOfStreamTok;
209 EndOfStreamTok.
setKind(EndOfStream);
210 LineToks.push_back(EndOfStreamTok);
213 LineToks.push_back(Tok);
215 PP.EnterTokenStream(LineToks,
true,
224 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
233 if (Tok.
is(tok::kw_this)) {
243 false, &TemplateKWLoc,
Id);
246 IsUnevaluatedContext);
251 while (
Result.isUsable() && Tok.
is(tok::period)) {
253 if (IdTok.
isNot(tok::identifier))
263 unsigned LineIndex = 0;
264 if (Tok.
is(EndOfStream)) {
265 LineIndex = LineToks.size() - 2;
267 while (LineToks[LineIndex].getLocation() != Tok.
getLocation()) {
269 assert(LineIndex < LineToks.size() - 2);
275 if (Invalid || Tok.
is(EndOfStream)) {
276 NumLineToksConsumed = LineToks.size() - 2;
279 NumLineToksConsumed = LineIndex;
284 for (
unsigned i = 0, e = LineToks.size() - LineIndex - 2; i != e; ++i) {
287 assert(Tok.
is(EndOfStream));
303 assert(!AsmToks.empty() &&
"Didn't expect an empty AsmToks!");
306 bool isNewStatement =
true;
308 for (
unsigned i = 0, e = AsmToks.size(); i < e; ++i) {
309 const Token &Tok = AsmToks[i];
314 isNewStatement =
true;
323 TokOffsets.push_back(
Asm.size());
326 if (Tok.
is(tok::kw_asm)) {
329 PP.
Diag(AsmLoc, diag::err_asm_empty);
338 bool SpellingInvalid =
false;
340 assert(!SpellingInvalid &&
"spelling was invalid after correct parse?");
343 isNewStatement =
false;
350 assert(TokOffsets.size() == AsmToks.size());
355bool Parser::isGCCAsmStatement(
const Token &TokAfterAsm)
const {
356 return TokAfterAsm.
is(tok::l_paren) || isGNUAsmQualifier(TokAfterAsm);
359bool Parser::isGNUAsmQualifier(
const Token &TokAfterAsm)
const {
360 return getGNUAsmQualifier(TokAfterAsm) != GNUAsmQualifiers::AQ_unspecified;
383 bool SingleLineMode =
true;
384 unsigned BraceNesting = 0;
385 unsigned short savedBraceCount = BraceCount;
386 bool InAsmComment =
false;
389 unsigned NumTokensRead = 0;
391 bool SkippedStartOfLine =
false;
393 if (Tok.
is(tok::l_brace)) {
395 SingleLineMode =
false;
397 EndLoc = ConsumeBrace();
398 LBraceLocs.push_back(EndLoc);
402 std::pair<FileID, unsigned> ExpAsmLoc =
404 FID = ExpAsmLoc.first;
415 if (!InAsmComment && Tok.
is(tok::l_brace)) {
418 AsmToks.push_back(Tok);
419 EndLoc = ConsumeBrace();
421 LBraceLocs.push_back(EndLoc);
425 }
else if (!InAsmComment && Tok.
is(tok::semi)) {
428 if (!SingleLineMode) {
430 std::pair<FileID, unsigned> ExpSemiLoc =
432 FID = ExpSemiLoc.first;
435 }
else if (SingleLineMode || InAsmComment) {
438 std::pair<FileID, unsigned> ExpLoc =
440 if (ExpLoc.first != FID ||
441 SrcMgr.
getLineNumber(ExpLoc.first, ExpLoc.second) != LineNo) {
446 bool isAsm = Tok.
is(tok::kw_asm);
447 if (SingleLineMode && (!isAsm || isGCCAsmStatement(
NextToken())))
450 InAsmComment =
false;
458 }
else if (Tok.
is(tok::semi)) {
464 }
else if (!InAsmComment && Tok.
is(tok::r_brace)) {
472 if (!InAsmComment && BraceNesting && Tok.
is(tok::r_brace) &&
473 BraceCount == (savedBraceCount + BraceNesting)) {
477 if (SingleLineMode || BraceNesting > 1) {
479 AsmToks.push_back(Tok);
481 EndLoc = ConsumeBrace();
485 if (BraceNesting == 0 && !SingleLineMode)
488 LBraceLocs.pop_back();
503 if (SkippedStartOfLine)
505 AsmToks.push_back(Tok);
510 SkippedStartOfLine =
false;
513 if (BraceNesting && BraceCount != savedBraceCount) {
515 for (
unsigned i = 0; i < BraceNesting; ++i) {
516 Diag(Tok, diag::err_expected) << tok::r_brace;
517 Diag(LBraceLocs.back(), diag::note_matching) << tok::l_brace;
518 LBraceLocs.pop_back();
521 }
else if (NumTokensRead == 0) {
523 Diag(Tok, diag::err_expected) << tok::l_brace;
534 const std::string &TT = TheTriple.getTriple();
535 const llvm::Target *TheTarget =
nullptr;
536 if (!TheTriple.isX86()) {
537 Diag(AsmLoc, diag::err_msasm_unsupported_arch) << TheTriple.getArchName();
540 TheTarget = llvm::TargetRegistry::lookupTarget(TT, Error);
542 Diag(AsmLoc, diag::err_msasm_unable_to_create_target) <<
Error;
545 assert(!LBraceLocs.empty() &&
"Should have at least one location here");
548 auto EmptyStmt = [&] {
549 return Actions.
ActOnMSAsmStmt(AsmLoc, LBraceLocs[0], AsmToks, AsmString,
551 ConstraintRefs, ClobberRefs, Exprs, EndLoc);
555 if (!TheTarget || AsmToks.empty()) {
565 std::string FeaturesStr =
568 std::unique_ptr<llvm::MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TT));
570 Diag(AsmLoc, diag::err_msasm_unable_to_create_target)
571 <<
"target MC unavailable";
575 llvm::MCTargetOptions MCOptions;
576 std::unique_ptr<llvm::MCAsmInfo> MAI(
577 TheTarget->createMCAsmInfo(*MRI, TT, MCOptions));
579 std::unique_ptr<llvm::MCInstrInfo> MII(TheTarget->createMCInstrInfo());
580 std::unique_ptr<llvm::MCSubtargetInfo> STI(
581 TheTarget->createMCSubtargetInfo(TT, TO.
CPU, FeaturesStr));
584 if (!MAI || !MII || !STI) {
585 Diag(AsmLoc, diag::err_msasm_unable_to_create_target)
586 <<
"target MC unavailable";
590 llvm::SourceMgr TempSrcMgr;
591 llvm::MCContext Ctx(TheTriple, MAI.get(), MRI.get(), STI.get(), &TempSrcMgr);
592 std::unique_ptr<llvm::MCObjectFileInfo> MOFI(
593 TheTarget->createMCObjectFileInfo(Ctx,
false));
594 Ctx.setObjectFileInfo(MOFI.get());
596 std::unique_ptr<llvm::MemoryBuffer> Buffer =
597 llvm::MemoryBuffer::getMemBuffer(AsmString,
"<MS inline asm>");
600 TempSrcMgr.AddNewSourceBuffer(std::move(Buffer), llvm::SMLoc());
602 std::unique_ptr<llvm::MCStreamer> Str(createNullStreamer(Ctx));
603 std::unique_ptr<llvm::MCAsmParser>
Parser(
604 createMCAsmParser(TempSrcMgr, Ctx, *Str.get(), *MAI));
606 std::unique_ptr<llvm::MCTargetAsmParser> TargetParser(
607 TheTarget->createMCAsmParser(*STI, *
Parser, *MII, MCOptions));
610 Diag(AsmLoc, diag::err_msasm_unable_to_create_target)
611 <<
"target ASM parser unavailable";
615 std::unique_ptr<llvm::MCInstPrinter> IP(
616 TheTarget->createMCInstPrinter(llvm::Triple(TT), 1, *MAI, *MII, *MRI));
619 Parser->setAssemblerDialect(1);
620 Parser->setTargetParser(*TargetParser.get());
621 Parser->setParsingMSInlineAsm(
true);
622 TargetParser->setParsingMSInlineAsm(
true);
624 ClangAsmParserCallback Callback(*
this, AsmLoc, AsmString, AsmToks,
626 TargetParser->setSemaCallback(&Callback);
627 TempSrcMgr.setDiagHandler(ClangAsmParserCallback::DiagHandlerCallback,
632 std::string AsmStringIR;
636 if (
Parser->parseMSInlineAsm(AsmStringIR, NumOutputs, NumInputs, OpExprs,
637 Constraints, Clobbers, MII.get(), IP.get(),
643 llvm::erase_if(Clobbers, [](
const std::string &
C) {
644 return C ==
"fpsr" ||
C ==
"mxcsr";
648 ClobberRefs.insert(ClobberRefs.end(), Clobbers.begin(), Clobbers.end());
651 unsigned NumExprs = NumOutputs + NumInputs;
652 ConstraintRefs.resize(NumExprs);
653 Exprs.resize(NumExprs);
654 for (
unsigned i = 0, e = NumExprs; i != e; ++i) {
655 Expr *OpExpr =
static_cast<Expr *
>(OpExprs[i].first);
660 if (OpExprs[i].second)
664 ConstraintRefs[i] = StringRef(Constraints[i]);
669 return Actions.
ActOnMSAsmStmt(AsmLoc, LBraceLocs[0], AsmToks, AsmStringIR,
670 NumOutputs, NumInputs, ConstraintRefs,
671 ClobberRefs, Exprs, EndLoc);
683bool Parser::parseGNUAsmQualifierListOpt(GNUAsmQualifiers &AQ) {
685 const GNUAsmQualifiers::AQ A = getGNUAsmQualifier(Tok);
686 if (A == GNUAsmQualifiers::AQ_unspecified) {
687 if (Tok.
isNot(tok::l_paren)) {
694 if (AQ.setAsmQualifier(A))
696 << GNUAsmQualifiers::getQualifierName(A);
721StmtResult Parser::ParseAsmStatement(
bool &msAsm) {
722 assert(Tok.
is(tok::kw_asm) &&
"Not an asm stmt");
725 if (
getLangOpts().AsmBlocks && !isGCCAsmStatement(Tok)) {
727 return ParseMicrosoftAsmStatement(AsmLoc);
731 GNUAsmQualifiers GAQ;
732 if (parseGNUAsmQualifierListOpt(GAQ))
735 if (GAQ.isGoto() &&
getLangOpts().SpeculativeLoadHardening)
736 Diag(
Loc, diag::warn_slh_does_not_support_asm_goto);
741 ExprResult AsmString(ParseAsmStringLiteral(
false));
745 if (!(
getLangOpts().GNUAsm || AsmString.isInvalid())) {
746 const auto *SL = cast<StringLiteral>(AsmString.get());
747 if (!SL->getString().trim().empty())
748 Diag(
Loc, diag::err_gnu_inline_asm_disabled);
751 if (AsmString.isInvalid()) {
758 ExprVector Constraints;
762 if (Tok.
is(tok::r_paren)) {
766 AsmLoc,
true, GAQ.isVolatile(),
767 0, 0,
nullptr, Constraints, Exprs,
768 AsmString.get(), Clobbers, 0,
T.getCloseLocation());
772 bool AteExtraColon =
false;
773 if (Tok.
is(tok::colon) || Tok.
is(tok::coloncolon)) {
775 AteExtraColon = Tok.
is(tok::coloncolon);
778 if (!AteExtraColon && ParseAsmOperandsOpt(Names, Constraints, Exprs))
782 unsigned NumOutputs = Names.size();
785 if (AteExtraColon || Tok.
is(tok::colon) || Tok.
is(tok::coloncolon)) {
788 AteExtraColon =
false;
790 AteExtraColon = Tok.
is(tok::coloncolon);
794 if (!AteExtraColon && ParseAsmOperandsOpt(Names, Constraints, Exprs))
798 assert(Names.size() == Constraints.size() &&
799 Constraints.size() == Exprs.size() &&
"Input operand size mismatch!");
801 unsigned NumInputs = Names.size() - NumOutputs;
804 if (AteExtraColon || Tok.
is(tok::colon) || Tok.
is(tok::coloncolon)) {
806 AteExtraColon =
false;
808 AteExtraColon = Tok.
is(tok::coloncolon);
812 if (!AteExtraColon && isTokenStringLiteral()) {
814 ExprResult Clobber(ParseAsmStringLiteral(
false));
816 if (Clobber.isInvalid())
819 Clobbers.push_back(Clobber.get());
826 if (!GAQ.isGoto() && (Tok.
isNot(tok::r_paren) || AteExtraColon)) {
827 Diag(Tok, diag::err_expected) << tok::r_paren;
833 unsigned NumLabels = 0;
834 if (AteExtraColon || Tok.
is(tok::colon)) {
839 if (Tok.
isNot(tok::identifier)) {
840 Diag(Tok, diag::err_expected) << tok::identifier;
853 Exprs.push_back(Res.
get());
859 }
else if (GAQ.isGoto()) {
860 Diag(Tok, diag::err_expected) << tok::colon;
865 return Actions.
ActOnGCCAsmStmt(AsmLoc,
false, GAQ.isVolatile(), NumOutputs,
866 NumInputs, Names.data(), Constraints, Exprs,
867 AsmString.get(), Clobbers, NumLabels,
868 T.getCloseLocation());
888 if (!isTokenStringLiteral() && Tok.
isNot(tok::l_square))
893 if (Tok.
is(tok::l_square)) {
897 if (Tok.
isNot(tok::identifier)) {
898 Diag(Tok, diag::err_expected) << tok::identifier;
909 Names.push_back(
nullptr);
911 ExprResult Constraint(ParseAsmStringLiteral(
false));
912 if (Constraint.isInvalid()) {
916 Constraints.push_back(Constraint.get());
918 if (Tok.
isNot(tok::l_paren)) {
919 Diag(Tok, diag::err_expected_lparen_after) <<
"asm operand";
933 Exprs.push_back(Res.
get());
940const char *Parser::GNUAsmQualifiers::getQualifierName(AQ Qualifier) {
942 case AQ_volatile:
return "volatile";
943 case AQ_inline:
return "inline";
944 case AQ_goto:
return "goto";
945 case AQ_unspecified:
return "unspecified";
947 llvm_unreachable(
"Unknown GNUAsmQualifier");
950Parser::GNUAsmQualifiers::AQ
951Parser::getGNUAsmQualifier(
const Token &Tok)
const {
953 case tok::kw_volatile:
return GNUAsmQualifiers::AQ_volatile;
954 case tok::kw_inline:
return GNUAsmQualifiers::AQ_inline;
955 case tok::kw_goto:
return GNUAsmQualifiers::AQ_goto;
956 default:
return GNUAsmQualifiers::AQ_unspecified;
959bool Parser::GNUAsmQualifiers::setAsmQualifier(AQ Qualifier) {
Defines the clang::ASTContext interface.
Defines the Diagnostic-related interfaces.
static bool buildMSAsmString(Preprocessor &PP, SourceLocation AsmLoc, ArrayRef< Token > AsmToks, SmallVectorImpl< unsigned > &TokOffsets, SmallString< 512 > &Asm)
Turn a sequence of our tokens back into a string that we can hand to the MC asm parser.
const TargetInfo & getTargetInfo() const
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
Represents a C++ nested-name-specifier or a global scope specifier.
This represents one expression.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
One of these records is kept for each identifier that is lexed.
Represents the declaration of a label.
Parser - This implements a parser for the C family of languages.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
Sema & getActions() const
ExprResult ParseMSAsmIdentifier(llvm::SmallVectorImpl< Token > &LineToks, unsigned &NumLineToksConsumed, bool IsUnevaluated)
Parse an identifier in an MS-style inline assembly block.
bool ParseUnqualifiedId(CXXScopeSpec &SS, ParsedType ObjectType, bool ObjectHadErrors, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, SourceLocation *TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
bool TryConsumeToken(tok::TokenKind Expected)
Scope * getCurScope() const
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
const LangOptions & getLangOpts() const
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
@ StopAtSemi
Stop skipping at semicolon.
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
void Lex(Token &Result)
Lex the next token for this preprocessor.
const Token & LookAhead(unsigned N)
Peeks ahead N tokens and returns that token without consuming any tokens.
SourceManager & getSourceManager() const
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const
Forwarding function for diagnostics.
The collection of all-type qualifiers we support.
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)
ExprResult LookupInlineAsmIdentifier(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool IsUnevaluatedContext)
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input, bool IsAfterAmp=false)
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
void FillInlineAsmIdentifierInfo(Expr *Res, llvm::InlineAsmIdentifierInfo &Info)
bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset, SourceLocation AsmLoc)
LabelDecl * LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc, SourceLocation GnuLabelLoc=SourceLocation())
LookupOrCreateLabel - Do a name lookup of a label with the specified name.
ExprResult LookupInlineAsmVarDeclField(Expr *RefExpr, StringRef Member, SourceLocation AsmLoc)
LabelDecl * GetOrCreateMSAsmLabel(StringRef ExternalLabelName, SourceLocation Location, bool AlwaysCreate)
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
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.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
unsigned getLineNumber(FileID FID, unsigned FilePos, bool *Invalid=nullptr) const
Given a SourceLocation, return the spelling line number for the position indicated.
std::pair< FileID, unsigned > getDecomposedExpansionLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
TargetOptions & getTargetOpts() const
Retrieve the target options.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Options for controlling the target.
std::vector< std::string > Features
The list of target specific features to enable or disable – this should be a list of strings starting...
std::string CPU
If given, the name of the target CPU to generate code for.
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
void clearFlag(TokenFlags Flag)
Unset the specified flag.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
void setKind(tok::TokenKind K)
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
tok::TokenKind getKind() const
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
bool hasLeadingSpace() const
Return true if this token has whitespace before it.
bool isNot(tok::TokenKind K) const
void startToken()
Reset all flags to cleared.
void setFlag(TokenFlags Flag)
Set the specified flag.
Represents a C++ unqualified-id that has been parsed.
Defines the clang::TargetInfo interface.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ Asm
Assembly: we accept this only so that we can preprocess it.
@ Result
The result type of a method or function.
const FunctionProtoType * T