[clang] [compiler-rt] [UBSan] Fix incorrect alignment reported when global new returns an o… (PR #152532)
    Eli Friedman via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Tue Oct 21 09:13:34 PDT 2025
    
    
  
================
@@ -1749,17 +1739,29 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
       allocator->isReservedGlobalPlacementOperator())
     result = Builder.CreateLaunderInvariantGroup(result);
 
+  // Check what type of constructor call the sanitizer is checking
+  // Different UB can occour with custom overloads of operator new
+  TypeCheckKind checkKind = CodeGenFunction::TCK_ConstructorCall;
+  const TargetInfo &TI = getContext().getTargetInfo();
+  unsigned DefaultTargetAlignment = TI.getNewAlign() / TI.getCharWidth();
+  SourceManager &SM = getContext().getSourceManager();
+  SourceLocation Loc = E->getOperatorNew()->getLocation();
+  bool IsCustomOverload = !SM.isInSystemHeader(Loc);
----------------
efriedma-quic wrote:
No, the declaration of the operator is still in a system header; just the definition is in user code.
https://github.com/llvm/llvm-project/pull/152532
    
    
More information about the llvm-commits
mailing list