[cfe-commits] r54941 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Sema/SemaStmt.cpp

Chris Lattner sabre at nondot.org
Mon Aug 18 12:55:17 PDT 2008


Author: lattner
Date: Mon Aug 18 14:55:17 2008
New Revision: 54941

URL: http://llvm.org/viewvc/llvm-project?rev=54941&view=rev
Log:
Several cleanups and tweaks to diagnostics in Sema::ActOnAsmStmt,
no other functionality change.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def
    cfe/trunk/lib/Sema/SemaStmt.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=54941&r1=54940&r2=54941&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Mon Aug 18 14:55:17 2008
@@ -1001,15 +1001,15 @@
     "Pascal string is too long")
 DIAG(err_asm_wide_character, ERROR,
     "wide string is invalid in 'asm'")
-DIAG(err_invalid_lvalue_in_asm_output, ERROR,
+DIAG(err_asm_invalid_lvalue_in_output, ERROR,
     "invalid lvalue in asm output")
-DIAG(err_invalid_output_constraint_in_asm, ERROR,
-    "invalid output constraint in asm")
-DIAG(err_invalid_input_constraint_in_asm, ERROR,
-    "invalid input constraint in asm")
-DIAG(err_invalid_type_in_asm_input, ERROR,
-    "invalid type '%0' in asm input")
-DIAG(err_unknown_register_name_in_asm, ERROR,
+DIAG(err_asm_invalid_output_constraint, ERROR,
+    "invalid output constraint '%0' in asm")
+DIAG(err_asm_invalid_input_constraint, ERROR,
+    "invalid input constraint '%0' in asm")
+DIAG(err_asm_invalid_type_in_input, ERROR,
+    "invalid type '%0' in asm input for constraint '%1'")
+DIAG(err_asm_unknown_register_name, ERROR,
     "unknown register name '%0' in asm")
 DIAG(err_invalid_conversion_between_vectors, ERROR,
     "invalid conversion between vector type '%0' and '%1' of different size")

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=54941&r1=54940&r2=54941&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Mon Aug 18 14:55:17 2008
@@ -675,22 +675,26 @@
                                     unsigned NumOutputs,
                                     unsigned NumInputs,
                                     std::string *Names,
-                                    ExprTy **Constraints,
-                                    ExprTy **Exprs,
+                                    ExprTy **constraints,
+                                    ExprTy **exprs,
                                     ExprTy *asmString,
                                     unsigned NumClobbers,
-                                    ExprTy **Clobbers,
+                                    ExprTy **clobbers,
                                     SourceLocation RParenLoc) {
-  // The parser verifies that there is a string literal here.
+  StringLiteral **Constraints = reinterpret_cast<StringLiteral**>(constraints);
+  Expr **Exprs = reinterpret_cast<Expr **>(exprs);
   StringLiteral *AsmString = cast<StringLiteral>((Expr *)asmString);
+  StringLiteral **Clobbers = reinterpret_cast<StringLiteral**>(clobbers);
+  
+  // The parser verifies that there is a string literal here.
   if (AsmString->isWide())
     // FIXME: We currently leak memory here.
     return Diag(AsmString->getLocStart(), diag::err_asm_wide_character,
                 AsmString->getSourceRange());
   
   
-  for (unsigned i = 0; i < NumOutputs; i++) {
-    StringLiteral *Literal = cast<StringLiteral>((Expr *)Constraints[i]);
+  for (unsigned i = 0; i != NumOutputs; i++) {
+    StringLiteral *Literal = Constraints[i];
     if (Literal->isWide())
       // FIXME: We currently leak memory here.
       return Diag(Literal->getLocStart(), diag::err_asm_wide_character,
@@ -703,23 +707,21 @@
     if (!Context.Target.validateOutputConstraint(OutputConstraint.c_str(),info))
       // FIXME: We currently leak memory here.
       return Diag(Literal->getLocStart(),
-                  diag::err_invalid_output_constraint_in_asm);
+                  diag::err_asm_invalid_output_constraint, OutputConstraint);
     
     // Check that the output exprs are valid lvalues.
-    Expr *OutputExpr = (Expr *)Exprs[i];
+    ParenExpr *OutputExpr = cast<ParenExpr>(Exprs[i]);
     Expr::isLvalueResult Result = OutputExpr->isLvalue(Context);
     if (Result != Expr::LV_Valid) {
-      ParenExpr *PE = cast<ParenExpr>(OutputExpr);
-      
       // FIXME: We currently leak memory here.
-      return Diag(PE->getSubExpr()->getLocStart(), 
-                  diag::err_invalid_lvalue_in_asm_output,
-                  PE->getSubExpr()->getSourceRange());
+      return Diag(OutputExpr->getSubExpr()->getLocStart(), 
+                  diag::err_asm_invalid_lvalue_in_output,
+                  OutputExpr->getSubExpr()->getSourceRange());
     }
   }
   
   for (unsigned i = NumOutputs, e = NumOutputs + NumInputs; i != e; i++) {
-    StringLiteral *Literal = cast<StringLiteral>((Expr *)Constraints[i]);
+    StringLiteral *Literal = Constraints[i];
     if (Literal->isWide())
       // FIXME: We currently leak memory here.
       return Diag(Literal->getLocStart(), diag::err_asm_wide_character,
@@ -730,29 +732,27 @@
     
     TargetInfo::ConstraintInfo info;
     if (!Context.Target.validateInputConstraint(InputConstraint.c_str(),
-                                                NumOutputs,                                                
-                                                info)) {
+                                                NumOutputs, info)) {
       // FIXME: We currently leak memory here.
       return Diag(Literal->getLocStart(),
-                  diag::err_invalid_input_constraint_in_asm);
+                  diag::err_asm_invalid_input_constraint, InputConstraint);
     }
     
     // Check that the input exprs aren't of type void.
-    Expr *InputExpr = (Expr *)Exprs[i];    
+    ParenExpr *InputExpr = cast<ParenExpr>(Exprs[i]);
     if (InputExpr->getType()->isVoidType()) {
-      ParenExpr *PE = cast<ParenExpr>(InputExpr);
       
       // FIXME: We currently leak memory here.
-      return Diag(PE->getSubExpr()->getLocStart(),
-                  diag::err_invalid_type_in_asm_input,
-                  PE->getType().getAsString(), 
-                  PE->getSubExpr()->getSourceRange());
+      return Diag(InputExpr->getSubExpr()->getLocStart(),
+                  diag::err_asm_invalid_type_in_input,
+                  InputExpr->getType().getAsString(), InputConstraint,
+                  InputExpr->getSubExpr()->getSourceRange());
     }
   }
   
   // Check that the clobbers are valid.
-  for (unsigned i = 0; i < NumClobbers; i++) {
-    StringLiteral *Literal = cast<StringLiteral>((Expr *)Clobbers[i]);
+  for (unsigned i = 0; i != NumClobbers; i++) {
+    StringLiteral *Literal = Clobbers[i];
     if (Literal->isWide())
       // FIXME: We currently leak memory here.
       return Diag(Literal->getLocStart(), diag::err_asm_wide_character,
@@ -765,20 +765,12 @@
     if (!Context.Target.isValidGCCRegisterName(Clobber.c_str()))
       // FIXME: We currently leak memory here.
       return Diag(Literal->getLocStart(),
-                  diag::err_unknown_register_name_in_asm, Clobber.c_str());
+                  diag::err_asm_unknown_register_name, Clobber.c_str());
   }
   
-  return new AsmStmt(AsmLoc,
-                     IsSimple,
-                     IsVolatile,
-                     NumOutputs,
-                     NumInputs, 
-                     Names,
-                     reinterpret_cast<StringLiteral**>(Constraints),
-                     reinterpret_cast<Expr**>(Exprs),
-                     AsmString, NumClobbers,
-                     reinterpret_cast<StringLiteral**>(Clobbers),
-                     RParenLoc);
+  return new AsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs, NumInputs, 
+                     Names, Constraints, Exprs, AsmString, NumClobbers,
+                     Clobbers, RParenLoc);
 }
 
 Action::StmtResult





More information about the cfe-commits mailing list