diff options
author | Tim Northover <tnorthover@apple.com> | 2018-11-02 13:14:11 +0000 |
---|---|---|
committer | Tim Northover <tnorthover@apple.com> | 2018-11-02 13:14:11 +0000 |
commit | 314fbfa1c4c6665c54a220eefb10a6f23010a352 (patch) | |
tree | e7249debf2e3c4d030fd1be7460a7f72a30a1c19 /clang/lib/AST/ExprConstant.cpp | |
parent | c55d09a00e8067f27de2bb88c12a2bee64a2192a (diff) | |
download | bcm5719-llvm-314fbfa1c4c6665c54a220eefb10a6f23010a352.tar.gz bcm5719-llvm-314fbfa1c4c6665c54a220eefb10a6f23010a352.zip |
Reapply Logging: make os_log buffer size an integer constant expression.
The size of an os_log buffer is known at any stage of compilation, so making it
a constant expression means that the common idiom of declaring a buffer for it
won't result in a VLA. That allows the compiler to skip saving and restoring
the stack pointer around such buffers.
This also moves the OSLog and other FormatString helpers from
libclangAnalysis to libclangAST to avoid a circular dependency.
llvm-svn: 345971
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 15efe433bd1..a85d5cf9d5f 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -39,6 +39,7 @@ #include "clang/AST/ASTLambda.h" #include "clang/AST/CharUnits.h" #include "clang/AST/Expr.h" +#include "clang/AST/OSLog.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/StmtVisitor.h" #include "clang/AST/TypeLoc.h" @@ -8126,6 +8127,12 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E, llvm_unreachable("unexpected EvalMode"); } + case Builtin::BI__builtin_os_log_format_buffer_size: { + analyze_os_log::OSLogBufferLayout Layout; + analyze_os_log::computeOSLogBufferLayout(Info.Ctx, E, Layout); + return Success(Layout.size().getQuantity(), E); + } + case Builtin::BI__builtin_bswap16: case Builtin::BI__builtin_bswap32: case Builtin::BI__builtin_bswap64: { |