From bbe96e50f3bec29588bb873842e2b438536d3efc Mon Sep 17 00:00:00 2001 From: Vlad Tsyrklevich Date: Fri, 4 Aug 2017 20:37:49 +0000 Subject: Revert "Reland "CFI: blacklist STL allocate() from unrelated-casts"" This reverts commit r310105. llvm-svn: 310121 --- clang/lib/CodeGen/CodeGenFunction.cpp | 27 --------------------------- 1 file changed, 27 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp') diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 9d32ad2e7038..fc7a10d08b28 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -723,25 +723,6 @@ static void markAsIgnoreThreadCheckingAtRuntime(llvm::Function *Fn) { Fn->removeFnAttr(llvm::Attribute::SanitizeThread); } -static bool matchesStlAllocatorFn(const Decl *D, const ASTContext &Ctx) { - auto *MD = dyn_cast_or_null(D); - if (!MD || !MD->getName().equals("allocate") || - (MD->getNumParams() != 1 && MD->getNumParams() != 2)) - return false; - - if (MD->parameters()[0]->getType().getCanonicalType() != Ctx.getSizeType()) - return false; - - if (MD->getNumParams() == 2) { - auto *PT = MD->parameters()[1]->getType()->getAs(); - if (!PT || !PT->isVoidPointerType() || - !PT->getPointeeType().isConstQualified()) - return false; - } - - return true; -} - void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, llvm::Function *Fn, @@ -801,14 +782,6 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, } } - // Ignore unrelated casts in STL allocate() since the allocator must cast - // from void* to T* before object initialization completes. Don't match on the - // namespace because not all allocators are in std:: - if (D && SanOpts.has(SanitizerKind::CFIUnrelatedCast)) { - if (matchesStlAllocatorFn(D, getContext())) - SanOpts.Mask &= ~SanitizerKind::CFIUnrelatedCast; - } - // Apply xray attributes to the function (as a string, for now) if (D && ShouldXRayInstrumentFunction()) { if (const auto *XRayAttr = D->getAttr()) { -- cgit v1.2.3