Skip to content

Commit 76cf895

Browse files
committed
Revert "[HLSL] error on out of bounds vector accesses (#128952)"
This caused false-positive errors, see comment on the PR. > Add Sema checking and diagnostics to error on out of bounds vector > accesses > Add tests > Closes #91640 This reverts commit f1e3675.
1 parent 30fa7a2 commit 76cf895

File tree

6 files changed

+1
-49
lines changed

6 files changed

+1
-49
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,6 @@ Improvements to Clang's diagnostics
236236
under the subgroup ``-Wunsafe-buffer-usage-in-libc-call``.
237237
- Diagnostics on chained comparisons (``a < b < c``) are now an error by default. This can be disabled with
238238
``-Wno-error=parentheses``.
239-
- Adds an error diagnostic for out of bounds vector accesses; produces an error
240-
for compile time statically provable out of bounds vector accesses.
241239
- The ``-Wshift-bool`` warning has been added to warn about shifting a boolean. (#GH28334)
242240
- Fixed diagnostics adding a trailing ``::`` when printing some source code
243241
constructs, like base classes.

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10688,9 +10688,6 @@ def err_block_on_vm : Error<
1068810688
def err_sizeless_nonlocal : Error<
1068910689
"non-local variable with sizeless type %0">;
1069010690

10691-
def err_vector_index_out_of_range : Error<
10692-
"vector element index %0 is out of bounds">;
10693-
1069410691
def err_vec_builtin_non_vector : Error<
1069510692
"%select{first two|all}1 arguments to %0 must be vectors">;
1069610693
def err_vec_builtin_incompatible_vector : Error<

clang/include/clang/Sema/Sema.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2468,7 +2468,6 @@ class Sema final : public SemaBase {
24682468
const ArraySubscriptExpr *ASE = nullptr,
24692469
bool AllowOnePastEnd = true, bool IndexNegated = false);
24702470
void CheckArrayAccess(const Expr *E);
2471-
void CheckVectorAccess(const Expr *BaseExpr, const Expr *IndexExpr);
24722471

24732472
bool CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
24742473
const FunctionProtoType *Proto);

clang/lib/Sema/SemaChecking.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14055,23 +14055,6 @@ void Sema::CheckCastAlign(Expr *Op, QualType T, SourceRange TRange) {
1405514055
<< TRange << Op->getSourceRange();
1405614056
}
1405714057

14058-
void Sema::CheckVectorAccess(const Expr *BaseExpr, const Expr *IndexExpr) {
14059-
const auto *VTy = BaseExpr->getType()->getAs<VectorType>();
14060-
if (!VTy)
14061-
return;
14062-
14063-
Expr::EvalResult Result;
14064-
if (!IndexExpr->EvaluateAsInt(Result, Context, Expr::SE_AllowSideEffects))
14065-
return;
14066-
14067-
unsigned DiagID = diag::err_vector_index_out_of_range;
14068-
14069-
llvm::APSInt index = Result.Val.getInt();
14070-
if (index.isNegative() || index >= VTy->getNumElements())
14071-
Diag(BaseExpr->getBeginLoc(), DiagID) << toString(index, 10, true);
14072-
return;
14073-
}
14074-
1407514058
void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
1407614059
const ArraySubscriptExpr *ASE,
1407714060
bool AllowOnePastEnd, bool IndexNegated) {
@@ -14086,12 +14069,6 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
1408614069
const Type *EffectiveType =
1408714070
BaseExpr->getType()->getPointeeOrArrayElementType();
1408814071
BaseExpr = BaseExpr->IgnoreParenCasts();
14089-
14090-
if (BaseExpr->getType()->isVectorType()) {
14091-
CheckVectorAccess(BaseExpr, IndexExpr);
14092-
return;
14093-
}
14094-
1409514072
const ConstantArrayType *ArrayTy =
1409614073
Context.getAsConstantArrayType(BaseExpr->getType());
1409714074

clang/test/CodeGenCXX/x86_64-arguments.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,6 @@ union U {
215215
float f1;
216216
char __attribute__((__vector_size__(1))) f2;
217217
};
218-
int f(union U u) { return u.f2[0]; }
218+
int f(union U u) { return u.f2[1]; }
219219
// CHECK-LABEL: define{{.*}} i32 @_ZN6test111fENS_1UE(i32
220220
}

clang/test/SemaHLSL/Language/VectorOutOfRange-errors.hlsl

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)