Skip to content

Commit c70bd2b

Browse files
committed
SR-11889: Located added dump methods
1 parent b4b3f98 commit c70bd2b

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

include/swift/Basic/Located.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#ifndef SWIFT_BASIC_LOCATED_H
2020
#define SWIFT_BASIC_LOCATED_H
21+
#include "swift/Basic/Debug.h"
22+
#include "swift/Basic/LLVM.h"
2123
#include "swift/Basic/SourceLoc.h"
2224

2325
namespace swift {
@@ -41,11 +43,15 @@ struct Located {
4143

4244
Located(T Item, SourceLoc loc): Item(Item), Loc(loc) {}
4345

46+
SWIFT_DEBUG_DUMP;
47+
void dump(raw_ostream &os) const;
48+
4449
template<typename U>
4550
friend bool operator ==(const Located<U>& lhs, const Located<U>& rhs) {
4651
return lhs.Item == rhs.Item && lhs.Loc == rhs.Loc;
4752
}
4853
};
49-
}
54+
55+
} // end namespace swift
5056

5157
#endif // SWIFT_BASIC_LOCATED_H

lib/Basic/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ add_swift_host_library(swiftBasic STATIC
7777
JSONSerialization.cpp
7878
LangOptions.cpp
7979
LLVMContext.cpp
80+
Located.cpp
8081
Mangler.cpp
8182
OutputFileMap.cpp
8283
Platform.cpp

lib/Basic/Located.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===--- Located.cpp - Source Location and Associated Value ----------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2019 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
#include "llvm/Support/raw_ostream.h"
12+
#include "swift/Basic/Located.h"
13+
14+
using namespace swift;
15+
16+
template<typename T>
17+
void Located<T>::dump() const {
18+
dump(llvm::errs());
19+
}
20+
21+
template<typename T>
22+
void Located<T>::dump(raw_ostream &os) const {
23+
os << Loc << " " << Item;
24+
}

0 commit comments

Comments
 (0)