[asan] add missing asan instrumentation in generated global init functions
llvm-svn: 159191
This commit is contained in:
parent
26d4cc1b96
commit
bf84b8fa3b
|
@ -228,6 +228,9 @@ CreateGlobalInitOrDestructFunction(CodeGenModule &CGM,
|
||||||
if (!CGM.getLangOpts().Exceptions)
|
if (!CGM.getLangOpts().Exceptions)
|
||||||
Fn->setDoesNotThrow();
|
Fn->setDoesNotThrow();
|
||||||
|
|
||||||
|
if (CGM.getLangOpts().AddressSanitizer)
|
||||||
|
Fn->addFnAttr(llvm::Attribute::AddressSafety);
|
||||||
|
|
||||||
return Fn;
|
return Fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,3 +33,9 @@ int TemplateAddressSafetyOk() { return i; }
|
||||||
|
|
||||||
int force_instance = TemplateAddressSafetyOk<42>()
|
int force_instance = TemplateAddressSafetyOk<42>()
|
||||||
+ TemplateNoAddressSafety<42>();
|
+ TemplateNoAddressSafety<42>();
|
||||||
|
|
||||||
|
// Check that __cxx_global_var_init* get the address_safety attribute.
|
||||||
|
int global1 = 0;
|
||||||
|
int global2 = *(int*)((char*)&global1+1);
|
||||||
|
// CHECK-NOT: @__cxx_global_var_init{{.*}}address_safety
|
||||||
|
// ASAN: @__cxx_global_var_init{{.*}}address_safety
|
||||||
|
|
Loading…
Reference in New Issue