clang  8.0.0svn
SemaStmtAsm.cpp
Go to the documentation of this file.
1 //===--- SemaStmtAsm.cpp - Semantic Analysis for Asm Statements -----------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements semantic analysis for inline asm statements.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "clang/AST/ExprCXX.h"
15 #include "clang/AST/RecordLayout.h"
16 #include "clang/AST/TypeLoc.h"
17 #include "clang/Basic/TargetInfo.h"
18 #include "clang/Lex/Preprocessor.h"
20 #include "clang/Sema/Lookup.h"
21 #include "clang/Sema/Scope.h"
22 #include "clang/Sema/ScopeInfo.h"
24 #include "llvm/ADT/ArrayRef.h"
25 #include "llvm/ADT/StringSet.h"
26 #include "llvm/MC/MCParser/MCAsmParser.h"
27 using namespace clang;
28 using namespace sema;
29 
30 /// CheckAsmLValue - GNU C has an extremely ugly extension whereby they silently
31 /// ignore "noop" casts in places where an lvalue is required by an inline asm.
32 /// We emulate this behavior when -fheinous-gnu-extensions is specified, but
33 /// provide a strong guidance to not use it.
34 ///
35 /// This method checks to see if the argument is an acceptable l-value and
36 /// returns false if it is a case we can handle.
37 static bool CheckAsmLValue(const Expr *E, Sema &S) {
38  // Type dependent expressions will be checked during instantiation.
39  if (E->isTypeDependent())
40  return false;
41 
42  if (E->isLValue())
43  return false; // Cool, this is an lvalue.
44 
45  // Okay, this is not an lvalue, but perhaps it is the result of a cast that we
46  // are supposed to allow.
47  const Expr *E2 = E->IgnoreParenNoopCasts(S.Context);
48  if (E != E2 && E2->isLValue()) {
49  if (!S.getLangOpts().HeinousExtensions)
50  S.Diag(E2->getBeginLoc(), diag::err_invalid_asm_cast_lvalue)
51  << E->getSourceRange();
52  else
53  S.Diag(E2->getBeginLoc(), diag::warn_invalid_asm_cast_lvalue)
54  << E->getSourceRange();
55  // Accept, even if we emitted an error diagnostic.
56  return false;
57  }
58 
59  // None of the above, just randomly invalid non-lvalue.
60  return true;
61 }
62 
63 /// isOperandMentioned - Return true if the specified operand # is mentioned
64 /// anywhere in the decomposed asm string.
65 static bool
66 isOperandMentioned(unsigned OpNo,
68  for (unsigned p = 0, e = AsmStrPieces.size(); p != e; ++p) {
69  const GCCAsmStmt::AsmStringPiece &Piece = AsmStrPieces[p];
70  if (!Piece.isOperand())
71  continue;
72 
73  // If this is a reference to the input and if the input was the smaller
74  // one, then we have to reject this asm.
75  if (Piece.getOperandNo() == OpNo)
76  return true;
77  }
78  return false;
79 }
80 
81 static bool CheckNakedParmReference(Expr *E, Sema &S) {
82  FunctionDecl *Func = dyn_cast<FunctionDecl>(S.CurContext);
83  if (!Func)
84  return false;
85  if (!Func->hasAttr<NakedAttr>())
86  return false;
87 
88  SmallVector<Expr*, 4> WorkList;
89  WorkList.push_back(E);
90  while (WorkList.size()) {
91  Expr *E = WorkList.pop_back_val();
92  if (isa<CXXThisExpr>(E)) {
93  S.Diag(E->getBeginLoc(), diag::err_asm_naked_this_ref);
94  S.Diag(Func->getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
95  return true;
96  }
97  if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
98  if (isa<ParmVarDecl>(DRE->getDecl())) {
99  S.Diag(DRE->getBeginLoc(), diag::err_asm_naked_parm_ref);
100  S.Diag(Func->getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
101  return true;
102  }
103  }
104  for (Stmt *Child : E->children()) {
105  if (Expr *E = dyn_cast_or_null<Expr>(Child))
106  WorkList.push_back(E);
107  }
108  }
109  return false;
110 }
111 
112 /// Returns true if given expression is not compatible with inline
113 /// assembly's memory constraint; false otherwise.
116  bool is_input_expr) {
117  enum {
118  ExprBitfield = 0,
119  ExprVectorElt,
120  ExprGlobalRegVar,
121  ExprSafeType
122  } EType = ExprSafeType;
123 
124  // Bitfields, vector elements and global register variables are not
125  // compatible.
126  if (E->refersToBitField())
127  EType = ExprBitfield;
128  else if (E->refersToVectorElement())
129  EType = ExprVectorElt;
130  else if (E->refersToGlobalRegisterVar())
131  EType = ExprGlobalRegVar;
132 
133  if (EType != ExprSafeType) {
134  S.Diag(E->getBeginLoc(), diag::err_asm_non_addr_value_in_memory_constraint)
135  << EType << is_input_expr << Info.getConstraintStr()
136  << E->getSourceRange();
137  return true;
138  }
139 
140  return false;
141 }
142 
143 // Extracting the register name from the Expression value,
144 // if there is no register name to extract, returns ""
145 static StringRef extractRegisterName(const Expr *Expression,
146  const TargetInfo &Target) {
147  Expression = Expression->IgnoreImpCasts();
148  if (const DeclRefExpr *AsmDeclRef = dyn_cast<DeclRefExpr>(Expression)) {
149  // Handle cases where the expression is a variable
150  const VarDecl *Variable = dyn_cast<VarDecl>(AsmDeclRef->getDecl());
151  if (Variable && Variable->getStorageClass() == SC_Register) {
152  if (AsmLabelAttr *Attr = Variable->getAttr<AsmLabelAttr>())
153  if (Target.isValidGCCRegisterName(Attr->getLabel()))
154  return Target.getNormalizedGCCRegisterName(Attr->getLabel(), true);
155  }
156  }
157  return "";
158 }
159 
160 // Checks if there is a conflict between the input and output lists with the
161 // clobbers list. If there's a conflict, returns the location of the
162 // conflicted clobber, else returns nullptr
163 static SourceLocation
165  StringLiteral **Clobbers, int NumClobbers,
166  const TargetInfo &Target, ASTContext &Cont) {
167  llvm::StringSet<> InOutVars;
168  // Collect all the input and output registers from the extended asm
169  // statement in order to check for conflicts with the clobber list
170  for (unsigned int i = 0; i < Exprs.size(); ++i) {
171  StringRef Constraint = Constraints[i]->getString();
172  StringRef InOutReg = Target.getConstraintRegister(
173  Constraint, extractRegisterName(Exprs[i], Target));
174  if (InOutReg != "")
175  InOutVars.insert(InOutReg);
176  }
177  // Check for each item in the clobber list if it conflicts with the input
178  // or output
179  for (int i = 0; i < NumClobbers; ++i) {
180  StringRef Clobber = Clobbers[i]->getString();
181  // We only check registers, therefore we don't check cc and memory
182  // clobbers
183  if (Clobber == "cc" || Clobber == "memory")
184  continue;
185  Clobber = Target.getNormalizedGCCRegisterName(Clobber, true);
186  // Go over the output's registers we collected
187  if (InOutVars.count(Clobber))
188  return Clobbers[i]->getBeginLoc();
189  }
190  return SourceLocation();
191 }
192 
194  bool IsVolatile, unsigned NumOutputs,
195  unsigned NumInputs, IdentifierInfo **Names,
196  MultiExprArg constraints, MultiExprArg Exprs,
197  Expr *asmString, MultiExprArg clobbers,
198  SourceLocation RParenLoc) {
199  unsigned NumClobbers = clobbers.size();
200  StringLiteral **Constraints =
201  reinterpret_cast<StringLiteral**>(constraints.data());
202  StringLiteral *AsmString = cast<StringLiteral>(asmString);
203  StringLiteral **Clobbers = reinterpret_cast<StringLiteral**>(clobbers.data());
204 
205  SmallVector<TargetInfo::ConstraintInfo, 4> OutputConstraintInfos;
206 
207  // The parser verifies that there is a string literal here.
208  assert(AsmString->isAscii());
209 
210  // If we're compiling CUDA file and function attributes indicate that it's not
211  // for this compilation side, skip all the checks.
212  if (!DeclAttrsMatchCUDAMode(getLangOpts(), getCurFunctionDecl())) {
213  GCCAsmStmt *NS = new (Context) GCCAsmStmt(
214  Context, AsmLoc, IsSimple, IsVolatile, NumOutputs, NumInputs, Names,
215  Constraints, Exprs.data(), AsmString, NumClobbers, Clobbers, RParenLoc);
216  return NS;
217  }
218 
219  for (unsigned i = 0; i != NumOutputs; i++) {
220  StringLiteral *Literal = Constraints[i];
221  assert(Literal->isAscii());
222 
223  StringRef OutputName;
224  if (Names[i])
225  OutputName = Names[i]->getName();
226 
227  TargetInfo::ConstraintInfo Info(Literal->getString(), OutputName);
228  if (!Context.getTargetInfo().validateOutputConstraint(Info))
229  return StmtError(
230  Diag(Literal->getBeginLoc(), diag::err_asm_invalid_output_constraint)
231  << Info.getConstraintStr());
232 
233  ExprResult ER = CheckPlaceholderExpr(Exprs[i]);
234  if (ER.isInvalid())
235  return StmtError();
236  Exprs[i] = ER.get();
237 
238  // Check that the output exprs are valid lvalues.
239  Expr *OutputExpr = Exprs[i];
240 
241  // Referring to parameters is not allowed in naked functions.
242  if (CheckNakedParmReference(OutputExpr, *this))
243  return StmtError();
244 
245  // Check that the output expression is compatible with memory constraint.
246  if (Info.allowsMemory() &&
247  checkExprMemoryConstraintCompat(*this, OutputExpr, Info, false))
248  return StmtError();
249 
250  OutputConstraintInfos.push_back(Info);
251 
252  // If this is dependent, just continue.
253  if (OutputExpr->isTypeDependent())
254  continue;
255 
257  OutputExpr->isModifiableLvalue(Context, /*Loc=*/nullptr);
258  switch (IsLV) {
259  case Expr::MLV_Valid:
260  // Cool, this is an lvalue.
261  break;
262  case Expr::MLV_ArrayType:
263  // This is OK too.
264  break;
265  case Expr::MLV_LValueCast: {
266  const Expr *LVal = OutputExpr->IgnoreParenNoopCasts(Context);
267  if (!getLangOpts().HeinousExtensions) {
268  Diag(LVal->getBeginLoc(), diag::err_invalid_asm_cast_lvalue)
269  << OutputExpr->getSourceRange();
270  } else {
271  Diag(LVal->getBeginLoc(), diag::warn_invalid_asm_cast_lvalue)
272  << OutputExpr->getSourceRange();
273  }
274  // Accept, even if we emitted an error diagnostic.
275  break;
276  }
279  if (RequireCompleteType(OutputExpr->getBeginLoc(), Exprs[i]->getType(),
280  diag::err_dereference_incomplete_type))
281  return StmtError();
282  LLVM_FALLTHROUGH;
283  default:
284  return StmtError(Diag(OutputExpr->getBeginLoc(),
285  diag::err_asm_invalid_lvalue_in_output)
286  << OutputExpr->getSourceRange());
287  }
288 
289  unsigned Size = Context.getTypeSize(OutputExpr->getType());
290  if (!Context.getTargetInfo().validateOutputSize(Literal->getString(),
291  Size))
292  return StmtError(
293  Diag(OutputExpr->getBeginLoc(), diag::err_asm_invalid_output_size)
294  << Info.getConstraintStr());
295  }
296 
297  SmallVector<TargetInfo::ConstraintInfo, 4> InputConstraintInfos;
298 
299  for (unsigned i = NumOutputs, e = NumOutputs + NumInputs; i != e; i++) {
300  StringLiteral *Literal = Constraints[i];
301  assert(Literal->isAscii());
302 
303  StringRef InputName;
304  if (Names[i])
305  InputName = Names[i]->getName();
306 
307  TargetInfo::ConstraintInfo Info(Literal->getString(), InputName);
308  if (!Context.getTargetInfo().validateInputConstraint(OutputConstraintInfos,
309  Info)) {
310  return StmtError(
311  Diag(Literal->getBeginLoc(), diag::err_asm_invalid_input_constraint)
312  << Info.getConstraintStr());
313  }
314 
315  ExprResult ER = CheckPlaceholderExpr(Exprs[i]);
316  if (ER.isInvalid())
317  return StmtError();
318  Exprs[i] = ER.get();
319 
320  Expr *InputExpr = Exprs[i];
321 
322  // Referring to parameters is not allowed in naked functions.
323  if (CheckNakedParmReference(InputExpr, *this))
324  return StmtError();
325 
326  // Check that the input expression is compatible with memory constraint.
327  if (Info.allowsMemory() &&
328  checkExprMemoryConstraintCompat(*this, InputExpr, Info, true))
329  return StmtError();
330 
331  // Only allow void types for memory constraints.
332  if (Info.allowsMemory() && !Info.allowsRegister()) {
333  if (CheckAsmLValue(InputExpr, *this))
334  return StmtError(Diag(InputExpr->getBeginLoc(),
335  diag::err_asm_invalid_lvalue_in_input)
336  << Info.getConstraintStr()
337  << InputExpr->getSourceRange());
338  } else if (Info.requiresImmediateConstant() && !Info.allowsRegister()) {
339  if (!InputExpr->isValueDependent()) {
340  llvm::APSInt Result;
341  if (!InputExpr->EvaluateAsInt(Result, Context))
342  return StmtError(
343  Diag(InputExpr->getBeginLoc(), diag::err_asm_immediate_expected)
344  << Info.getConstraintStr() << InputExpr->getSourceRange());
345  if (!Info.isValidAsmImmediate(Result))
346  return StmtError(Diag(InputExpr->getBeginLoc(),
347  diag::err_invalid_asm_value_for_constraint)
348  << Result.toString(10) << Info.getConstraintStr()
349  << InputExpr->getSourceRange());
350  }
351 
352  } else {
353  ExprResult Result = DefaultFunctionArrayLvalueConversion(Exprs[i]);
354  if (Result.isInvalid())
355  return StmtError();
356 
357  Exprs[i] = Result.get();
358  }
359 
360  if (Info.allowsRegister()) {
361  if (InputExpr->getType()->isVoidType()) {
362  return StmtError(
363  Diag(InputExpr->getBeginLoc(), diag::err_asm_invalid_type_in_input)
364  << InputExpr->getType() << Info.getConstraintStr()
365  << InputExpr->getSourceRange());
366  }
367  }
368 
369  InputConstraintInfos.push_back(Info);
370 
371  const Type *Ty = Exprs[i]->getType().getTypePtr();
372  if (Ty->isDependentType())
373  continue;
374 
375  if (!Ty->isVoidType() || !Info.allowsMemory())
376  if (RequireCompleteType(InputExpr->getBeginLoc(), Exprs[i]->getType(),
377  diag::err_dereference_incomplete_type))
378  return StmtError();
379 
380  unsigned Size = Context.getTypeSize(Ty);
381  if (!Context.getTargetInfo().validateInputSize(Literal->getString(),
382  Size))
383  return StmtError(
384  Diag(InputExpr->getBeginLoc(), diag::err_asm_invalid_input_size)
385  << Info.getConstraintStr());
386  }
387 
388  // Check that the clobbers are valid.
389  for (unsigned i = 0; i != NumClobbers; i++) {
390  StringLiteral *Literal = Clobbers[i];
391  assert(Literal->isAscii());
392 
393  StringRef Clobber = Literal->getString();
394 
395  if (!Context.getTargetInfo().isValidClobber(Clobber))
396  return StmtError(
397  Diag(Literal->getBeginLoc(), diag::err_asm_unknown_register_name)
398  << Clobber);
399  }
400 
401  GCCAsmStmt *NS =
402  new (Context) GCCAsmStmt(Context, AsmLoc, IsSimple, IsVolatile, NumOutputs,
403  NumInputs, Names, Constraints, Exprs.data(),
404  AsmString, NumClobbers, Clobbers, RParenLoc);
405  // Validate the asm string, ensuring it makes sense given the operands we
406  // have.
408  unsigned DiagOffs;
409  if (unsigned DiagID = NS->AnalyzeAsmString(Pieces, Context, DiagOffs)) {
410  Diag(getLocationOfStringLiteralByte(AsmString, DiagOffs), DiagID)
411  << AsmString->getSourceRange();
412  return StmtError();
413  }
414 
415  // Validate constraints and modifiers.
416  for (unsigned i = 0, e = Pieces.size(); i != e; ++i) {
417  GCCAsmStmt::AsmStringPiece &Piece = Pieces[i];
418  if (!Piece.isOperand()) continue;
419 
420  // Look for the correct constraint index.
421  unsigned ConstraintIdx = Piece.getOperandNo();
422  unsigned NumOperands = NS->getNumOutputs() + NS->getNumInputs();
423 
424  // Look for the (ConstraintIdx - NumOperands + 1)th constraint with
425  // modifier '+'.
426  if (ConstraintIdx >= NumOperands) {
427  unsigned I = 0, E = NS->getNumOutputs();
428 
429  for (unsigned Cnt = ConstraintIdx - NumOperands; I != E; ++I)
430  if (OutputConstraintInfos[I].isReadWrite() && Cnt-- == 0) {
431  ConstraintIdx = I;
432  break;
433  }
434 
435  assert(I != E && "Invalid operand number should have been caught in "
436  " AnalyzeAsmString");
437  }
438 
439  // Now that we have the right indexes go ahead and check.
440  StringLiteral *Literal = Constraints[ConstraintIdx];
441  const Type *Ty = Exprs[ConstraintIdx]->getType().getTypePtr();
442  if (Ty->isDependentType() || Ty->isIncompleteType())
443  continue;
444 
445  unsigned Size = Context.getTypeSize(Ty);
446  std::string SuggestedModifier;
448  Literal->getString(), Piece.getModifier(), Size,
449  SuggestedModifier)) {
450  Diag(Exprs[ConstraintIdx]->getBeginLoc(),
451  diag::warn_asm_mismatched_size_modifier);
452 
453  if (!SuggestedModifier.empty()) {
454  auto B = Diag(Piece.getRange().getBegin(),
455  diag::note_asm_missing_constraint_modifier)
456  << SuggestedModifier;
457  SuggestedModifier = "%" + SuggestedModifier + Piece.getString();
458  B.AddFixItHint(FixItHint::CreateReplacement(Piece.getRange(),
459  SuggestedModifier));
460  }
461  }
462  }
463 
464  // Validate tied input operands for type mismatches.
465  unsigned NumAlternatives = ~0U;
466  for (unsigned i = 0, e = OutputConstraintInfos.size(); i != e; ++i) {
467  TargetInfo::ConstraintInfo &Info = OutputConstraintInfos[i];
468  StringRef ConstraintStr = Info.getConstraintStr();
469  unsigned AltCount = ConstraintStr.count(',') + 1;
470  if (NumAlternatives == ~0U)
471  NumAlternatives = AltCount;
472  else if (NumAlternatives != AltCount)
473  return StmtError(Diag(NS->getOutputExpr(i)->getBeginLoc(),
474  diag::err_asm_unexpected_constraint_alternatives)
475  << NumAlternatives << AltCount);
476  }
477  SmallVector<size_t, 4> InputMatchedToOutput(OutputConstraintInfos.size(),
478  ~0U);
479  for (unsigned i = 0, e = InputConstraintInfos.size(); i != e; ++i) {
480  TargetInfo::ConstraintInfo &Info = InputConstraintInfos[i];
481  StringRef ConstraintStr = Info.getConstraintStr();
482  unsigned AltCount = ConstraintStr.count(',') + 1;
483  if (NumAlternatives == ~0U)
484  NumAlternatives = AltCount;
485  else if (NumAlternatives != AltCount)
486  return StmtError(Diag(NS->getInputExpr(i)->getBeginLoc(),
487  diag::err_asm_unexpected_constraint_alternatives)
488  << NumAlternatives << AltCount);
489 
490  // If this is a tied constraint, verify that the output and input have
491  // either exactly the same type, or that they are int/ptr operands with the
492  // same size (int/long, int*/long, are ok etc).
493  if (!Info.hasTiedOperand()) continue;
494 
495  unsigned TiedTo = Info.getTiedOperand();
496  unsigned InputOpNo = i+NumOutputs;
497  Expr *OutputExpr = Exprs[TiedTo];
498  Expr *InputExpr = Exprs[InputOpNo];
499 
500  // Make sure no more than one input constraint matches each output.
501  assert(TiedTo < InputMatchedToOutput.size() && "TiedTo value out of range");
502  if (InputMatchedToOutput[TiedTo] != ~0U) {
503  Diag(NS->getInputExpr(i)->getBeginLoc(),
504  diag::err_asm_input_duplicate_match)
505  << TiedTo;
506  Diag(NS->getInputExpr(InputMatchedToOutput[TiedTo])->getBeginLoc(),
507  diag::note_asm_input_duplicate_first)
508  << TiedTo;
509  return StmtError();
510  }
511  InputMatchedToOutput[TiedTo] = i;
512 
513  if (OutputExpr->isTypeDependent() || InputExpr->isTypeDependent())
514  continue;
515 
516  QualType InTy = InputExpr->getType();
517  QualType OutTy = OutputExpr->getType();
518  if (Context.hasSameType(InTy, OutTy))
519  continue; // All types can be tied to themselves.
520 
521  // Decide if the input and output are in the same domain (integer/ptr or
522  // floating point.
523  enum AsmDomain {
524  AD_Int, AD_FP, AD_Other
525  } InputDomain, OutputDomain;
526 
527  if (InTy->isIntegerType() || InTy->isPointerType())
528  InputDomain = AD_Int;
529  else if (InTy->isRealFloatingType())
530  InputDomain = AD_FP;
531  else
532  InputDomain = AD_Other;
533 
534  if (OutTy->isIntegerType() || OutTy->isPointerType())
535  OutputDomain = AD_Int;
536  else if (OutTy->isRealFloatingType())
537  OutputDomain = AD_FP;
538  else
539  OutputDomain = AD_Other;
540 
541  // They are ok if they are the same size and in the same domain. This
542  // allows tying things like:
543  // void* to int*
544  // void* to int if they are the same size.
545  // double to long double if they are the same size.
546  //
547  uint64_t OutSize = Context.getTypeSize(OutTy);
548  uint64_t InSize = Context.getTypeSize(InTy);
549  if (OutSize == InSize && InputDomain == OutputDomain &&
550  InputDomain != AD_Other)
551  continue;
552 
553  // If the smaller input/output operand is not mentioned in the asm string,
554  // then we can promote the smaller one to a larger input and the asm string
555  // won't notice.
556  bool SmallerValueMentioned = false;
557 
558  // If this is a reference to the input and if the input was the smaller
559  // one, then we have to reject this asm.
560  if (isOperandMentioned(InputOpNo, Pieces)) {
561  // This is a use in the asm string of the smaller operand. Since we
562  // codegen this by promoting to a wider value, the asm will get printed
563  // "wrong".
564  SmallerValueMentioned |= InSize < OutSize;
565  }
566  if (isOperandMentioned(TiedTo, Pieces)) {
567  // If this is a reference to the output, and if the output is the larger
568  // value, then it's ok because we'll promote the input to the larger type.
569  SmallerValueMentioned |= OutSize < InSize;
570  }
571 
572  // If the smaller value wasn't mentioned in the asm string, and if the
573  // output was a register, just extend the shorter one to the size of the
574  // larger one.
575  if (!SmallerValueMentioned && InputDomain != AD_Other &&
576  OutputConstraintInfos[TiedTo].allowsRegister())
577  continue;
578 
579  // Either both of the operands were mentioned or the smaller one was
580  // mentioned. One more special case that we'll allow: if the tied input is
581  // integer, unmentioned, and is a constant, then we'll allow truncating it
582  // down to the size of the destination.
583  if (InputDomain == AD_Int && OutputDomain == AD_Int &&
584  !isOperandMentioned(InputOpNo, Pieces) &&
585  InputExpr->isEvaluatable(Context)) {
586  CastKind castKind =
587  (OutTy->isBooleanType() ? CK_IntegralToBoolean : CK_IntegralCast);
588  InputExpr = ImpCastExprToType(InputExpr, OutTy, castKind).get();
589  Exprs[InputOpNo] = InputExpr;
590  NS->setInputExpr(i, InputExpr);
591  continue;
592  }
593 
594  Diag(InputExpr->getBeginLoc(), diag::err_asm_tying_incompatible_types)
595  << InTy << OutTy << OutputExpr->getSourceRange()
596  << InputExpr->getSourceRange();
597  return StmtError();
598  }
599 
600  // Check for conflicts between clobber list and input or output lists
601  SourceLocation ConstraintLoc =
602  getClobberConflictLocation(Exprs, Constraints, Clobbers, NumClobbers,
603  Context.getTargetInfo(), Context);
604  if (ConstraintLoc.isValid())
605  return Diag(ConstraintLoc, diag::error_inoutput_conflict_with_clobber);
606 
607  return NS;
608 }
609 
611  llvm::InlineAsmIdentifierInfo &Info) {
612  QualType T = Res->getType();
613  Expr::EvalResult Eval;
614  if (T->isFunctionType() || T->isDependentType())
615  return Info.setLabel(Res);
616  if (Res->isRValue()) {
617  if (isa<clang::EnumType>(T) && Res->EvaluateAsRValue(Eval, Context))
618  return Info.setEnum(Eval.Val.getInt().getSExtValue());
619  return Info.setLabel(Res);
620  }
621  unsigned Size = Context.getTypeSizeInChars(T).getQuantity();
622  unsigned Type = Size;
623  if (const auto *ATy = Context.getAsArrayType(T))
624  Type = Context.getTypeSizeInChars(ATy->getElementType()).getQuantity();
625  bool IsGlobalLV = false;
626  if (Res->EvaluateAsLValue(Eval, Context))
627  IsGlobalLV = Eval.isGlobalLValue();
628  Info.setVar(Res, IsGlobalLV, Size, Type);
629 }
630 
632  SourceLocation TemplateKWLoc,
633  UnqualifiedId &Id,
634  bool IsUnevaluatedContext) {
635 
636  if (IsUnevaluatedContext)
637  PushExpressionEvaluationContext(
638  ExpressionEvaluationContext::UnevaluatedAbstract,
639  ReuseLambdaContextDecl);
640 
641  ExprResult Result = ActOnIdExpression(getCurScope(), SS, TemplateKWLoc, Id,
642  /*trailing lparen*/ false,
643  /*is & operand*/ false,
644  /*CorrectionCandidateCallback=*/nullptr,
645  /*IsInlineAsmIdentifier=*/ true);
646 
647  if (IsUnevaluatedContext)
648  PopExpressionEvaluationContext();
649 
650  if (!Result.isUsable()) return Result;
651 
652  Result = CheckPlaceholderExpr(Result.get());
653  if (!Result.isUsable()) return Result;
654 
655  // Referring to parameters is not allowed in naked functions.
656  if (CheckNakedParmReference(Result.get(), *this))
657  return ExprError();
658 
659  QualType T = Result.get()->getType();
660 
661  if (T->isDependentType()) {
662  return Result;
663  }
664 
665  // Any sort of function type is fine.
666  if (T->isFunctionType()) {
667  return Result;
668  }
669 
670  // Otherwise, it needs to be a complete type.
671  if (RequireCompleteExprType(Result.get(), diag::err_asm_incomplete_type)) {
672  return ExprError();
673  }
674 
675  return Result;
676 }
677 
678 bool Sema::LookupInlineAsmField(StringRef Base, StringRef Member,
679  unsigned &Offset, SourceLocation AsmLoc) {
680  Offset = 0;
682  Member.split(Members, ".");
683 
684  NamedDecl *FoundDecl = nullptr;
685 
686  // MS InlineAsm uses 'this' as a base
687  if (getLangOpts().CPlusPlus && Base.equals("this")) {
688  if (const Type *PT = getCurrentThisType().getTypePtrOrNull())
689  FoundDecl = PT->getPointeeType()->getAsTagDecl();
690  } else {
691  LookupResult BaseResult(*this, &Context.Idents.get(Base), SourceLocation(),
692  LookupOrdinaryName);
693  if (LookupName(BaseResult, getCurScope()) && BaseResult.isSingleResult())
694  FoundDecl = BaseResult.getFoundDecl();
695  }
696 
697  if (!FoundDecl)
698  return true;
699 
700  for (StringRef NextMember : Members) {
701  const RecordType *RT = nullptr;
702  if (VarDecl *VD = dyn_cast<VarDecl>(FoundDecl))
703  RT = VD->getType()->getAs<RecordType>();
704  else if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(FoundDecl)) {
705  MarkAnyDeclReferenced(TD->getLocation(), TD, /*OdrUse=*/false);
706  // MS InlineAsm often uses struct pointer aliases as a base
707  QualType QT = TD->getUnderlyingType();
708  if (const auto *PT = QT->getAs<PointerType>())
709  QT = PT->getPointeeType();
710  RT = QT->getAs<RecordType>();
711  } else if (TypeDecl *TD = dyn_cast<TypeDecl>(FoundDecl))
712  RT = TD->getTypeForDecl()->getAs<RecordType>();
713  else if (FieldDecl *TD = dyn_cast<FieldDecl>(FoundDecl))
714  RT = TD->getType()->getAs<RecordType>();
715  if (!RT)
716  return true;
717 
718  if (RequireCompleteType(AsmLoc, QualType(RT, 0),
719  diag::err_asm_incomplete_type))
720  return true;
721 
722  LookupResult FieldResult(*this, &Context.Idents.get(NextMember),
723  SourceLocation(), LookupMemberName);
724 
725  if (!LookupQualifiedName(FieldResult, RT->getDecl()))
726  return true;
727 
728  if (!FieldResult.isSingleResult())
729  return true;
730  FoundDecl = FieldResult.getFoundDecl();
731 
732  // FIXME: Handle IndirectFieldDecl?
733  FieldDecl *FD = dyn_cast<FieldDecl>(FoundDecl);
734  if (!FD)
735  return true;
736 
737  const ASTRecordLayout &RL = Context.getASTRecordLayout(RT->getDecl());
738  unsigned i = FD->getFieldIndex();
739  CharUnits Result = Context.toCharUnitsFromBits(RL.getFieldOffset(i));
740  Offset += (unsigned)Result.getQuantity();
741  }
742 
743  return false;
744 }
745 
748  SourceLocation AsmLoc) {
749 
750  QualType T = E->getType();
751  if (T->isDependentType()) {
752  DeclarationNameInfo NameInfo;
753  NameInfo.setLoc(AsmLoc);
754  NameInfo.setName(&Context.Idents.get(Member));
756  Context, E, T, /*IsArrow=*/false, AsmLoc, NestedNameSpecifierLoc(),
757  SourceLocation(),
758  /*FirstQualifierInScope=*/nullptr, NameInfo, /*TemplateArgs=*/nullptr);
759  }
760 
761  const RecordType *RT = T->getAs<RecordType>();
762  // FIXME: Diagnose this as field access into a scalar type.
763  if (!RT)
764  return ExprResult();
765 
766  LookupResult FieldResult(*this, &Context.Idents.get(Member), AsmLoc,
767  LookupMemberName);
768 
769  if (!LookupQualifiedName(FieldResult, RT->getDecl()))
770  return ExprResult();
771 
772  // Only normal and indirect field results will work.
773  ValueDecl *FD = dyn_cast<FieldDecl>(FieldResult.getFoundDecl());
774  if (!FD)
775  FD = dyn_cast<IndirectFieldDecl>(FieldResult.getFoundDecl());
776  if (!FD)
777  return ExprResult();
778 
779  // Make an Expr to thread through OpDecl.
780  ExprResult Result = BuildMemberReferenceExpr(
781  E, E->getType(), AsmLoc, /*IsArrow=*/false, CXXScopeSpec(),
782  SourceLocation(), nullptr, FieldResult, nullptr, nullptr);
783 
784  return Result;
785 }
786 
788  ArrayRef<Token> AsmToks,
789  StringRef AsmString,
790  unsigned NumOutputs, unsigned NumInputs,
791  ArrayRef<StringRef> Constraints,
792  ArrayRef<StringRef> Clobbers,
793  ArrayRef<Expr*> Exprs,
794  SourceLocation EndLoc) {
795  bool IsSimple = (NumOutputs != 0 || NumInputs != 0);
796  setFunctionHasBranchProtectedScope();
797  MSAsmStmt *NS =
798  new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, IsSimple,
799  /*IsVolatile*/ true, AsmToks, NumOutputs, NumInputs,
800  Constraints, Exprs, AsmString,
801  Clobbers, EndLoc);
802  return NS;
803 }
804 
805 LabelDecl *Sema::GetOrCreateMSAsmLabel(StringRef ExternalLabelName,
806  SourceLocation Location,
807  bool AlwaysCreate) {
808  LabelDecl* Label = LookupOrCreateLabel(PP.getIdentifierInfo(ExternalLabelName),
809  Location);
810 
811  if (Label->isMSAsmLabel()) {
812  // If we have previously created this label implicitly, mark it as used.
813  Label->markUsed(Context);
814  } else {
815  // Otherwise, insert it, but only resolve it if we have seen the label itself.
816  std::string InternalName;
817  llvm::raw_string_ostream OS(InternalName);
818  // Create an internal name for the label. The name should not be a valid
819  // mangled name, and should be unique. We use a dot to make the name an
820  // invalid mangled name. We use LLVM's inline asm ${:uid} escape so that a
821  // unique label is generated each time this blob is emitted, even after
822  // inlining or LTO.
823  OS << "__MSASMLABEL_.${:uid}__";
824  for (char C : ExternalLabelName) {
825  OS << C;
826  // We escape '$' in asm strings by replacing it with "$$"
827  if (C == '$')
828  OS << '$';
829  }
830  Label->setMSAsmLabel(OS.str());
831  }
832  if (AlwaysCreate) {
833  // The label might have been created implicitly from a previously encountered
834  // goto statement. So, for both newly created and looked up labels, we mark
835  // them as resolved.
836  Label->setMSAsmLabelResolved();
837  }
838  // Adjust their location for being able to generate accurate diagnostics.
839  Label->setLocation(Location);
840 
841  return Label;
842 }
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:1647
Represents a function declaration or definition.
Definition: Decl.h:1717
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
unsigned getNumInputs() const
Definition: Stmt.h:1563
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2511
A (possibly-)qualified type.
Definition: Type.h:642
static CXXDependentScopeMemberExpr * Create(const ASTContext &C, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Definition: ExprCXX.cpp:1162
void FillInlineAsmIdentifierInfo(Expr *Res, llvm::InlineAsmIdentifierInfo &Info)
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D...
Stmt - This represents one statement.
Definition: Stmt.h:66
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Definition: Type.cpp:497
StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, bool IsVolatile, unsigned NumOutputs, unsigned NumInputs, IdentifierInfo **Names, MultiExprArg Constraints, MultiExprArg Exprs, Expr *AsmString, MultiExprArg Clobbers, SourceLocation RParenLoc)
bool isRealFloatingType() const
Floating point categories.
Definition: Type.cpp:1929
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1017
unsigned getNumOutputs() const
Definition: Stmt.h:1541
bool isAscii() const
Definition: Expr.h:1659
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition: Sema.h:1289
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
Definition: Decl.cpp:3775
The base class of the type hierarchy.
Definition: Type.h:1415
bool validateInputConstraint(MutableArrayRef< ConstraintInfo > OutputConstraints, ConstraintInfo &info) const
Definition: TargetInfo.cpp:623
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:699
isModifiableLvalueResult
Definition: Expr.h:268
void setInputExpr(unsigned i, Expr *E)
Definition: Stmt.cpp:445
bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
Represents a variable declaration or definition.
Definition: Decl.h:812
const T * getAs() const
Member-template getAs<specific type>&#39;.
Definition: Type.h:6590
unsigned AnalyzeAsmString(SmallVectorImpl< AsmStringPiece > &Pieces, const ASTContext &C, unsigned &DiagOffs) const
AnalyzeAsmString - Analyze the asm string of the current asm, decomposing it into pieces...
Definition: Stmt.cpp:509
Defines the clang::Expr interface and subclasses for C++ expressions.
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&#39;s memory constraint; false ot...
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
Definition: Expr.h:2977
One of these records is kept for each identifier that is lexed.
SourceLocation getBegin() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:154
A C++ nested-name-specifier augmented with source location information.
StringRef getNormalizedGCCRegisterName(StringRef Name, bool ReturnCanonical=false) const
Returns the "normalized" GCC register name.
Definition: TargetInfo.cpp:485
virtual bool validateConstraintModifier(StringRef, char, unsigned, std::string &) const
Definition: TargetInfo.h:915
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.cpp:280
Represents a member of a struct/union/class.
Definition: Decl.h:2556
CharSourceRange getRange() const
Definition: Stmt.h:1712
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
static bool isOperandMentioned(unsigned OpNo, ArrayRef< GCCAsmStmt::AsmStringPiece > AsmStrPieces)
isOperandMentioned - Return true if the specified operand # is mentioned anywhere in the decomposed a...
Definition: SemaStmtAsm.cpp:66
IdentifierTable & Idents
Definition: ASTContext.h:565
LabelDecl * GetOrCreateMSAsmLabel(StringRef ExternalLabelName, SourceLocation Location, bool AlwaysCreate)
Represents a C++ unqualified-id that has been parsed.
Definition: DeclSpec.h:920
Represents the results of name lookup.
Definition: Lookup.h:47
PtrTy get() const
Definition: Ownership.h:174
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
Definition: Expr.h:436
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
APValue Val
Val - This is the value the expression can be folded to.
Definition: Expr.h:572
uint32_t Offset
Definition: CacheTokens.cpp:43
static bool CheckAsmLValue(const Expr *E, Sema &S)
CheckAsmLValue - GNU C has an extremely ugly extension whereby they silently ignore "noop" casts in p...
Definition: SemaStmtAsm.cpp:37
child_range children()
Definition: Stmt.cpp:229
StmtResult StmtError()
Definition: Ownership.h:284
Represents a declaration of a type.
Definition: Decl.h:2851
virtual StringRef getConstraintRegister(StringRef Constraint, StringRef Expression) const
Extracts a register from the passed constraint (if it is a single-register constraint) and the asm la...
Definition: TargetInfo.h:786
Expr * getOutputExpr(unsigned i)
Definition: Stmt.cpp:430
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:63
const LangOptions & getLangOpts() const
Definition: Sema.h:1212
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
Definition: Expr.h:166
virtual bool isValidGCCRegisterName(StringRef Name) const
Returns whether the passed in string is a valid register name according to GCC.
Definition: TargetInfo.cpp:440
ExprResult LookupInlineAsmIdentifier(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool IsUnevaluatedContext)
bool hasAttr() const
Definition: DeclBase.h:531
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:277
StringRef getString() const
Definition: Expr.h:1616
bool EvaluateAsLValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsLValue - Evaluate an expression to see if we can fold it to an lvalue with link time known ...
bool isValidClobber(StringRef Name) const
Returns whether the passed in string is a valid clobber in an inline asm statement.
Definition: TargetInfo.cpp:432
Expr * IgnoreParenNoopCasts(ASTContext &Ctx) LLVM_READONLY
IgnoreParenNoopCasts - Ignore parentheses and casts that do not change the value (including ptr->int ...
Definition: Expr.cpp:2664
CastKind
CastKind - The kind of operation required for a conversion.
unsigned getOperandNo() const
Definition: Stmt.h:1707
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Definition: CharUnits.h:179
static bool CheckNakedParmReference(Expr *E, Sema &S)
Definition: SemaStmtAsm.cpp:81
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
Definition: RecordLayout.h:39
Exposes information about the current target.
Definition: TargetInfo.h:54
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:636
This represents one expression.
Definition: Expr.h:105
std::string Label
int Id
Definition: ASTDiff.cpp:191
static SourceLocation getClobberConflictLocation(MultiExprArg Exprs, StringLiteral **Constraints, StringLiteral **Clobbers, int NumClobbers, const TargetInfo &Target, ASTContext &Cont)
AsmStringPiece - this is part of a decomposed asm string specification (for use with the AnalyzeAsmSt...
Definition: Stmt.h:1680
Defines the clang::Preprocessor interface.
Defines the clang::TypeLoc interface and its subclasses.
QualType getType() const
Definition: Expr.h:127
ActionResult< CXXBaseSpecifier * > BaseResult
Definition: Ownership.h:270
This represents a Microsoft inline-assembly statement extension.
Definition: Stmt.h:1822
bool isInvalid() const
Definition: Ownership.h:170
void setLocation(SourceLocation L)
Definition: DeclBase.h:419
bool isUsable() const
Definition: Ownership.h:171
RecordDecl * getDecl() const
Definition: Type.h:4263
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
Definition: RecordLayout.h:191
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Definition: Ownership.h:157
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static StringRef extractRegisterName(const Expr *Expression, const TargetInfo &Target)
ExprResult LookupInlineAsmVarDeclField(Expr *RefExpr, StringRef Member, SourceLocation AsmLoc)
Represents the declaration of a label.
Definition: Decl.h:468
const std::string & getString() const
Definition: Stmt.h:1705
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
bool validateOutputConstraint(ConstraintInfo &Info) const
Definition: TargetInfo.cpp:526
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
Definition: Expr.h:148
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:1712
bool isMSAsmLabel() const
Definition: Decl.h:502
bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset, SourceLocation AsmLoc)
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
Definition: Expr.h:248
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 refersToVectorElement() const
Returns whether this expression refers to a vector element.
Definition: Expr.cpp:3572
Expr * getInputExpr(unsigned i)
Definition: Stmt.cpp:441
StringRef getName() const
Return the actual identifier string.
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2893
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
EvalResult is a struct with detailed info about an evaluated expression.
Definition: Expr.h:570
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)
Represents a field injected from an anonymous union/struct into the parent scope. ...
Definition: Decl.h:2802
bool isBooleanType() const
Definition: Type.h:6517
char getModifier() const
getModifier - Get the modifier for this operand, if present.
Definition: Stmt.cpp:421
bool hasTiedOperand() const
Return true if this input operand is a matching constraint that ties it to an output operand...
Definition: TargetInfo.h:834
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
const std::string & getConstraintStr() const
Definition: TargetInfo.h:818
bool DeclAttrsMatchCUDAMode(const LangOptions &LangOpts, Decl *D)
Definition: SemaInternal.h:54
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4253
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Definition: Type.h:6438
T * getAttr() const
Definition: DeclBase.h:527
bool isFunctionType() const
Definition: Type.h:6173
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Definition: ASTContext.h:2275
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
Definition: DeclBase.cpp:412
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Definition: ASTContext.h:2076
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
Definition: Type.cpp:2022
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
bool refersToGlobalRegisterVar() const
Returns whether this expression refers to a global register variable.
Definition: Expr.cpp:3598
ActionResult< Expr * > ExprResult
Definition: Ownership.h:267
virtual bool validateOutputSize(StringRef, unsigned) const
Definition: TargetInfo.h:905
bool isVoidType() const
Definition: Type.h:6404
void setMSAsmLabel(StringRef Name)
Definition: Decl.cpp:4363
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition: Sema.h:331
bool isRValue() const
Definition: Expr.h:249
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
Definition: Diagnostic.h:129
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:268
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1568
Defines the clang::TargetInfo interface.
ExprResult ExprError()
Definition: Ownership.h:283
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2056
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...
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:971
bool isPointerType() const
Definition: Type.h:6177
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
void setMSAsmLabelResolved()
Definition: Decl.h:506
virtual bool validateInputSize(StringRef, unsigned) const
Definition: TargetInfo.h:910
ASTContext & Context
Definition: Sema.h:319
This represents a decl that may have a name.
Definition: Decl.h:248
APSInt & getInt()
Definition: APValue.h:252
Attr - This represents one attribute.
Definition: Attr.h:43