leanil created this revision.
leanil added reviewers: dcoughlin, xazax.hun, NoQ.
Herald added subscribers: a.sidorin, rnkovacs, szepet.
Herald added a reviewer: george.karpenkov.

This will handle those platforms that don't have 8-bit chars.
This is a follow up fix to review https://reviews.llvm.org/D41384, which has 
been committed since.


https://reviews.llvm.org/D43928

Files:
  lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp


Index: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
+++ lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
@@ -514,7 +514,7 @@
              *Source = CE->getArg(1)->IgnoreImpCasts();
   if (const auto *DeclRef = dyn_cast<DeclRefExpr>(Target))
     if (const auto *Array = dyn_cast<ConstantArrayType>(DeclRef->getType())) {
-      uint64_t ArraySize = BR.getContext().getTypeSize(Array) / 8;
+      uint64_t ArraySize = 
BR.getContext().getTypeSizeInChars(Array).getQuantity();
       if (const auto *String = dyn_cast<StringLiteral>(Source)) {
         if (ArraySize >= String->getLength() + 1)
           return;


Index: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
+++ lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
@@ -514,7 +514,7 @@
              *Source = CE->getArg(1)->IgnoreImpCasts();
   if (const auto *DeclRef = dyn_cast<DeclRefExpr>(Target))
     if (const auto *Array = dyn_cast<ConstantArrayType>(DeclRef->getType())) {
-      uint64_t ArraySize = BR.getContext().getTypeSize(Array) / 8;
+      uint64_t ArraySize = BR.getContext().getTypeSizeInChars(Array).getQuantity();
       if (const auto *String = dyn_cast<StringLiteral>(Source)) {
         if (ArraySize >= String->getLength() + 1)
           return;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to