llvm-project/clang/test/CodeGen/asan-strings.c
Aaron Ballman ed509fe296 Use functions with prototypes when appropriate; NFC
A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the tenth batch of tests being updated (there are a
significant number of other tests left to be updated).
2022-02-15 09:28:02 -05:00

18 lines
1.1 KiB
C

// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=address -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefix=LINUX
// RUN: %clang_cc1 -triple x86_64-windows-msvc -fsanitize=address -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefix=WINDOWS
// RUN: %clang_cc1 -triple x86_64-windows-msvc -fsanitize=address -fwritable-strings -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefix=WINWRITE
// On Linux (and basically every non-MS target) string literals are emitted with
// private linkage, which means ASan can freely instrument them. On Windows,
// they are emitted with comdats. ASan's global instrumentation code for COFF
// knows how to make the metadata comdat associative, so the string literal
// global is only registered if the instrumented global prevails during linking.
const char *foo(void) { return "asdf"; }
// LINUX: @.str = private unnamed_addr constant [5 x i8] c"asdf\00", align 1
// WINDOWS: @"??_C@_04JIHMPGLA@asdf?$AA@" = linkonce_odr dso_local unnamed_addr constant [5 x i8] c"asdf\00", comdat, align 1
// WINWRITE: @.str = private unnamed_addr global [5 x i8] c"asdf\00", align 1