Skip to content

Commit 13c4092

Browse files
committed
!fixup account for globals without types.
1 parent 8dfaca8 commit 13c4092

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clang/lib/CodeGen/SanitizerMetadata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV,
7272

7373
GV->setSanitizerMetadata(Meta);
7474

75-
if (!CGM.getLangOpts().Sanitize.has(SanitizerKind::Type) ||
75+
if (Ty.isNull() || !CGM.getLangOpts().Sanitize.has(SanitizerKind::Type) ||
7676
NoSanitizeAttrMask & SanitizerKind::Type)
7777
return;
7878

clang/test/CodeGen/sanitize-type-attr.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ struct SX {
5757
};
5858
SX sx;
5959

60+
void consumer(const char *);
61+
62+
void char_caller() {
63+
// TYSAN: void @_Z11char_callerv()
64+
// TYSAN-NEXT: entry:
65+
// TYSAN-NEXT: call void @_Z8consumerPKc(ptr noundef @.str)
66+
// TYSAN-NEXT: ret void
67+
68+
consumer("foo");
69+
}
70+
6071
// WITHOUT: attributes [[NOATTR]] = { noinline nounwind{{.*}} }
6172

6273
// BL: attributes [[NOATTR]] = { noinline nounwind{{.*}} }

0 commit comments

Comments
 (0)