brintos

brintos / llvm-project-archived public Read only

0
0
Text · 705 B · 81e7af8 Raw
23 lines · cpp
1// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s2// RUN: %clangxx_msan -fsanitize-memory-track-origins -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s3// RUN: %clangxx_msan -fsanitize-memory-track-origins -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s4 5// Test condition origin propagation through "select" IR instruction.6 7#include <stdio.h>8#include <stdint.h>9 10__attribute__((noinline))11int *max_by_ptr(int *a, int *b) {12  return *a < *b ? b : a;13}14 15int main(void) {16  int x;17  int *volatile px = &x;18  int y = 43;19  int *p = max_by_ptr(px, &y);20  // CHECK: Uninitialized value was created by an allocation of 'x' in the stack frame21  return *p;22}23