BuildBot fix, compiler complains about array decay to pointer
[llvm-core.git] / unittests / Analysis / GlobalsModRefTest.cpp
blob323edc2cc1759e4054222562028fdd281f4c0291
1 //===--- GlobalsModRefTest.cpp - Mixed TBAA unit tests --------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
10 #include "llvm/Analysis/GlobalsModRef.h"
11 #include "llvm/AsmParser/Parser.h"
12 #include "llvm/Support/SourceMgr.h"
13 #include "gtest/gtest.h"
15 using namespace llvm;
17 TEST(GlobalsModRef, OptNone) {
18 StringRef Assembly = R"(
19 define void @f1() optnone {
20 ret void
22 define void @f2() optnone readnone {
23 ret void
25 define void @f3() optnone readonly {
26 ret void
28 )";
30 LLVMContext Context;
31 SMDiagnostic Error;
32 auto M = parseAssemblyString(Assembly, Error, Context);
33 ASSERT_TRUE(M) << "Bad assembly?";
35 const auto &funcs = M->functions();
36 auto I = funcs.begin();
37 ASSERT_NE(I, funcs.end());
38 const Function &F1 = *I;
39 ASSERT_NE(++I, funcs.end());
40 const Function &F2 = *I;
41 ASSERT_NE(++I, funcs.end());
42 const Function &F3 = *I;
43 EXPECT_EQ(++I, funcs.end());
45 Triple Trip(M->getTargetTriple());
46 TargetLibraryInfoImpl TLII(Trip);
47 TargetLibraryInfo TLI(TLII);
48 llvm::CallGraph CG(*M);
50 auto AAR = GlobalsAAResult::analyzeModule(*M, TLI, CG);
52 EXPECT_EQ(FMRB_UnknownModRefBehavior, AAR.getModRefBehavior(&F1));
53 EXPECT_EQ(FMRB_DoesNotAccessMemory, AAR.getModRefBehavior(&F2));
54 EXPECT_EQ(FMRB_OnlyReadsMemory, AAR.getModRefBehavior(&F3));