tbaeder updated this revision to Diff 476391. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138270/new/
https://reviews.llvm.org/D138270 Files: clang/include/clang/Sema/Sema.h clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaChecking.cpp clang/unittests/Support/TimeProfilerTest.cpp Index: clang/unittests/Support/TimeProfilerTest.cpp =================================================================== --- clang/unittests/Support/TimeProfilerTest.cpp +++ clang/unittests/Support/TimeProfilerTest.cpp @@ -178,9 +178,7 @@ ASSERT_TRUE(TraceGraph == R"( Frontend | EvaluateAsRValue (<test.cc:8:21>) -| EvaluateForOverflow (<test.cc:8:21, col:25>) | EvaluateAsRValue (<test.cc:9:14>) -| EvaluateForOverflow (<test.cc:9:9, col:14>) | isPotentialConstantExpr (slow_namespace::slow_func) | EvaluateAsBooleanCondition (<test.cc:8:21, col:25>) | | EvaluateAsRValue (<test.cc:8:21, col:25>) Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -15542,11 +15542,14 @@ bool IsConstexpr) { llvm::SaveAndRestore<bool> ConstantContext( isConstantEvaluatedOverride, IsConstexpr || isa<ConstantExpr>(E)); + CheckImplicitConversions(E, CheckLoc); if (!E->isInstantiationDependent()) CheckUnsequencedOperations(E); - if (!IsConstexpr && !E->isValueDependent()) + + if (!IsConstexpr && !E->isValueDependent() && !curFunctionDeclIsConstexpr()) CheckForIntOverflow(E); + DiagnoseMisalignedMembers(); } Index: clang/lib/Sema/Sema.cpp =================================================================== --- clang/lib/Sema/Sema.cpp +++ clang/lib/Sema/Sema.cpp @@ -1438,7 +1438,7 @@ // Helper functions. //===----------------------------------------------------------------------===// -DeclContext *Sema::getFunctionLevelDeclContext(bool AllowLambda) { +DeclContext *Sema::getFunctionLevelDeclContext(bool AllowLambda) const { DeclContext *DC = CurContext; while (true) { @@ -1458,7 +1458,7 @@ /// getCurFunctionDecl - If inside of a function body, this returns a pointer /// to the function decl for the function being parsed. If we're currently /// in a 'block', this returns the containing context. -FunctionDecl *Sema::getCurFunctionDecl(bool AllowLambda) { +FunctionDecl *Sema::getCurFunctionDecl(bool AllowLambda) const { DeclContext *DC = getFunctionLevelDeclContext(AllowLambda); return dyn_cast<FunctionDecl>(DC); } Index: clang/include/clang/Sema/Sema.h =================================================================== --- clang/include/clang/Sema/Sema.h +++ clang/include/clang/Sema/Sema.h @@ -3503,13 +3503,18 @@ void ActOnExitFunctionContext(); /// If \p AllowLambda is true, treat lambda as function. - DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false); + DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false) const; /// Returns a pointer to the innermost enclosing function, or nullptr if the /// current context is not inside a function. If \p AllowLambda is true, /// this can return the call operator of an enclosing lambda, otherwise /// lambdas are skipped when looking for an enclosing function. - FunctionDecl *getCurFunctionDecl(bool AllowLambda = false); + FunctionDecl *getCurFunctionDecl(bool AllowLambda = false) const; + + bool curFunctionDeclIsConstexpr() const { + const FunctionDecl *FD = getCurFunctionDecl(); + return FD ? FD->isConstexpr() : false; + } /// getCurMethodDecl - If inside of a method body, this returns a pointer to /// the method decl for the method being parsed. If we're currently
Index: clang/unittests/Support/TimeProfilerTest.cpp =================================================================== --- clang/unittests/Support/TimeProfilerTest.cpp +++ clang/unittests/Support/TimeProfilerTest.cpp @@ -178,9 +178,7 @@ ASSERT_TRUE(TraceGraph == R"( Frontend | EvaluateAsRValue (<test.cc:8:21>) -| EvaluateForOverflow (<test.cc:8:21, col:25>) | EvaluateAsRValue (<test.cc:9:14>) -| EvaluateForOverflow (<test.cc:9:9, col:14>) | isPotentialConstantExpr (slow_namespace::slow_func) | EvaluateAsBooleanCondition (<test.cc:8:21, col:25>) | | EvaluateAsRValue (<test.cc:8:21, col:25>) Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -15542,11 +15542,14 @@ bool IsConstexpr) { llvm::SaveAndRestore<bool> ConstantContext( isConstantEvaluatedOverride, IsConstexpr || isa<ConstantExpr>(E)); + CheckImplicitConversions(E, CheckLoc); if (!E->isInstantiationDependent()) CheckUnsequencedOperations(E); - if (!IsConstexpr && !E->isValueDependent()) + + if (!IsConstexpr && !E->isValueDependent() && !curFunctionDeclIsConstexpr()) CheckForIntOverflow(E); + DiagnoseMisalignedMembers(); } Index: clang/lib/Sema/Sema.cpp =================================================================== --- clang/lib/Sema/Sema.cpp +++ clang/lib/Sema/Sema.cpp @@ -1438,7 +1438,7 @@ // Helper functions. //===----------------------------------------------------------------------===// -DeclContext *Sema::getFunctionLevelDeclContext(bool AllowLambda) { +DeclContext *Sema::getFunctionLevelDeclContext(bool AllowLambda) const { DeclContext *DC = CurContext; while (true) { @@ -1458,7 +1458,7 @@ /// getCurFunctionDecl - If inside of a function body, this returns a pointer /// to the function decl for the function being parsed. If we're currently /// in a 'block', this returns the containing context. -FunctionDecl *Sema::getCurFunctionDecl(bool AllowLambda) { +FunctionDecl *Sema::getCurFunctionDecl(bool AllowLambda) const { DeclContext *DC = getFunctionLevelDeclContext(AllowLambda); return dyn_cast<FunctionDecl>(DC); } Index: clang/include/clang/Sema/Sema.h =================================================================== --- clang/include/clang/Sema/Sema.h +++ clang/include/clang/Sema/Sema.h @@ -3503,13 +3503,18 @@ void ActOnExitFunctionContext(); /// If \p AllowLambda is true, treat lambda as function. - DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false); + DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false) const; /// Returns a pointer to the innermost enclosing function, or nullptr if the /// current context is not inside a function. If \p AllowLambda is true, /// this can return the call operator of an enclosing lambda, otherwise /// lambdas are skipped when looking for an enclosing function. - FunctionDecl *getCurFunctionDecl(bool AllowLambda = false); + FunctionDecl *getCurFunctionDecl(bool AllowLambda = false) const; + + bool curFunctionDeclIsConstexpr() const { + const FunctionDecl *FD = getCurFunctionDecl(); + return FD ? FD->isConstexpr() : false; + } /// getCurMethodDecl - If inside of a method body, this returns a pointer to /// the method decl for the method being parsed. If we're currently
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits