r178507 - Use the ASYContext::getTypeSizeInChars API to cleanup some ugliness, per John

Chad Rosier mcrosier at apple.com
Mon Apr 1 15:02:05 PDT 2013


Author: mcrosier
Date: Mon Apr  1 17:02:05 2013
New Revision: 178507

URL: http://llvm.org/viewvc/llvm-project?rev=178507&view=rev
Log:
Use the ASYContext::getTypeSizeInChars API to cleanup some ugliness, per John
and Jordan's suggestion.  No functional change intendend.

Modified:
    cfe/trunk/lib/Sema/SemaStmtAsm.cpp

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=178507&r1=178506&r2=178507&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Mon Apr  1 17:02:05 2013
@@ -519,15 +519,13 @@ NamedDecl *Sema::LookupInlineAsmIdentifi
   if (isa<FunctionDecl>(FoundDecl))
     return FoundDecl;
   if (VarDecl *Var = dyn_cast<VarDecl>(FoundDecl)) {
-    Type = Context.getTypeInfo(Var->getType()).first;
     QualType Ty = Var->getType();
+    Type = Size = Context.getTypeSizeInChars(Ty).getQuantity();
     if (Ty->isArrayType()) {
       const ArrayType *ATy = Context.getAsArrayType(Ty);
-      Length = Type / Context.getTypeInfo(ATy->getElementType()).first;
-      Type /= Length; // Type is in terms of a single element.
+      Type = Context.getTypeSizeInChars(ATy->getElementType()).getQuantity();
+      Length = Size / Type;
     }
-    Type /= 8; // Type is in terms of bits, but we want bytes.
-    Size = Length * Type;
     IsVarDecl = true;
     return FoundDecl;
   }





More information about the cfe-commits mailing list