Skip to content

Commit

Permalink
Merged master:a1b12a934d9 into amd-gfx:75acce66862
Browse files Browse the repository at this point in the history
Local branch amd-gfx 75acce6 Merged master:e4ef948a434 into amd-gfx:6a6cb0e5da2
Remote branch master a1b12a9 [OpenMP] Add missing RUN lines for OpenMP 4.5
  • Loading branch information
Sw authored and Sw committed Jul 22, 2020
2 parents 75acce6 + a1b12a9 commit cc7ab8f
Show file tree
Hide file tree
Showing 24 changed files with 809 additions and 363 deletions.
13 changes: 6 additions & 7 deletions clang/include/clang/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -522,16 +522,15 @@ class Expr : public ValueStmt {
/// semantically correspond to a bool.
bool isKnownToHaveBooleanValue(bool Semantic = true) const;

/// isIntegerConstantExpr - Return true if this expression is a valid integer
/// constant expression, and, if so, return its value in Result. If not a
/// valid i-c-e, return false and fill in Loc (if specified) with the location
/// of the invalid expression.
/// isIntegerConstantExpr - Return the value if this expression is a valid
/// integer constant expression. If not a valid i-c-e, return None and fill
/// in Loc (if specified) with the location of the invalid expression.
///
/// Note: This does not perform the implicit conversions required by C++11
/// [expr.const]p5.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx,
SourceLocation *Loc = nullptr,
bool isEvaluated = true) const;
Optional<llvm::APSInt> getIntegerConstantExpr(const ASTContext &Ctx,
SourceLocation *Loc = nullptr,
bool isEvaluated = true) const;
bool isIntegerConstantExpr(const ASTContext &Ctx,
SourceLocation *Loc = nullptr) const;

Expand Down
16 changes: 7 additions & 9 deletions clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9471,17 +9471,15 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
const ConstantArrayType* CAT)
-> std::pair<bool,llvm::APInt> {
if (VAT) {
llvm::APSInt TheInt;
Optional<llvm::APSInt> TheInt;
Expr *E = VAT->getSizeExpr();
if (E && E->isIntegerConstantExpr(TheInt, *this))
return std::make_pair(true, TheInt);
else
return std::make_pair(false, TheInt);
} else if (CAT) {
return std::make_pair(true, CAT->getSize());
} else {
return std::make_pair(false, llvm::APInt());
if (E && (TheInt = E->getIntegerConstantExpr(*this)))
return std::make_pair(true, *TheInt);
return std::make_pair(false, llvm::APSInt());
}
if (CAT)
return std::make_pair(true, CAT->getSize());
return std::make_pair(false, llvm::APInt());
};

bool HaveLSize, HaveRSize;
Expand Down
19 changes: 12 additions & 7 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14892,16 +14892,22 @@ bool Expr::isIntegerConstantExpr(const ASTContext &Ctx,
return true;
}

bool Expr::isIntegerConstantExpr(llvm::APSInt &Value, const ASTContext &Ctx,
SourceLocation *Loc, bool isEvaluated) const {
Optional<llvm::APSInt> Expr::getIntegerConstantExpr(const ASTContext &Ctx,
SourceLocation *Loc,
bool isEvaluated) const {
assert(!isValueDependent() &&
"Expression evaluator can't be called on a dependent expression.");

if (Ctx.getLangOpts().CPlusPlus11)
return EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, &Value, Loc);
APSInt Value;

if (Ctx.getLangOpts().CPlusPlus11) {
if (EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, &Value, Loc))
return Value;
return None;
}

if (!isIntegerConstantExpr(Ctx, Loc))
return false;
return None;

// The only possible side-effects here are due to UB discovered in the
// evaluation (for instance, INT_MAX + 1). In such a case, we are still
Expand All @@ -14915,8 +14921,7 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Value, const ASTContext &Ctx,
if (!::EvaluateAsInt(this, ExprResult, Ctx, SE_AllowSideEffects, Info))
llvm_unreachable("ICE cannot be evaluated!");

Value = ExprResult.Val.getInt();
return true;
return ExprResult.Val.getInt();
}

bool Expr::isCXX98IntegralConstantExpr(const ASTContext &Ctx) const {
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/AST/MicrosoftMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1372,9 +1372,9 @@ void MicrosoftCXXNameMangler::mangleIntegerLiteral(const llvm::APSInt &Value,

void MicrosoftCXXNameMangler::mangleExpression(const Expr *E) {
// See if this is a constant expression.
llvm::APSInt Value;
if (E->isIntegerConstantExpr(Value, Context.getASTContext())) {
mangleIntegerLiteral(Value, E->getType()->isBooleanType());
if (Optional<llvm::APSInt> Value =
E->getIntegerConstantExpr(Context.getASTContext())) {
mangleIntegerLiteral(*Value, E->getType()->isBooleanType());
return;
}

Expand Down
16 changes: 8 additions & 8 deletions clang/lib/AST/OpenMPClause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2127,21 +2127,21 @@ void OMPTraitInfo::getAsVariantMatchInfo(ASTContext &ASTCtx,
TraitProperty::user_condition_unknown &&
"Ill-formed user condition, expected unknown trait property!");

llvm::APSInt CondVal;
if (Selector.ScoreOrCondition->isIntegerConstantExpr(CondVal, ASTCtx))
VMI.addTrait(CondVal.isNullValue()
? TraitProperty::user_condition_false
: TraitProperty::user_condition_true);
if (Optional<APSInt> CondVal =
Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx))
VMI.addTrait(CondVal->isNullValue()
? TraitProperty::user_condition_false
: TraitProperty::user_condition_true);
else
VMI.addTrait(TraitProperty::user_condition_false);
continue;
}

llvm::APSInt Score;
Optional<llvm::APSInt> Score;
llvm::APInt *ScorePtr = nullptr;
if (Selector.ScoreOrCondition) {
if (Selector.ScoreOrCondition->isIntegerConstantExpr(Score, ASTCtx))
ScorePtr = &Score;
if ((Score = Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx)))
ScorePtr = &*Score;
else
VMI.addTrait(TraitProperty::user_condition_false);
}
Expand Down
Loading

0 comments on commit cc7ab8f

Please sign in to comment.