[PATCH] D149514: Check if First argument in _builtin_assume_aligned_ is of pointer type
Rishabh Bali via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 29 01:04:05 PDT 2023
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());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149514.518143.patch
Type: text/x-patch
Size: 729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230429/53e4f2ce/attachment.bin>
More information about the cfe-commits
mailing list