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 | |
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')
-rw-r--r-- | clang/lib/AST/CMakeLists.txt | 4 | ||||
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 7 | ||||
-rw-r--r-- | clang/lib/AST/FormatString.cpp (renamed from clang/lib/Analysis/FormatString.cpp) | 0 | ||||
-rw-r--r-- | clang/lib/AST/FormatStringParsing.h (renamed from clang/lib/Analysis/FormatStringParsing.h) | 2 | ||||
-rw-r--r-- | clang/lib/AST/OSLog.cpp (renamed from clang/lib/Analysis/OSLog.cpp) | 4 | ||||
-rw-r--r-- | clang/lib/AST/PrintfFormatString.cpp (renamed from clang/lib/Analysis/PrintfFormatString.cpp) | 4 | ||||
-rw-r--r-- | clang/lib/AST/ScanfFormatString.cpp (renamed from clang/lib/Analysis/ScanfFormatString.cpp) | 2 | ||||
-rw-r--r-- | clang/lib/Analysis/CMakeLists.txt | 4 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 9 | ||||
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 2 |
10 files changed, 19 insertions, 19 deletions
diff --git a/clang/lib/AST/CMakeLists.txt b/clang/lib/AST/CMakeLists.txt index 4f868a3af59..45ed87d670f 100644 --- a/clang/lib/AST/CMakeLists.txt +++ b/clang/lib/AST/CMakeLists.txt @@ -39,6 +39,7 @@ add_clang_library(clangAST ExprObjC.cpp ExternalASTMerger.cpp ExternalASTSource.cpp + FormatString.cpp InheritViz.cpp ItaniumCXXABI.cpp ItaniumMangle.cpp @@ -48,12 +49,15 @@ add_clang_library(clangAST NestedNameSpecifier.cpp NSAPI.cpp ODRHash.cpp + OSLog.cpp OpenMPClause.cpp ParentMap.cpp + PrintfFormatString.cpp QualTypeNames.cpp RawCommentList.cpp RecordLayout.cpp RecordLayoutBuilder.cpp + ScanfFormatString.cpp SelectorLocationsKind.cpp Stmt.cpp StmtCXX.cpp 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: { diff --git a/clang/lib/Analysis/FormatString.cpp b/clang/lib/AST/FormatString.cpp index 5e2137c7088..5e2137c7088 100644 --- a/clang/lib/Analysis/FormatString.cpp +++ b/clang/lib/AST/FormatString.cpp diff --git a/clang/lib/Analysis/FormatStringParsing.h b/clang/lib/AST/FormatStringParsing.h index a63140b366c..91fab155e4c 100644 --- a/clang/lib/Analysis/FormatStringParsing.h +++ b/clang/lib/AST/FormatStringParsing.h @@ -3,7 +3,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/Type.h" -#include "clang/Analysis/Analyses/FormatString.h" +#include "clang/AST/FormatString.h" namespace clang { diff --git a/clang/lib/Analysis/OSLog.cpp b/clang/lib/AST/OSLog.cpp index b2983932ea2..cf20706c4b3 100644 --- a/clang/lib/Analysis/OSLog.cpp +++ b/clang/lib/AST/OSLog.cpp @@ -1,11 +1,11 @@ // TODO: header template -#include "clang/Analysis/Analyses/OSLog.h" +#include "clang/AST/OSLog.h" #include "clang/AST/Attr.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/ExprObjC.h" -#include "clang/Analysis/Analyses/FormatString.h" +#include "clang/AST/FormatString.h" #include "clang/Basic/Builtins.h" #include "llvm/ADT/SmallBitVector.h" diff --git a/clang/lib/Analysis/PrintfFormatString.cpp b/clang/lib/AST/PrintfFormatString.cpp index dcb15c5e375..96a8f258ed3 100644 --- a/clang/lib/Analysis/PrintfFormatString.cpp +++ b/clang/lib/AST/PrintfFormatString.cpp @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#include "clang/Analysis/Analyses/FormatString.h" -#include "clang/Analysis/Analyses/OSLog.h" +#include "clang/AST/FormatString.h" +#include "clang/AST/OSLog.h" #include "FormatStringParsing.h" #include "clang/Basic/TargetInfo.h" diff --git a/clang/lib/Analysis/ScanfFormatString.cpp b/clang/lib/AST/ScanfFormatString.cpp index a9af0cdfdac..bda97c57c87 100644 --- a/clang/lib/Analysis/ScanfFormatString.cpp +++ b/clang/lib/AST/ScanfFormatString.cpp @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -#include "clang/Analysis/Analyses/FormatString.h" +#include "clang/AST/FormatString.h" #include "FormatStringParsing.h" #include "clang/Basic/TargetInfo.h" diff --git a/clang/lib/Analysis/CMakeLists.txt b/clang/lib/Analysis/CMakeLists.txt index 36a37f49858..5345a56f200 100644 --- a/clang/lib/Analysis/CMakeLists.txt +++ b/clang/lib/Analysis/CMakeLists.txt @@ -16,15 +16,11 @@ add_clang_library(clangAnalysis CodeInjector.cpp Dominators.cpp ExprMutationAnalyzer.cpp - FormatString.cpp LiveVariables.cpp - OSLog.cpp ObjCNoReturn.cpp PostOrderCFGView.cpp - PrintfFormatString.cpp ProgramPoint.cpp ReachableCode.cpp - ScanfFormatString.cpp ThreadSafety.cpp ThreadSafetyCommon.cpp ThreadSafetyLogical.cpp diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 2c7a3d720a7..f880e93068a 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -21,7 +21,7 @@ #include "TargetInfo.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" -#include "clang/Analysis/Analyses/OSLog.h" +#include "clang/AST/OSLog.h" #include "clang/Basic/TargetBuiltins.h" #include "clang/Basic/TargetInfo.h" #include "clang/CodeGen/CGFunctionInfo.h" @@ -3606,13 +3606,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, case Builtin::BI__builtin_os_log_format: return emitBuiltinOSLogFormat(*E); - case Builtin::BI__builtin_os_log_format_buffer_size: { - analyze_os_log::OSLogBufferLayout Layout; - analyze_os_log::computeOSLogBufferLayout(CGM.getContext(), E, Layout); - return RValue::get(ConstantInt::get(ConvertType(E->getType()), - Layout.size().getQuantity())); - } - case Builtin::BI__xray_customevent: { if (!ShouldXRayInstrumentFunction()) return RValue::getIgnored(); diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 792171a4f5d..4660ed55aee 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -27,6 +27,7 @@ #include "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" #include "clang/AST/ExprOpenMP.h" +#include "clang/AST/FormatString.h" #include "clang/AST/NSAPI.h" #include "clang/AST/NonTrivialTypeVisitor.h" #include "clang/AST/OperationKinds.h" @@ -35,7 +36,6 @@ #include "clang/AST/Type.h" #include "clang/AST/TypeLoc.h" #include "clang/AST/UnresolvedSet.h" -#include "clang/Analysis/Analyses/FormatString.h" #include "clang/Basic/AddressSpaces.h" #include "clang/Basic/CharInfo.h" #include "clang/Basic/Diagnostic.h" |