Skip to content

Commit 12f4ee0

Browse files
committed
Fix
Created using spr 1.3.5
2 parents 4eedce5 + c632ac3 commit 12f4ee0

File tree

75 files changed

+1078
-478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1078
-478
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,6 @@ Improvements to Clang's diagnostics
525525

526526
- Fixed a duplicate diagnostic when performing typo correction on function template
527527
calls with explicit template arguments. (#GH139226)
528-
529-
- An error is now emitted when OpenMP ``collapse`` and ``ordered`` clauses have an
530-
argument larger than what can fit within a 64-bit integer.
531528

532529
- Explanatory note is printed when ``assert`` fails during evaluation of a
533530
constant expression. Prior to this, the error inaccurately implied that assert
@@ -946,6 +943,12 @@ OpenMP Support
946943
- Fixed a crashing bug with a malformed ``cancel`` directive. (#GH139360)
947944
- Fixed a crashing bug with ``omp distribute dist_schedule`` if the argument to
948945
``dist_schedule`` was not strictly positive. (#GH139266)
946+
- Fixed two crashing bugs with a malformed ``metadirective`` directive. One was
947+
a crash if the next token after ``metadirective`` was a paren, bracket, or
948+
brace. The other was if the next token after the meta directive was not an
949+
open parenthesis. (#GH139665)
950+
- An error is now emitted when OpenMP ``collapse`` and ``ordered`` clauses have
951+
an argument larger than what can fit within a 64-bit integer.
949952

950953
Improvements
951954
^^^^^^^^^^^^

clang/include/clang/AST/Expr.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4566,9 +4566,11 @@ class ShuffleVectorExpr : public Expr {
45664566

45674567
void setExprs(const ASTContext &C, ArrayRef<Expr *> Exprs);
45684568

4569-
llvm::APSInt getShuffleMaskIdx(const ASTContext &Ctx, unsigned N) const {
4569+
llvm::APSInt getShuffleMaskIdx(unsigned N) const {
45704570
assert((N < NumExprs - 2) && "Shuffle idx out of range!");
4571-
return getExpr(N+2)->EvaluateKnownConstInt(Ctx);
4571+
assert(isa<ConstantExpr>(getExpr(N + 2)) &&
4572+
"Index expression must be a ConstantExpr");
4573+
return cast<ConstantExpr>(getExpr(N + 2))->getAPValueResult().getInt();
45724574
}
45734575

45744576
// Iterators

clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ class SymbolConjured : public SymbolData {
103103
const Stmt *getStmt() const {
104104
switch (Elem->getKind()) {
105105
case CFGElement::Initializer:
106-
return Elem->castAs<CFGInitializer>().getInitializer()->getInit();
106+
if (const auto *Init = Elem->castAs<CFGInitializer>().getInitializer()) {
107+
return Init->getInit();
108+
}
109+
return nullptr;
107110
case CFGElement::ScopeBegin:
108111
return Elem->castAs<CFGScopeBegin>().getTriggerStmt();
109112
case CFGElement::ScopeEnd:

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3883,7 +3883,7 @@ bool Compiler<Emitter>::VisitShuffleVectorExpr(const ShuffleVectorExpr *E) {
38833883
return false;
38843884
}
38853885
for (unsigned I = 0; I != NumOutputElems; ++I) {
3886-
APSInt ShuffleIndex = E->getShuffleMaskIdx(Ctx.getASTContext(), I);
3886+
APSInt ShuffleIndex = E->getShuffleMaskIdx(I);
38873887
assert(ShuffleIndex >= -1);
38883888
if (ShuffleIndex == -1)
38893889
return this->emitInvalidShuffleVectorIndex(I, E);

clang/lib/AST/ExprConstant.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11571,7 +11571,7 @@ static bool handleVectorShuffle(EvalInfo &Info, const ShuffleVectorExpr *E,
1157111571
unsigned const TotalElementsInInputVector1 = VecVal1.getVectorLength();
1157211572
unsigned const TotalElementsInInputVector2 = VecVal2.getVectorLength();
1157311573

11574-
APSInt IndexVal = E->getShuffleMaskIdx(Info.Ctx, EltNum);
11574+
APSInt IndexVal = E->getShuffleMaskIdx(EltNum);
1157511575
int64_t index = IndexVal.getExtValue();
1157611576
// The spec says that -1 should be treated as undef for optimizations,
1157711577
// but in constexpr we'd have to produce an APValue::Indeterminate,

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,7 @@ Value *ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
19061906

19071907
SmallVector<int, 32> Indices;
19081908
for (unsigned i = 2; i < E->getNumSubExprs(); ++i) {
1909-
llvm::APSInt Idx = E->getShuffleMaskIdx(CGF.getContext(), i-2);
1909+
llvm::APSInt Idx = E->getShuffleMaskIdx(i - 2);
19101910
// Check for -1 and output it as undef in the IR.
19111911
if (Idx.isSigned() && Idx.isAllOnes())
19121912
Indices.push_back(-1);

clang/lib/Headers/__clang_hip_cmath.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ class __promote : public __promote_imp<_A1, _A2, _A3> {};
448448
} // namespace __hip
449449

450450
// __HIP_OVERLOAD1 is used to resolve function calls with integer argument to
451-
// avoid compilation error due to ambibuity. e.g. floor(5) is resolved with
451+
// avoid compilation error due to ambiguity. e.g. floor(5) is resolved with
452452
// floor(double).
453453
#define __HIP_OVERLOAD1(__retty, __fn) \
454454
template <typename __T> \
@@ -459,7 +459,7 @@ class __promote : public __promote_imp<_A1, _A2, _A3> {};
459459
}
460460

461461
// __HIP_OVERLOAD2 is used to resolve function calls with mixed float/double
462-
// or integer argument to avoid compilation error due to ambibuity. e.g.
462+
// or integer argument to avoid compilation error due to ambiguity. e.g.
463463
// max(5.0f, 6.0) is resolved with max(double, double).
464464
#if __cplusplus >= 201103L
465465
#define __HIP_OVERLOAD2(__retty, __fn) \

clang/lib/Parse/ParseOpenMP.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2613,6 +2613,11 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
26132613
Diag(Tok, diag::err_omp_unknown_directive);
26142614
return StmtError();
26152615
}
2616+
if (DKind == OMPD_workshare) {
2617+
// "workshare" is an executable, Fortran-only directive. Treat it
2618+
// as unknown.
2619+
DKind = OMPD_unknown;
2620+
}
26162621

26172622
StmtResult Directive = StmtError();
26182623

@@ -2661,8 +2666,12 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
26612666
? OMPC_unknown
26622667
: getOpenMPClauseKind(PP.getSpelling(Tok));
26632668
// Check if the clause is unrecognized.
2664-
if (CKind == OMPC_unknown)
2669+
if (CKind == OMPC_unknown) {
26652670
Diag(Tok, diag::err_omp_expected_clause) << "metadirective";
2671+
TPA.Revert();
2672+
SkipUntil(tok::annot_pragma_openmp_end);
2673+
return Directive;
2674+
}
26662675
if (getLangOpts().OpenMP < 52 && CKind == OMPC_otherwise)
26672676
Diag(Tok, diag::err_omp_unexpected_clause)
26682677
<< getOpenMPClauseName(CKind) << "metadirective";
@@ -2673,8 +2682,11 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
26732682

26742683
// Parse '('.
26752684
if (T.expectAndConsume(diag::err_expected_lparen_after,
2676-
getOpenMPClauseName(CKind).data()))
2685+
getOpenMPClauseName(CKind).data())) {
2686+
TPA.Revert();
2687+
SkipUntil(tok::annot_pragma_openmp_end);
26772688
return Directive;
2689+
}
26782690

26792691
OMPTraitInfo &TI = Actions.getASTContext().getNewOMPTraitInfo();
26802692
if (CKind == OMPC_when) {

clang/lib/Sema/SemaChecking.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5342,29 +5342,29 @@ ExprResult Sema::BuiltinShuffleVector(CallExpr *TheCall) {
53425342
}
53435343

53445344
for (unsigned i = 2; i < TheCall->getNumArgs(); i++) {
5345-
if (TheCall->getArg(i)->isTypeDependent() ||
5346-
TheCall->getArg(i)->isValueDependent())
5345+
Expr *Arg = TheCall->getArg(i);
5346+
if (Arg->isTypeDependent() || Arg->isValueDependent())
53475347
continue;
53485348

53495349
std::optional<llvm::APSInt> Result;
5350-
if (!(Result = TheCall->getArg(i)->getIntegerConstantExpr(Context)))
5350+
if (!(Result = Arg->getIntegerConstantExpr(Context)))
53515351
return ExprError(Diag(TheCall->getBeginLoc(),
53525352
diag::err_shufflevector_nonconstant_argument)
5353-
<< TheCall->getArg(i)->getSourceRange());
5353+
<< Arg->getSourceRange());
53545354

53555355
// Allow -1 which will be translated to undef in the IR.
53565356
if (Result->isSigned() && Result->isAllOnes())
5357-
continue;
5358-
5359-
if (Result->getActiveBits() > 64 ||
5360-
Result->getZExtValue() >= numElements * 2)
5357+
;
5358+
else if (Result->getActiveBits() > 64 ||
5359+
Result->getZExtValue() >= numElements * 2)
53615360
return ExprError(Diag(TheCall->getBeginLoc(),
53625361
diag::err_shufflevector_argument_too_large)
5363-
<< TheCall->getArg(i)->getSourceRange());
5364-
}
5362+
<< Arg->getSourceRange());
53655363

5366-
SmallVector<Expr*, 32> exprs;
5364+
TheCall->setArg(i, ConstantExpr::Create(Context, Arg, APValue(*Result)));
5365+
}
53675366

5367+
SmallVector<Expr *> exprs;
53685368
for (unsigned i = 0, e = TheCall->getNumArgs(); i != e; i++) {
53695369
exprs.push_back(TheCall->getArg(i));
53705370
TheCall->setArg(i, nullptr);

clang/lib/Sema/SemaConcept.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1999,8 +1999,9 @@ FormulaType SubsumptionChecker::Normalize(const NormalizedConstraint &NC) {
19991999
});
20002000

20012001
if (NC.getCompoundKind() == FormulaType::Kind) {
2002+
auto SizeLeft = Left.size();
20022003
Res = std::move(Left);
2003-
Res.reserve(Left.size() + Right.size());
2004+
Res.reserve(SizeLeft + Right.size());
20042005
std::for_each(std::make_move_iterator(Right.begin()),
20052006
std::make_move_iterator(Right.end()), Add);
20062007
return Res;

0 commit comments

Comments
 (0)