| OLD | NEW |
| 1 diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h | 1 diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h |
| 2 index 96603eb..7586cbb 100644 | 2 index c737d5f..352c96c 100644 |
| 3 --- a/include/clang/AST/ExprCXX.h | 3 --- a/include/clang/AST/ExprCXX.h |
| 4 +++ b/include/clang/AST/ExprCXX.h | 4 +++ b/include/clang/AST/ExprCXX.h |
| 5 @@ -1456,6 +1456,9 @@ class CXXNewExpr : public Expr { | 5 @@ -1459,6 +1459,9 @@ class CXXNewExpr : public Expr { |
| 6 /// null. | 6 /// null. |
| 7 FunctionDecl *OperatorDelete; | 7 FunctionDecl *OperatorDelete; |
| 8 | 8 |
| 9 + // TODO(dmikurube): Add a comment. | 9 + // TODO(dmikurube): Add a comment. |
| 10 + FunctionDecl *OperatorNewIntercept; | 10 + FunctionDecl *OperatorNewIntercept; |
| 11 + | 11 + |
| 12 /// \brief The allocated type-source information, as written in the source. | 12 /// \brief The allocated type-source information, as written in the source. |
| 13 TypeSourceInfo *AllocatedTypeInfo; | 13 TypeSourceInfo *AllocatedTypeInfo; |
| 14 | 14 |
| 15 @@ -1530,6 +1533,9 @@ public: | 15 @@ -1533,6 +1536,9 @@ public: |
| 16 FunctionDecl *getOperatorDelete() const { return OperatorDelete; } | 16 FunctionDecl *getOperatorDelete() const { return OperatorDelete; } |
| 17 void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; } | 17 void setOperatorDelete(FunctionDecl *D) { OperatorDelete = D; } |
| 18 | 18 |
| 19 + FunctionDecl *getOperatorNewIntercept() const { return OperatorNewIntercept;
} | 19 + FunctionDecl *getOperatorNewIntercept() const { return OperatorNewIntercept;
} |
| 20 + void setOperatorNewIntercept(FunctionDecl *D) { OperatorNewIntercept = D; } | 20 + void setOperatorNewIntercept(FunctionDecl *D) { OperatorNewIntercept = D; } |
| 21 + | 21 + |
| 22 bool isArray() const { return Array; } | 22 bool isArray() const { return Array; } |
| 23 Expr *getArraySize() { | 23 Expr *getArraySize() { |
| 24 return Array ? cast<Expr>(SubExprs[0]) : 0; | 24 return Array ? cast<Expr>(SubExprs[0]) : 0; |
| 25 @@ -1637,6 +1643,8 @@ public: | 25 @@ -1640,6 +1646,8 @@ public: |
| 26 class CXXDeleteExpr : public Expr { | 26 class CXXDeleteExpr : public Expr { |
| 27 // Points to the operator delete overload that is used. Could be a member. | 27 // Points to the operator delete overload that is used. Could be a member. |
| 28 FunctionDecl *OperatorDelete; | 28 FunctionDecl *OperatorDelete; |
| 29 + // TODO(dmikurube): Add a comment. | 29 + // TODO(dmikurube): Add a comment. |
| 30 + FunctionDecl *OperatorDeleteIntercept; | 30 + FunctionDecl *OperatorDeleteIntercept; |
| 31 // The pointer expression to be deleted. | 31 // The pointer expression to be deleted. |
| 32 Stmt *Argument; | 32 Stmt *Argument; |
| 33 // Location of the expression. | 33 // Location of the expression. |
| 34 @@ -1659,7 +1667,9 @@ public: | 34 @@ -1662,7 +1670,9 @@ public: |
| 35 : Expr(CXXDeleteExprClass, ty, VK_RValue, OK_Ordinary, false, false, | 35 : Expr(CXXDeleteExprClass, ty, VK_RValue, OK_Ordinary, false, false, |
| 36 arg->isInstantiationDependent(), | 36 arg->isInstantiationDependent(), |
| 37 arg->containsUnexpandedParameterPack()), | 37 arg->containsUnexpandedParameterPack()), |
| 38 - OperatorDelete(operatorDelete), Argument(arg), Loc(loc), | 38 - OperatorDelete(operatorDelete), Argument(arg), Loc(loc), |
| 39 + OperatorDelete(operatorDelete), | 39 + OperatorDelete(operatorDelete), |
| 40 + OperatorDeleteIntercept(0), | 40 + OperatorDeleteIntercept(0), |
| 41 + Argument(arg), Loc(loc), | 41 + Argument(arg), Loc(loc), |
| 42 GlobalDelete(globalDelete), | 42 GlobalDelete(globalDelete), |
| 43 ArrayForm(arrayForm), ArrayFormAsWritten(arrayFormAsWritten), | 43 ArrayForm(arrayForm), ArrayFormAsWritten(arrayFormAsWritten), |
| 44 UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize) { } | 44 UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize) { } |
| 45 @@ -1679,6 +1689,12 @@ public: | 45 @@ -1682,6 +1692,12 @@ public: |
| 46 } | 46 } |
| 47 | 47 |
| 48 FunctionDecl *getOperatorDelete() const { return OperatorDelete; } | 48 FunctionDecl *getOperatorDelete() const { return OperatorDelete; } |
| 49 + FunctionDecl *getOperatorDeleteIntercept() const { | 49 + FunctionDecl *getOperatorDeleteIntercept() const { |
| 50 + return OperatorDeleteIntercept; | 50 + return OperatorDeleteIntercept; |
| 51 + } | 51 + } |
| 52 + void setOperatorDeleteIntercept(FunctionDecl *D) { | 52 + void setOperatorDeleteIntercept(FunctionDecl *D) { |
| 53 + OperatorDeleteIntercept = D; | 53 + OperatorDeleteIntercept = D; |
| 54 + } | 54 + } |
| 55 | 55 |
| 56 Expr *getArgument() { return cast<Expr>(Argument); } | 56 Expr *getArgument() { return cast<Expr>(Argument); } |
| 57 const Expr *getArgument() const { return cast<Expr>(Argument); } | 57 const Expr *getArgument() const { return cast<Expr>(Argument); } |
| 58 diff --git a/include/clang/Basic/LangOptions.def b/include/clang/Basic/LangOptio
ns.def | 58 diff --git a/include/clang/Basic/LangOptions.def b/include/clang/Basic/LangOptio
ns.def |
| 59 index f4cba24..5e2ea5a 100644 | 59 index f180e31..0b457e8 100644 |
| 60 --- a/include/clang/Basic/LangOptions.def | 60 --- a/include/clang/Basic/LangOptions.def |
| 61 +++ b/include/clang/Basic/LangOptions.def | 61 +++ b/include/clang/Basic/LangOptions.def |
| 62 @@ -127,6 +127,8 @@ BENIGN_LANGOPT(DebuggerSupport , 1, 0, "debugger support") | 62 @@ -130,6 +130,8 @@ BENIGN_LANGOPT(DebuggerSupport , 1, 0, "debugger support") |
| 63 BENIGN_LANGOPT(DebuggerCastResultToId, 1, 0, "for 'po' in the debugger, cast th
e result to id if it is of unknown type") | 63 BENIGN_LANGOPT(DebuggerCastResultToId, 1, 0, "for 'po' in the debugger, cast th
e result to id if it is of unknown type") |
| 64 BENIGN_LANGOPT(DebuggerObjCLiteral , 1, 0, "debugger Objective-C literals and s
ubscripting support") | 64 BENIGN_LANGOPT(DebuggerObjCLiteral , 1, 0, "debugger Objective-C literals and s
ubscripting support") |
| 65 | 65 |
| 66 +BENIGN_LANGOPT(InterceptAllocationFunctions , 1, 0, "intercepting allocation fu
nctions and allocated types") | 66 +BENIGN_LANGOPT(InterceptAllocationFunctions , 1, 0, "intercepting allocation fu
nctions and allocated types") |
| 67 + | 67 + |
| 68 BENIGN_LANGOPT(SpellChecking , 1, 1, "spell-checking") | 68 BENIGN_LANGOPT(SpellChecking , 1, 1, "spell-checking") |
| 69 LANGOPT(SinglePrecisionConstants , 1, 0, "treating double-precision floating po
int constants as single precision constants") | 69 LANGOPT(SinglePrecisionConstants , 1, 0, "treating double-precision floating po
int constants as single precision constants") |
| 70 LANGOPT(FastRelaxedMath , 1, 0, "OpenCL fast relaxed math") | 70 LANGOPT(FastRelaxedMath , 1, 0, "OpenCL fast relaxed math") |
| 71 diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td | 71 diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td |
| 72 index 2ace8f3..a625fdd 100644 | 72 index 7598643..17e8b70 100644 |
| 73 --- a/include/clang/Driver/Options.td | 73 --- a/include/clang/Driver/Options.td |
| 74 +++ b/include/clang/Driver/Options.td | 74 +++ b/include/clang/Driver/Options.td |
| 75 @@ -299,6 +299,9 @@ def fno_address_sanitizer : Flag<["-"], "fno-address-sanitiz
er">, Group<f_Group> | 75 @@ -299,6 +299,9 @@ def faddress_sanitizer : Flag<["-"], "faddress-sanitizer">,
Group<f_Group>; |
| 76 def fthread_sanitizer : Flag<["-"], "fthread-sanitizer">, Group<f_Group>, | 76 def fno_address_sanitizer : Flag<["-"], "fno-address-sanitizer">, Group<f_Group
>; |
| 77 HelpText<"Enable ThreadSanitizer instrumentation (race detection)">; | 77 def fthread_sanitizer : Flag<["-"], "fthread-sanitizer">, Group<f_Group>; |
| 78 def fno_thread_sanitizer : Flag<["-"], "fno-thread-sanitizer">, Group<f_Group>; | 78 def fno_thread_sanitizer : Flag<["-"], "fno-thread-sanitizer">, Group<f_Group>; |
| 79 +def fintercept_allocation_functions : Flag<["-"], "fintercept-allocation-functi
ons">, Group<f_Group>, Flags<[CC1Option]>, | 79 +def fintercept_allocation_functions : Flag<["-"], "fintercept-allocation-functi
ons">, Group<f_Group>, Flags<[CC1Option]>, |
| 80 + HelpText<"Intercept allocation functions and allocated types">; | 80 + HelpText<"Intercept allocation functions and allocated types">; |
| 81 +def fno_intercept_allocation_functions : Flag<["-"], "fno-intercept-allocation-
functions">, Group<f_Group>, Flags<[CC1Option]>; | 81 +def fno_intercept_allocation_functions : Flag<["-"], "fno-intercept-allocation-
functions">, Group<f_Group>, Flags<[CC1Option]>; |
| 82 def fasm : Flag<["-"], "fasm">, Group<f_Group>; | 82 def fasm : Flag<["-"], "fasm">, Group<f_Group>; |
| 83 | 83 |
| 84 def fasm_blocks : Flag<["-"], "fasm-blocks">, Group<f_Group>; | 84 def fasm_blocks : Flag<["-"], "fasm-blocks">, Group<f_Group>, Flags<[CC1Option]
>; |
| 85 diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h | 85 diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h |
| 86 index 4183dcf..8483209 100644 | 86 index 047804a..1d60251 100644 |
| 87 --- a/include/clang/Sema/Sema.h | 87 --- a/include/clang/Sema/Sema.h |
| 88 +++ b/include/clang/Sema/Sema.h | 88 +++ b/include/clang/Sema/Sema.h |
| 89 @@ -3260,6 +3260,9 @@ public: | 89 @@ -3291,6 +3291,9 @@ public: |
| 90 NamespaceDecl *getStdNamespace() const; | 90 NamespaceDecl *getStdNamespace() const; |
| 91 NamespaceDecl *getOrCreateStdNamespace(); | 91 NamespaceDecl *getOrCreateStdNamespace(); |
| 92 | 92 |
| 93 + RecordDecl *getCXXTypeInfoDecl() const; | 93 + RecordDecl *getCXXTypeInfoDecl() const; |
| 94 + RecordDecl *getOrCreateCXXTypeInfoDecl(); | 94 + RecordDecl *getOrCreateCXXTypeInfoDecl(); |
| 95 + | 95 + |
| 96 CXXRecordDecl *getStdBadAlloc() const; | 96 CXXRecordDecl *getStdBadAlloc() const; |
| 97 | 97 |
| 98 /// \brief Tests whether Ty is an instance of std::initializer_list and, if | 98 /// \brief Tests whether Ty is an instance of std::initializer_list and, if |
| 99 @@ -3790,6 +3793,7 @@ public: | 99 @@ -3821,6 +3824,7 @@ public: |
| 100 void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return, | 100 void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return, |
| 101 QualType Argument, | 101 QualType Argument, |
| 102 bool addMallocAttr = false); | 102 bool addMallocAttr = false); |
| 103 + void DeclareGlobalAllocatorInterceptFunctions(DeclarationName Name); | 103 + void DeclareGlobalAllocatorInterceptFunctions(DeclarationName Name); |
| 104 | 104 |
| 105 bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, | 105 bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, |
| 106 DeclarationName Name, FunctionDecl* &Operator, | 106 DeclarationName Name, FunctionDecl* &Operator, |
| 107 diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp | 107 diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp |
| 108 index 9758b60..ec8dc42 100644 | 108 index 1dc7de1..87dc918 100644 |
| 109 --- a/lib/AST/ExprCXX.cpp | 109 --- a/lib/AST/ExprCXX.cpp |
| 110 +++ b/lib/AST/ExprCXX.cpp | 110 +++ b/lib/AST/ExprCXX.cpp |
| 111 @@ -94,6 +94,7 @@ CXXNewExpr::CXXNewExpr(ASTContext &C, bool globalNew, Function
Decl *operatorNew, | 111 @@ -95,6 +95,7 @@ CXXNewExpr::CXXNewExpr(ASTContext &C, bool globalNew, Function
Decl *operatorNew, |
| 112 ty->isInstantiationDependentType(), | 112 ty->isInstantiationDependentType(), |
| 113 ty->containsUnexpandedParameterPack()), | 113 ty->containsUnexpandedParameterPack()), |
| 114 SubExprs(0), OperatorNew(operatorNew), OperatorDelete(operatorDelete), | 114 SubExprs(0), OperatorNew(operatorNew), OperatorDelete(operatorDelete), |
| 115 + OperatorNewIntercept(0), | 115 + OperatorNewIntercept(0), |
| 116 AllocatedTypeInfo(allocatedTypeInfo), TypeIdParens(typeIdParens), | 116 AllocatedTypeInfo(allocatedTypeInfo), TypeIdParens(typeIdParens), |
| 117 StartLoc(startLoc), DirectInitRange(directInitRange), | 117 Range(Range), DirectInitRange(directInitRange), |
| 118 GlobalNew(globalNew), UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize)
{ | 118 GlobalNew(globalNew), UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize)
{ |
| 119 diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp | 119 diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp |
| 120 index b583c62..757949d 100644 | 120 index 9df8905..1df8c29 100644 |
| 121 --- a/lib/CodeGen/CGClass.cpp | 121 --- a/lib/CodeGen/CGClass.cpp |
| 122 +++ b/lib/CodeGen/CGClass.cpp | 122 +++ b/lib/CodeGen/CGClass.cpp |
| 123 @@ -973,7 +973,9 @@ namespace { | 123 @@ -966,7 +966,9 @@ namespace { |
| 124 void Emit(CodeGenFunction &CGF, Flags flags) { | 124 void Emit(CodeGenFunction &CGF, Flags flags) { |
| 125 const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(CGF.CurCodeDecl); | 125 const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(CGF.CurCodeDecl); |
| 126 const CXXRecordDecl *ClassDecl = Dtor->getParent(); | 126 const CXXRecordDecl *ClassDecl = Dtor->getParent(); |
| 127 - CGF.EmitDeleteCall(Dtor->getOperatorDelete(), CGF.LoadCXXThis(), | 127 - CGF.EmitDeleteCall(Dtor->getOperatorDelete(), CGF.LoadCXXThis(), |
| 128 + // TODO(dmikurube): Not 0 for OperatorDeleteIntercept? | 128 + // TODO(dmikurube): Not 0 for OperatorDeleteIntercept? |
| 129 + CGF.EmitDeleteCall(Dtor->getOperatorDelete(), | 129 + CGF.EmitDeleteCall(Dtor->getOperatorDelete(), |
| 130 + 0, CGF.LoadCXXThis(), | 130 + 0, CGF.LoadCXXThis(), |
| 131 CGF.getContext().getTagDeclType(ClassDecl)); | 131 CGF.getContext().getTagDeclType(ClassDecl)); |
| 132 } | 132 } |
| 133 }; | 133 }; |
| 134 diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp | 134 diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp |
| 135 index 7f640f6..926c325 100644 | 135 index f7d8202..74387b4 100644 |
| 136 --- a/lib/CodeGen/CGExprCXX.cpp | 136 --- a/lib/CodeGen/CGExprCXX.cpp |
| 137 +++ b/lib/CodeGen/CGExprCXX.cpp | 137 +++ b/lib/CodeGen/CGExprCXX.cpp |
| 138 @@ -1227,6 +1227,31 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNew
Expr *E) { | 138 @@ -1227,6 +1227,31 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNew
Expr *E) { |
| 139 allocatorArgs, allocator); | 139 allocatorArgs, allocator); |
| 140 } | 140 } |
| 141 | 141 |
| 142 + FunctionDecl *Intercept = E->getOperatorNewIntercept(); | 142 + FunctionDecl *Intercept = E->getOperatorNewIntercept(); |
| 143 + if (getContext().getLangOpts().InterceptAllocationFunctions && | 143 + if (getContext().getLangOpts().InterceptAllocationFunctions && |
| 144 + getContext().getLangOpts().RTTI && | 144 + getContext().getLangOpts().RTTI && |
| 145 + Intercept) { | 145 + Intercept) { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 if (E->isArrayForm()) { | 347 if (E->isArrayForm()) { |
| 348 EmitArrayDelete(*this, E, Ptr, DeleteTy); | 348 EmitArrayDelete(*this, E, Ptr, DeleteTy); |
| 349 } else { | 349 } else { |
| 350 - EmitObjectDelete(*this, E->getOperatorDelete(), Ptr, DeleteTy, | 350 - EmitObjectDelete(*this, E->getOperatorDelete(), Ptr, DeleteTy, |
| 351 + EmitObjectDelete(*this, E->getOperatorDelete(), | 351 + EmitObjectDelete(*this, E->getOperatorDelete(), |
| 352 + E->getOperatorDeleteIntercept(), Ptr, DeleteTy, | 352 + E->getOperatorDeleteIntercept(), Ptr, DeleteTy, |
| 353 E->isGlobalDelete()); | 353 E->isGlobalDelete()); |
| 354 } | 354 } |
| 355 | 355 |
| 356 diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h | 356 diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h |
| 357 index fadc391..f13eb8e 100644 | 357 index e8f7055..90d1990 100644 |
| 358 --- a/lib/CodeGen/CodeGenFunction.h | 358 --- a/lib/CodeGen/CodeGenFunction.h |
| 359 +++ b/lib/CodeGen/CodeGenFunction.h | 359 +++ b/lib/CodeGen/CodeGenFunction.h |
| 360 @@ -407,6 +407,14 @@ public: | 360 @@ -407,6 +407,14 @@ public: |
| 361 (void) Obj; | 361 (void) Obj; |
| 362 } | 362 } |
| 363 | 363 |
| 364 + /// Push a lazily-created cleanup on the stack. | 364 + /// Push a lazily-created cleanup on the stack. |
| 365 + template <class T, class A0, class A1, class A2, class A3, class A4, class A5
> | 365 + template <class T, class A0, class A1, class A2, class A3, class A4, class A5
> |
| 366 + void pushCleanup(CleanupKind Kind, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
{ | 366 + void pushCleanup(CleanupKind Kind, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
{ |
| 367 + void *Buffer = pushCleanup(Kind, sizeof(T)); | 367 + void *Buffer = pushCleanup(Kind, sizeof(T)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 378 | 378 |
| 379 - void EmitDeleteCall(const FunctionDecl *DeleteFD, llvm::Value *Ptr, | 379 - void EmitDeleteCall(const FunctionDecl *DeleteFD, llvm::Value *Ptr, |
| 380 - QualType DeleteTy); | 380 - QualType DeleteTy); |
| 381 + void EmitDeleteCall(const FunctionDecl *DeleteFD, | 381 + void EmitDeleteCall(const FunctionDecl *DeleteFD, |
| 382 + const FunctionDecl *DeleteFDIntercept, | 382 + const FunctionDecl *DeleteFDIntercept, |
| 383 + llvm::Value *Ptr, QualType DeleteTy); | 383 + llvm::Value *Ptr, QualType DeleteTy); |
| 384 | 384 |
| 385 llvm::Value* EmitCXXTypeidExpr(const CXXTypeidExpr *E); | 385 llvm::Value* EmitCXXTypeidExpr(const CXXTypeidExpr *E); |
| 386 llvm::Value *EmitDynamicCast(llvm::Value *V, const CXXDynamicCastExpr *DCE); | 386 llvm::Value *EmitDynamicCast(llvm::Value *V, const CXXDynamicCastExpr *DCE); |
| 387 diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp | 387 diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp |
| 388 index 2eca3fe..48869ea 100644 | 388 index eec3974..58f259c 100644 |
| 389 --- a/lib/Driver/Tools.cpp | 389 --- a/lib/Driver/Tools.cpp |
| 390 +++ b/lib/Driver/Tools.cpp | 390 +++ b/lib/Driver/Tools.cpp |
| 391 @@ -2444,6 +2444,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction
&JA, | 391 @@ -2482,6 +2482,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction
&JA, |
| 392 if (getToolChain().SupportsProfiling()) | 392 if (getToolChain().SupportsProfiling()) |
| 393 Args.AddLastArg(CmdArgs, options::OPT_pg); | 393 Args.AddLastArg(CmdArgs, options::OPT_pg); |
| 394 | 394 |
| 395 + if (Args.hasFlag(options::OPT_fintercept_allocation_functions, | 395 + if (Args.hasFlag(options::OPT_fintercept_allocation_functions, |
| 396 + options::OPT_fno_intercept_allocation_functions, false)) { | 396 + options::OPT_fno_intercept_allocation_functions, false)) { |
| 397 + CmdArgs.push_back("-fintercept-allocation-functions"); | 397 + CmdArgs.push_back("-fintercept-allocation-functions"); |
| 398 + CmdArgs.push_back("-include"); | 398 + CmdArgs.push_back("-include"); |
| 399 + CmdArgs.push_back("typeinfo"); | 399 + CmdArgs.push_back("typeinfo"); |
| 400 + } | 400 + } |
| 401 + | 401 + |
| 402 // -flax-vector-conversions is default. | 402 // -flax-vector-conversions is default. |
| 403 if (!Args.hasFlag(options::OPT_flax_vector_conversions, | 403 if (!Args.hasFlag(options::OPT_flax_vector_conversions, |
| 404 options::OPT_fno_lax_vector_conversions)) | 404 options::OPT_fno_lax_vector_conversions)) |
| 405 diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocati
on.cpp | 405 diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocati
on.cpp |
| 406 index d0ff7d2..b2825fd 100644 | 406 index 711e0e3..9a9703d 100644 |
| 407 --- a/lib/Frontend/CompilerInvocation.cpp | 407 --- a/lib/Frontend/CompilerInvocation.cpp |
| 408 +++ b/lib/Frontend/CompilerInvocation.cpp | 408 +++ b/lib/Frontend/CompilerInvocation.cpp |
| 409 @@ -1233,6 +1233,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args
, InputKind IK, | 409 @@ -1237,6 +1237,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args
, InputKind IK, |
| 410 Opts.DebuggerSupport = Args.hasArg(OPT_fdebugger_support); | 410 Opts.DebuggerSupport = Args.hasArg(OPT_fdebugger_support); |
| 411 Opts.DebuggerCastResultToId = Args.hasArg(OPT_fdebugger_cast_result_to_id); | 411 Opts.DebuggerCastResultToId = Args.hasArg(OPT_fdebugger_cast_result_to_id); |
| 412 Opts.DebuggerObjCLiteral = Args.hasArg(OPT_fdebugger_objc_literal); | 412 Opts.DebuggerObjCLiteral = Args.hasArg(OPT_fdebugger_objc_literal); |
| 413 + Opts.InterceptAllocationFunctions = | 413 + Opts.InterceptAllocationFunctions = |
| 414 + Args.hasArg(OPT_fintercept_allocation_functions); | 414 + Args.hasArg(OPT_fintercept_allocation_functions); |
| 415 Opts.ApplePragmaPack = Args.hasArg(OPT_fapple_pragma_pack); | 415 Opts.ApplePragmaPack = Args.hasArg(OPT_fapple_pragma_pack); |
| 416 Opts.CurrentModule = Args.getLastArgValue(OPT_fmodule_name); | 416 Opts.CurrentModule = Args.getLastArgValue(OPT_fmodule_name); |
| 417 | 417 |
| 418 diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp | 418 diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp |
| 419 index f9eb9eb..078cdb3 100644 | 419 index 027491c..3a2bdd0 100644 |
| 420 --- a/lib/Sema/SemaDeclCXX.cpp | 420 --- a/lib/Sema/SemaDeclCXX.cpp |
| 421 +++ b/lib/Sema/SemaDeclCXX.cpp | 421 +++ b/lib/Sema/SemaDeclCXX.cpp |
| 422 @@ -5160,6 +5160,7 @@ bool Sema::CheckDestructor(CXXDestructorDecl *Destructor)
{ | 422 @@ -5688,6 +5688,7 @@ bool Sema::CheckDestructor(CXXDestructorDecl *Destructor)
{ |
| 423 | 423 |
| 424 MarkFunctionReferenced(Loc, OperatorDelete); | 424 MarkFunctionReferenced(Loc, OperatorDelete); |
| 425 | 425 |
| 426 + // TODO(dmikurube): OperatorDeleteIntercept required? | 426 + // TODO(dmikurube): OperatorDeleteIntercept required? |
| 427 Destructor->setOperatorDelete(OperatorDelete); | 427 Destructor->setOperatorDelete(OperatorDelete); |
| 428 } | 428 } |
| 429 | 429 |
| 430 @@ -5664,6 +5665,32 @@ NamespaceDecl *Sema::getOrCreateStdNamespace() { | 430 @@ -6192,6 +6193,32 @@ NamespaceDecl *Sema::getOrCreateStdNamespace() { |
| 431 return getStdNamespace(); | 431 return getStdNamespace(); |
| 432 } | 432 } |
| 433 | 433 |
| 434 +RecordDecl *Sema::getCXXTypeInfoDecl() const { | 434 +RecordDecl *Sema::getCXXTypeInfoDecl() const { |
| 435 + return CXXTypeInfoDecl; | 435 + return CXXTypeInfoDecl; |
| 436 +} | 436 +} |
| 437 + | 437 + |
| 438 +RecordDecl *Sema::getOrCreateCXXTypeInfoDecl() { | 438 +RecordDecl *Sema::getOrCreateCXXTypeInfoDecl() { |
| 439 + if (!CXXTypeInfoDecl) { | 439 + if (!CXXTypeInfoDecl) { |
| 440 + IdentifierInfo *TypeInfoII = &PP.getIdentifierTable().get("type_info"); | 440 + IdentifierInfo *TypeInfoII = &PP.getIdentifierTable().get("type_info"); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 454 + return NULL; | 454 + return NULL; |
| 455 + } | 455 + } |
| 456 + | 456 + |
| 457 + return getCXXTypeInfoDecl(); | 457 + return getCXXTypeInfoDecl(); |
| 458 +} | 458 +} |
| 459 + | 459 + |
| 460 bool Sema::isStdInitializerList(QualType Ty, QualType *Element) { | 460 bool Sema::isStdInitializerList(QualType Ty, QualType *Element) { |
| 461 assert(getLangOpts().CPlusPlus && | 461 assert(getLangOpts().CPlusPlus && |
| 462 "Looking for std::initializer_list outside of C++."); | 462 "Looking for std::initializer_list outside of C++."); |
| 463 diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp | 463 diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp |
| 464 index bed6cb0..609833a 100644 | 464 index e3df0a3..d718c39 100644 |
| 465 --- a/lib/Sema/SemaExprCXX.cpp | 465 --- a/lib/Sema/SemaExprCXX.cpp |
| 466 +++ b/lib/Sema/SemaExprCXX.cpp | 466 +++ b/lib/Sema/SemaExprCXX.cpp |
| 467 @@ -371,26 +371,15 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation
LParenLoc, | 467 @@ -371,26 +371,15 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation
LParenLoc, |
| 468 if (!getStdNamespace()) | 468 if (!getStdNamespace()) |
| 469 return ExprError(Diag(OpLoc, diag::err_need_header_before_typeid)); | 469 return ExprError(Diag(OpLoc, diag::err_need_header_before_typeid)); |
| 470 | 470 |
| 471 - if (!CXXTypeInfoDecl) { | 471 - if (!CXXTypeInfoDecl) { |
| 472 - IdentifierInfo *TypeInfoII = &PP.getIdentifierTable().get("type_info"); | 472 - IdentifierInfo *TypeInfoII = &PP.getIdentifierTable().get("type_info"); |
| 473 - LookupResult R(*this, TypeInfoII, SourceLocation(), LookupTagName); | 473 - LookupResult R(*this, TypeInfoII, SourceLocation(), LookupTagName); |
| 474 - LookupQualifiedName(R, getStdNamespace()); | 474 - LookupQualifiedName(R, getStdNamespace()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 488 | 488 |
| 489 if (!getLangOpts().RTTI) { | 489 if (!getLangOpts().RTTI) { |
| 490 return ExprError(Diag(OpLoc, diag::err_no_typeid_with_fno_rtti)); | 490 return ExprError(Diag(OpLoc, diag::err_no_typeid_with_fno_rtti)); |
| 491 } | 491 } |
| 492 | 492 |
| 493 - QualType TypeInfoType = Context.getTypeDeclType(CXXTypeInfoDecl); | 493 - QualType TypeInfoType = Context.getTypeDeclType(CXXTypeInfoDecl); |
| 494 + QualType TypeInfoType = Context.getTypeDeclType(TypeInfoDecl); | 494 + QualType TypeInfoType = Context.getTypeDeclType(TypeInfoDecl); |
| 495 | 495 |
| 496 if (isType) { | 496 if (isType) { |
| 497 // The operand is a type; handle it as such. | 497 // The operand is a type; handle it as such. |
| 498 @@ -1400,14 +1389,75 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGloba
l, | 498 @@ -1397,14 +1386,75 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, |
| 499 } | 499 } |
| 500 } | 500 } |
| 501 | 501 |
| 502 - return Owned(new (Context) CXXNewExpr(Context, UseGlobal, OperatorNew, | 502 - return Owned(new (Context) CXXNewExpr(Context, UseGlobal, OperatorNew, |
| 503 - OperatorDelete, | |
| 504 - UsualArrayDeleteWantsSize, | |
| 505 - llvm::makeArrayRef(PlaceArgs, NumPlaceArgs), | |
| 506 - TypeIdParens, | |
| 507 - ArraySize, initStyle, Initializer, | |
| 508 - ResultType, AllocTypeInfo, | |
| 509 - StartLoc, DirectInitRange)); | |
| 510 + CXXNewExpr* Result = | 503 + CXXNewExpr* Result = |
| 511 + new (Context) CXXNewExpr(Context, UseGlobal, OperatorNew, | 504 + new (Context) CXXNewExpr(Context, UseGlobal, OperatorNew, |
| 512 + OperatorDelete, | 505 OperatorDelete, |
| 513 + UsualArrayDeleteWantsSize, | 506 UsualArrayDeleteWantsSize, |
| 514 + llvm::makeArrayRef(PlaceArgs, NumPlaceArgs), | 507 llvm::makeArrayRef(PlaceArgs, NumPlaceArgs), |
| 515 + TypeIdParens, | 508 TypeIdParens, |
| 516 + ArraySize, initStyle, Initializer, | 509 ArraySize, initStyle, Initializer, |
| 517 + ResultType, AllocTypeInfo, | 510 ResultType, AllocTypeInfo, |
| 518 + StartLoc, DirectInitRange); | 511 - Range, DirectInitRange)); |
| 512 + Range, DirectInitRange); |
| 519 + | 513 + |
| 520 + if (getLangOpts().InterceptAllocationFunctions && | 514 + if (getLangOpts().InterceptAllocationFunctions && |
| 521 + getLangOpts().RTTI) { | 515 + getLangOpts().RTTI) { |
| 522 + IdentifierInfo *NewInterceptInfo = | 516 + IdentifierInfo *NewInterceptInfo = |
| 523 + &PP.getIdentifierTable().get("__op_new_intercept__"); | 517 + &PP.getIdentifierTable().get("__op_new_intercept__"); |
| 524 + DeclareGlobalAllocatorInterceptFunctions( | 518 + DeclareGlobalAllocatorInterceptFunctions( |
| 525 + DeclarationName(NewInterceptInfo)); | 519 + DeclarationName(NewInterceptInfo)); |
| 526 + LookupResult R(*this, NewInterceptInfo, SourceLocation(), | 520 + LookupResult R(*this, NewInterceptInfo, SourceLocation(), |
| 527 + LookupOrdinaryName); | 521 + LookupOrdinaryName); |
| 528 + LookupQualifiedName(R, Context.getTranslationUnitDecl()); | 522 + LookupQualifiedName(R, Context.getTranslationUnitDecl()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 + default: | 566 + default: |
| 573 + ; | 567 + ; |
| 574 + } | 568 + } |
| 575 + } | 569 + } |
| 576 + } | 570 + } |
| 577 + | 571 + |
| 578 + return Owned(Result); | 572 + return Owned(Result); |
| 579 } | 573 } |
| 580 | 574 |
| 581 /// \brief Checks that a type is suitable as the allocated type | 575 /// \brief Checks that a type is suitable as the allocated type |
| 582 @@ -1847,6 +1897,80 @@ void Sema::DeclareGlobalNewDelete() { | 576 @@ -1844,6 +1894,80 @@ void Sema::DeclareGlobalNewDelete() { |
| 583 Context.VoidTy, VoidPtr); | 577 Context.VoidTy, VoidPtr); |
| 584 } | 578 } |
| 585 | 579 |
| 586 +/// DeclareGlobalAllocatorInterceptFunctions - Declares a single implicit globa
l | 580 +/// DeclareGlobalAllocatorInterceptFunctions - Declares a single implicit globa
l |
| 587 +/// allocator intercept functions if it doesn't already exist. | 581 +/// allocator intercept functions if it doesn't already exist. |
| 588 +void Sema::DeclareGlobalAllocatorInterceptFunctions(DeclarationName Name) { | 582 +void Sema::DeclareGlobalAllocatorInterceptFunctions(DeclarationName Name) { |
| 589 + DeclContext *GlobalCtx = Context.getTranslationUnitDecl(); | 583 + DeclContext *GlobalCtx = Context.getTranslationUnitDecl(); |
| 590 + | 584 + |
| 591 + QualType VoidPtrType = Context.getPointerType(Context.VoidTy); | 585 + QualType VoidPtrType = Context.getPointerType(Context.VoidTy); |
| 592 + QualType SizeType = Context.getSizeType(); | 586 + QualType SizeType = Context.getSizeType(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 + | 647 + |
| 654 + // FIXME: Also add this declaration to the IdentifierResolver, but | 648 + // FIXME: Also add this declaration to the IdentifierResolver, but |
| 655 + // make sure it is at the end of the chain to coincide with the | 649 + // make sure it is at the end of the chain to coincide with the |
| 656 + // global scope. | 650 + // global scope. |
| 657 + Context.getTranslationUnitDecl()->addDecl(Intercept); | 651 + Context.getTranslationUnitDecl()->addDecl(Intercept); |
| 658 +} | 652 +} |
| 659 + | 653 + |
| 660 /// DeclareGlobalAllocationFunction - Declares a single implicit global | 654 /// DeclareGlobalAllocationFunction - Declares a single implicit global |
| 661 /// allocation function if it doesn't already exist. | 655 /// allocation function if it doesn't already exist. |
| 662 void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, | 656 void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, |
| 663 @@ -2206,10 +2330,70 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGl
obal, | 657 @@ -2207,10 +2331,70 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGl
obal, |
| 664 | 658 |
| 665 } | 659 } |
| 666 | 660 |
| 667 - return Owned(new (Context) CXXDeleteExpr(Context.VoidTy, UseGlobal, ArrayForm
, | 661 - return Owned(new (Context) CXXDeleteExpr(Context.VoidTy, UseGlobal, ArrayForm
, |
| 668 - ArrayFormAsWritten, | 662 - ArrayFormAsWritten, |
| 669 - UsualArrayDeleteWantsSize, | 663 - UsualArrayDeleteWantsSize, |
| 670 - OperatorDelete, Ex.take(), StartLoc)
); | 664 - OperatorDelete, Ex.take(), StartLoc)
); |
| 671 + CXXDeleteExpr* Result = | 665 + CXXDeleteExpr* Result = |
| 672 + new (Context) CXXDeleteExpr(Context.VoidTy, UseGlobal, ArrayForm, | 666 + new (Context) CXXDeleteExpr(Context.VoidTy, UseGlobal, ArrayForm, |
| 673 + ArrayFormAsWritten, | 667 + ArrayFormAsWritten, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 + default: | 722 + default: |
| 729 + ; | 723 + ; |
| 730 + } | 724 + } |
| 731 + } | 725 + } |
| 732 + } | 726 + } |
| 733 + | 727 + |
| 734 + return Owned(Result); | 728 + return Owned(Result); |
| 735 } | 729 } |
| 736 | 730 |
| 737 /// \brief Check the use of the given variable as a C++ condition in an if, | 731 /// \brief Check the use of the given variable as a C++ condition in an if, |
| OLD | NEW |