Ris-Bali created this revision.
Ris-Bali added a reviewer: tbaeder.
Ris-Bali added a project: clang.
Herald added a project: All.
Ris-Bali requested review of this revision.
Herald added a subscriber: cfe-commits.

Currently clang doesn't verify if the first argument in 
_builtin_assume_aligned_ is of pointer type. This leads to an assertion build 
failure. This patch aims to add a check if the first argument is of pointer 
type or not and diagnose it with `diag::err_typecheck_convert_incompatible` if 
its not of pointer type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149514

Files:
  clang/lib/Sema/SemaChecking.cpp


Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -7981,6 +7981,14 @@
         DefaultFunctionArrayLvalueConversion(FirstArg);
     if (FirstArgResult.isInvalid())
       return true;
+    Qualtype firstArgType = FirstArgResult.get()->getType();
+
+    if (!firstArgType->isAnyPointerType()) {
+      Qualtype expectedType = Context.getPointerType(firstArgType);
+      return Diag(FirstArg->getBeginLoc(),
+                  diag::err_typecheck_convert_incompatible)
+             << firstArgType << expectedType << 1 << 0 << 0;
+    }      
     TheCall->setArg(0, FirstArgResult.get());
   }
 


Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -7981,6 +7981,14 @@
         DefaultFunctionArrayLvalueConversion(FirstArg);
     if (FirstArgResult.isInvalid())
       return true;
+    Qualtype firstArgType = FirstArgResult.get()->getType();
+
+    if (!firstArgType->isAnyPointerType()) {
+      Qualtype expectedType = Context.getPointerType(firstArgType);
+      return Diag(FirstArg->getBeginLoc(),
+                  diag::err_typecheck_convert_incompatible)
+             << firstArgType << expectedType << 1 << 0 << 0;
+    }      
     TheCall->setArg(0, FirstArgResult.get());
   }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to