[Flang] remove whole-archive option for AIX linker (#76039)
[llvm-project.git] / clang / lib / Analysis / FlowSensitive / Value.cpp
blob349f873f1e6c4d9fa81508aaac8c1618f534bcde
1 //===-- Value.cpp -----------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines support functions for the `Value` type.
11 //===----------------------------------------------------------------------===//
13 #include "clang/Analysis/FlowSensitive/Value.h"
14 #include "clang/Analysis/FlowSensitive/DebugSupport.h"
15 #include "llvm/Support/Casting.h"
17 namespace clang {
18 namespace dataflow {
20 static bool areEquivalentIndirectionValues(const Value &Val1,
21 const Value &Val2) {
22 if (auto *IndVal1 = dyn_cast<PointerValue>(&Val1)) {
23 auto *IndVal2 = cast<PointerValue>(&Val2);
24 return &IndVal1->getPointeeLoc() == &IndVal2->getPointeeLoc();
26 return false;
29 bool areEquivalentValues(const Value &Val1, const Value &Val2) {
30 return &Val1 == &Val2 || (Val1.getKind() == Val2.getKind() &&
31 (isa<TopBoolValue>(&Val1) ||
32 areEquivalentIndirectionValues(Val1, Val2)));
35 raw_ostream &operator<<(raw_ostream &OS, const Value &Val) {
36 switch (Val.getKind()) {
37 case Value::Kind::Integer:
38 return OS << "Integer(@" << &Val << ")";
39 case Value::Kind::Pointer:
40 return OS << "Pointer(" << &cast<PointerValue>(Val).getPointeeLoc() << ")";
41 case Value::Kind::Record:
42 return OS << "Record(" << &cast<RecordValue>(Val).getLoc() << ")";
43 case Value::Kind::TopBool:
44 return OS << "TopBool(" << cast<TopBoolValue>(Val).getAtom() << ")";
45 case Value::Kind::AtomicBool:
46 return OS << "AtomicBool(" << cast<AtomicBoolValue>(Val).getAtom() << ")";
47 case Value::Kind::FormulaBool:
48 return OS << "FormulaBool(" << cast<FormulaBoolValue>(Val).formula() << ")";
50 llvm_unreachable("Unknown clang::dataflow::Value::Kind enum");
53 } // namespace dataflow
54 } // namespace clang