@@ -262,10 +262,15 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
262
262
OutputName = Names[i]->getName ();
263
263
264
264
TargetInfo::ConstraintInfo Info (Literal->getString (), OutputName);
265
- if (!Context.getTargetInfo ().validateOutputConstraint (Info))
266
- return StmtResult (targetDiag (Literal->getBeginLoc (),
267
- diag::err_asm_invalid_output_constraint)
268
- << Info.getConstraintStr ());
265
+ if (!Context.getTargetInfo ().validateOutputConstraint (Info)) {
266
+ targetDiag (Literal->getBeginLoc (),
267
+ diag::err_asm_invalid_output_constraint)
268
+ << Info.getConstraintStr ();
269
+ return new (Context)
270
+ GCCAsmStmt (Context, AsmLoc, IsSimple, IsVolatile, NumOutputs,
271
+ NumInputs, Names, Constraints, Exprs.data (), AsmString,
272
+ NumClobbers, Clobbers, RParenLoc);
273
+ }
269
274
270
275
ExprResult ER = CheckPlaceholderExpr (Exprs[i]);
271
276
if (ER.isInvalid ())
@@ -318,10 +323,15 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
318
323
}
319
324
320
325
unsigned Size = Context.getTypeSize (OutputExpr->getType ());
321
- if (!Context.getTargetInfo ().validateOutputSize (Literal->getString (), Size ))
322
- return StmtResult (targetDiag (OutputExpr->getBeginLoc (),
323
- diag::err_asm_invalid_output_size)
324
- << Info.getConstraintStr ());
326
+ if (!Context.getTargetInfo ().validateOutputSize (Literal->getString (),
327
+ Size )) {
328
+ targetDiag (OutputExpr->getBeginLoc (), diag::err_asm_invalid_output_size)
329
+ << Info.getConstraintStr ();
330
+ return new (Context)
331
+ GCCAsmStmt (Context, AsmLoc, IsSimple, IsVolatile, NumOutputs,
332
+ NumInputs, Names, Constraints, Exprs.data (), AsmString,
333
+ NumClobbers, Clobbers, RParenLoc);
334
+ }
325
335
}
326
336
327
337
SmallVector<TargetInfo::ConstraintInfo, 4 > InputConstraintInfos;
@@ -337,9 +347,12 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
337
347
TargetInfo::ConstraintInfo Info (Literal->getString (), InputName);
338
348
if (!Context.getTargetInfo ().validateInputConstraint (OutputConstraintInfos,
339
349
Info)) {
340
- return StmtResult (targetDiag (Literal->getBeginLoc (),
341
- diag::err_asm_invalid_input_constraint)
342
- << Info.getConstraintStr ());
350
+ targetDiag (Literal->getBeginLoc (), diag::err_asm_invalid_input_constraint)
351
+ << Info.getConstraintStr ();
352
+ return new (Context)
353
+ GCCAsmStmt (Context, AsmLoc, IsSimple, IsVolatile, NumOutputs,
354
+ NumInputs, Names, Constraints, Exprs.data (), AsmString,
355
+ NumClobbers, Clobbers, RParenLoc);
343
356
}
344
357
345
358
ExprResult ER = CheckPlaceholderExpr (Exprs[i]);
@@ -423,10 +436,14 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
423
436
424
437
StringRef Clobber = Literal->getString ();
425
438
426
- if (!Context.getTargetInfo ().isValidClobber (Clobber))
427
- return StmtResult (targetDiag (Literal->getBeginLoc (),
428
- diag::err_asm_unknown_register_name)
429
- << Clobber);
439
+ if (!Context.getTargetInfo ().isValidClobber (Clobber)) {
440
+ targetDiag (Literal->getBeginLoc (), diag::err_asm_unknown_register_name)
441
+ << Clobber;
442
+ return new (Context)
443
+ GCCAsmStmt (Context, AsmLoc, IsSimple, IsVolatile, NumOutputs,
444
+ NumInputs, Names, Constraints, Exprs.data (), AsmString,
445
+ NumClobbers, Clobbers, RParenLoc);
446
+ }
430
447
}
431
448
432
449
GCCAsmStmt *NS =
@@ -437,10 +454,11 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
437
454
// have.
438
455
SmallVector<GCCAsmStmt::AsmStringPiece, 8 > Pieces;
439
456
unsigned DiagOffs;
440
- if (unsigned DiagID = NS->AnalyzeAsmString (Pieces, Context, DiagOffs))
441
- return StmtResult (
442
- targetDiag (getLocationOfStringLiteralByte (AsmString, DiagOffs), DiagID)
443
- << AsmString->getSourceRange ());
457
+ if (unsigned DiagID = NS->AnalyzeAsmString (Pieces, Context, DiagOffs)) {
458
+ targetDiag (getLocationOfStringLiteralByte (AsmString, DiagOffs), DiagID)
459
+ << AsmString->getSourceRange ();
460
+ return NS;
461
+ }
444
462
445
463
// Validate constraints and modifiers.
446
464
for (unsigned i = 0 , e = Pieces.size (); i != e; ++i) {
@@ -496,27 +514,29 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
496
514
TargetInfo::ConstraintInfo &Info = OutputConstraintInfos[i];
497
515
StringRef ConstraintStr = Info.getConstraintStr ();
498
516
unsigned AltCount = ConstraintStr.count (' ,' ) + 1 ;
499
- if (NumAlternatives == ~0U )
517
+ if (NumAlternatives == ~0U ) {
500
518
NumAlternatives = AltCount;
501
- else if (NumAlternatives != AltCount)
502
- return StmtResult (
503
- targetDiag (NS->getOutputExpr (i)->getBeginLoc (),
504
- diag::err_asm_unexpected_constraint_alternatives)
505
- << NumAlternatives << AltCount);
519
+ } else if (NumAlternatives != AltCount) {
520
+ targetDiag (NS->getOutputExpr (i)->getBeginLoc (),
521
+ diag::err_asm_unexpected_constraint_alternatives)
522
+ << NumAlternatives << AltCount;
523
+ return NS;
524
+ }
506
525
}
507
526
SmallVector<size_t , 4 > InputMatchedToOutput (OutputConstraintInfos.size (),
508
527
~0U );
509
528
for (unsigned i = 0 , e = InputConstraintInfos.size (); i != e; ++i) {
510
529
TargetInfo::ConstraintInfo &Info = InputConstraintInfos[i];
511
530
StringRef ConstraintStr = Info.getConstraintStr ();
512
531
unsigned AltCount = ConstraintStr.count (' ,' ) + 1 ;
513
- if (NumAlternatives == ~0U )
532
+ if (NumAlternatives == ~0U ) {
514
533
NumAlternatives = AltCount;
515
- else if (NumAlternatives != AltCount)
516
- return StmtResult (
517
- targetDiag (NS->getInputExpr (i)->getBeginLoc (),
518
- diag::err_asm_unexpected_constraint_alternatives)
519
- << NumAlternatives << AltCount);
534
+ } else if (NumAlternatives != AltCount) {
535
+ targetDiag (NS->getInputExpr (i)->getBeginLoc (),
536
+ diag::err_asm_unexpected_constraint_alternatives)
537
+ << NumAlternatives << AltCount;
538
+ return NS;
539
+ }
520
540
521
541
// If this is a tied constraint, verify that the output and input have
522
542
// either exactly the same type, or that they are int/ptr operands with the
@@ -534,11 +554,10 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
534
554
targetDiag (NS->getInputExpr (i)->getBeginLoc (),
535
555
diag::err_asm_input_duplicate_match)
536
556
<< TiedTo;
537
- return StmtResult (
538
- targetDiag (
539
- NS->getInputExpr (InputMatchedToOutput[TiedTo])->getBeginLoc (),
540
- diag::note_asm_input_duplicate_first)
541
- << TiedTo);
557
+ targetDiag (NS->getInputExpr (InputMatchedToOutput[TiedTo])->getBeginLoc (),
558
+ diag::note_asm_input_duplicate_first)
559
+ << TiedTo;
560
+ return NS;
542
561
}
543
562
InputMatchedToOutput[TiedTo] = i;
544
563
@@ -623,19 +642,18 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
623
642
continue ;
624
643
}
625
644
626
- return StmtResult ( targetDiag (InputExpr->getBeginLoc (),
627
- diag::err_asm_tying_incompatible_types )
628
- << InTy << OutTy << OutputExpr ->getSourceRange ()
629
- << InputExpr-> getSourceRange ()) ;
645
+ targetDiag (InputExpr->getBeginLoc (), diag::err_asm_tying_incompatible_types)
646
+ << InTy << OutTy << OutputExpr-> getSourceRange ( )
647
+ << InputExpr ->getSourceRange ();
648
+ return NS ;
630
649
}
631
650
632
651
// Check for conflicts between clobber list and input or output lists
633
652
SourceLocation ConstraintLoc =
634
653
getClobberConflictLocation (Exprs, Constraints, Clobbers, NumClobbers,
635
654
Context.getTargetInfo (), Context);
636
655
if (ConstraintLoc.isValid ())
637
- return StmtResult (
638
- targetDiag (ConstraintLoc, diag::error_inoutput_conflict_with_clobber));
656
+ targetDiag (ConstraintLoc, diag::error_inoutput_conflict_with_clobber);
639
657
640
658
return NS;
641
659
}
0 commit comments