Skip to content

Commit

Permalink
Merged master:8032727a43ca into amd-gfx:9c600f889dbd
Browse files Browse the repository at this point in the history
Local branch amd-gfx 9c600f8 Merged master:c37d25f0d1e0 into amd-gfx:8f0252f78f37
Remote branch master 8032727 [DWARFYAML][MachO] Remove endianness related tests.
  • Loading branch information
Sw authored and Sw committed Jun 30, 2020
2 parents 9c600f8 + 8032727 commit a1a3a9d
Show file tree
Hide file tree
Showing 51 changed files with 1,142 additions and 315 deletions.
5 changes: 2 additions & 3 deletions clang-tools-extra/clangd/Preamble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,8 @@ struct ScannedPreamble {
llvm::Expected<ScannedPreamble>
scanPreamble(llvm::StringRef Contents, const tooling::CompileCommand &Cmd) {
class EmptyFS : public ThreadsafeFS {
public:
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
view(llvm::NoneType) const override {
private:
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> viewImpl() const override {
return new llvm::vfs::InMemoryFileSystem;
}
};
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/support/ThreadsafeFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ ThreadsafeFS::view(PathRef CWD) const {
}

llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
RealThreadsafeFS::view(llvm::NoneType) const {
RealThreadsafeFS::viewImpl() const {
// Avoid using memory-mapped files.
// FIXME: Try to use a similar approach in Sema instead of relying on
// propagation of the 'isVolatile' flag through all layers.
Expand Down
19 changes: 12 additions & 7 deletions clang-tools-extra/clangd/support/ThreadsafeFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,25 @@ class ThreadsafeFS {
virtual ~ThreadsafeFS() = default;

/// Obtain a vfs::FileSystem with an arbitrary initial working directory.
virtual llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
view(llvm::NoneType CWD) const = 0;
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
view(llvm::NoneType CWD) const {
return viewImpl();
}

/// Obtain a vfs::FileSystem with a specified working directory.
/// If the working directory can't be set (e.g. doesn't exist), logs and
/// returns the FS anyway.
virtual llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
view(PathRef CWD) const;
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> view(PathRef CWD) const;

private:
/// Overridden by implementations to provide a vfs::FileSystem.
/// This is distinct from view(NoneType) to avoid GCC's -Woverloaded-virtual.
virtual llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> viewImpl() const = 0;
};

class RealThreadsafeFS : public ThreadsafeFS {
public:
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
view(llvm::NoneType) const override;
private:
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> viewImpl() const override;
};

} // namespace clangd
Expand Down
20 changes: 11 additions & 9 deletions clang-tools-extra/clangd/unittests/ClangdTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,13 @@ int b = a;
TEST_F(ClangdVFSTest, PropagatesContexts) {
static Key<int> Secret;
struct ContextReadingFS : public ThreadsafeFS {
IntrusiveRefCntPtr<llvm::vfs::FileSystem>
view(llvm::NoneType) const override {
mutable int Got;

private:
IntrusiveRefCntPtr<llvm::vfs::FileSystem> viewImpl() const override {
Got = Context::current().getExisting(Secret);
return buildTestFS({});
}
mutable int Got;
} FS;
struct Callbacks : public ClangdServer::Callbacks {
void onDiagnosticsReady(PathRef File, llvm::StringRef Version,
Expand Down Expand Up @@ -925,12 +926,17 @@ TEST_F(ClangdVFSTest, ChangedHeaderFromISystem) {
// preamble again. (They should be using the preamble's stat-cache)
TEST(ClangdTests, PreambleVFSStatCache) {
class StatRecordingFS : public ThreadsafeFS {
llvm::StringMap<unsigned> &CountStats;

public:
// If relative paths are used, they are resolved with testPath().
llvm::StringMap<std::string> Files;

StatRecordingFS(llvm::StringMap<unsigned> &CountStats)
: CountStats(CountStats) {}

IntrusiveRefCntPtr<llvm::vfs::FileSystem>
view(llvm::NoneType) const override {
private:
IntrusiveRefCntPtr<llvm::vfs::FileSystem> viewImpl() const override {
class StatRecordingVFS : public llvm::vfs::ProxyFileSystem {
public:
StatRecordingVFS(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
Expand All @@ -954,10 +960,6 @@ TEST(ClangdTests, PreambleVFSStatCache) {
return IntrusiveRefCntPtr<StatRecordingVFS>(
new StatRecordingVFS(buildTestFS(Files), CountStats));
}

// If relative paths are used, they are resolved with testPath().
llvm::StringMap<std::string> Files;
llvm::StringMap<unsigned> &CountStats;
};

llvm::StringMap<unsigned> CountStats;
Expand Down
3 changes: 1 addition & 2 deletions clang-tools-extra/clangd/unittests/TestFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ buildTestFS(llvm::StringMap<std::string> const &Files,
// A VFS provider that returns TestFSes containing a provided set of files.
class MockFS : public ThreadsafeFS {
public:
IntrusiveRefCntPtr<llvm::vfs::FileSystem>
view(llvm::NoneType) const override {
IntrusiveRefCntPtr<llvm::vfs::FileSystem> viewImpl() const override {
return buildTestFS(Files, Timestamps);
}

Expand Down
1 change: 1 addition & 0 deletions clang/cmake/modules/ClangConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ find_package(LLVM REQUIRED CONFIG
set(CLANG_EXPORTED_TARGETS "@CLANG_EXPORTS@")
set(CLANG_CMAKE_DIR "@CLANG_CONFIG_CMAKE_DIR@")
set(CLANG_INCLUDE_DIRS "@CLANG_CONFIG_INCLUDE_DIRS@")
set(CLANG_LINK_CLANG_DYLIB "@CLANG_LINK_CLANG_DYLIB@")

# Provide all our library targets to users.
include("@CLANG_CONFIG_EXPORTS_FILE@")
Expand Down
16 changes: 10 additions & 6 deletions clang/lib/ASTMatchers/ASTMatchFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ static const unsigned MaxMemoizationEntries = 10000;

enum class MatchType {
Ancestors,
Descendants

Descendants,
Child,
};

// We use memoization to avoid running the same matcher on the same
Expand Down Expand Up @@ -452,8 +454,7 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>,
BoundNodesTreeBuilder *Builder, int MaxDepth,
TraversalKind Traversal, BindKind Bind) {
// For AST-nodes that don't have an identity, we can't memoize.
// When doing a single-level match, we don't need to memoize
if (!Node.getMemoizationData() || !Builder->isComparable() || MaxDepth == 1)
if (!Node.getMemoizationData() || !Builder->isComparable())
return matchesRecursively(Node, Matcher, Builder, MaxDepth, Traversal,
Bind);

Expand All @@ -463,7 +464,8 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>,
// Note that we key on the bindings *before* the match.
Key.BoundNodes = *Builder;
Key.Traversal = Ctx.getParentMapContext().getTraversalKind();
Key.Type = MatchType::Descendants;
// Memoize result even doing a single-level match, it might be expensive.
Key.Type = MaxDepth == 1 ? MatchType::Child : MatchType::Descendants;
MemoizationMap::iterator I = ResultCache.find(Key);
if (I != ResultCache.end()) {
*Builder = I->second.Nodes;
Expand Down Expand Up @@ -700,8 +702,10 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>,
BoundNodesTreeBuilder *Builder,
AncestorMatchMode MatchMode) {
// For AST-nodes that don't have an identity, we can't memoize.
// When doing a single-level match, we don't need to memoize
if (!Builder->isComparable() || MatchMode == AncestorMatchMode::AMM_ParentOnly)
// When doing a single-level match, we don't need to memoize because
// ParentMap (in ASTContext) already memoizes the result.
if (!Builder->isComparable() ||
MatchMode == AncestorMatchMode::AMM_ParentOnly)
return matchesAncestorOfRecursively(Node, Ctx, Matcher, Builder,
MatchMode);

Expand Down
11 changes: 8 additions & 3 deletions lldb/packages/Python/lldbsuite/test/lldbtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2481,9 +2481,7 @@ def expect_expr(
else:
eval_result = self.target().EvaluateExpression(expr, options)

if not eval_result.GetError().Success():
self.assertTrue(eval_result.GetError().Success(),
"Unexpected failure with msg: " + eval_result.GetError().GetCString())
self.assertSuccess(eval_result.GetError())

if result_type:
self.assertEqual(result_type, eval_result.GetDisplayTypeName())
Expand Down Expand Up @@ -2535,6 +2533,13 @@ def run_platform_command(self, cmd):
err = platform.Run(shell_command)
return (err, shell_command.GetStatus(), shell_command.GetOutput())

"""Assert that an lldb.SBError is in the "success" state."""
def assertSuccess(self, obj, msg=None):
if not obj.Success():
error = obj.GetCString()
self.fail(self._formatMessage(msg,
"'{}' is not success".format(error)))

# =================================================
# Misc. helper methods for debugging test execution
# =================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ def call_function(self):
'Stop here in main.', self.main_source_spec)

# Make sure the SIGCHLD behavior is pass/no-stop/no-notify:
return_obj = lldb.SBCommandReturnObject()
self.dbg.GetCommandInterpreter().HandleCommand(
"process handle SIGCHLD -s 0 -p 1 -n 0", return_obj)
self.assertTrue(return_obj.Succeeded(), "Set SIGCHLD to pass, no-stop")
self.runCmd("process handle SIGCHLD -s 0 -p 1 -n 0")

# The sigchld_no variable should be 0 at this point.
self.sigchld_no = target.FindFirstGlobalVariable("sigchld_no")
Expand Down Expand Up @@ -84,7 +81,7 @@ def call_function(self):
"call_me (%d)" %
(num_sigchld), options)
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertSuccess(value.GetError())
self.assertEquals(value.GetValueAsSigned(-1), num_sigchld)

self.check_after_call(num_sigchld)
Expand All @@ -101,23 +98,21 @@ def call_function(self):
"call_me (%d)" %
(num_sigchld), options)

self.assertTrue(value.IsValid() and value.GetError().Success())
self.assertTrue(value.IsValid())
self.assertSuccess(value.GetError())
self.assertEquals(value.GetValueAsSigned(-1), num_sigchld)
self.check_after_call(num_sigchld)

# Now set the signal to print but not stop and make sure that calling
# still works:
self.dbg.GetCommandInterpreter().HandleCommand(
"process handle SIGCHLD -s 0 -p 1 -n 1", return_obj)
self.assertTrue(
return_obj.Succeeded(),
"Set SIGCHLD to pass, no-stop, notify")
self.runCmd("process handle SIGCHLD -s 0 -p 1 -n 1")

value = frame.EvaluateExpression(
"call_me (%d)" %
(num_sigchld), options)

self.assertTrue(value.IsValid() and value.GetError().Success())
self.assertTrue(value.IsValid())
self.assertSuccess(value.GetError())
self.assertEquals(value.GetValueAsSigned(-1), num_sigchld)
self.check_after_call(num_sigchld)

Expand All @@ -128,36 +123,28 @@ def call_function(self):
"call_me (%d)" %
(num_sigchld), options)

self.assertTrue(value.IsValid() and value.GetError().Success())
self.assertTrue(value.IsValid())
self.assertSuccess(value.GetError())
self.assertEquals(value.GetValueAsSigned(-1), num_sigchld)
self.check_after_call(num_sigchld)

# Okay, now set UnwindOnError to true, and then make the signal behavior to stop
# and see that now we do stop at the signal point:

self.dbg.GetCommandInterpreter().HandleCommand(
"process handle SIGCHLD -s 1 -p 1 -n 1", return_obj)
self.assertTrue(
return_obj.Succeeded(),
"Set SIGCHLD to pass, stop, notify")
self.runCmd("process handle SIGCHLD -s 1 -p 1 -n 1")

value = frame.EvaluateExpression(
"call_me (%d)" %
(num_sigchld), options)
self.assertTrue(
value.IsValid() and value.GetError().Success() == False)
self.assertTrue(value.IsValid())
self.assertFalse(value.GetError().Success())

# Set signal handling back to no-stop, and continue and we should end
# up back in out starting frame:
self.dbg.GetCommandInterpreter().HandleCommand(
"process handle SIGCHLD -s 0 -p 1 -n 1", return_obj)
self.assertTrue(
return_obj.Succeeded(),
"Set SIGCHLD to pass, no-stop, notify")
self.runCmd("process handle SIGCHLD -s 0 -p 1 -n 1")

error = process.Continue()
self.assertTrue(
error.Success(),
self.assertSuccess(error,
"Continuing after stopping for signal succeeds.")

frame = self.thread.GetFrameAtIndex(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def call_function(self):
options.SetTrapExceptions(False)
value = frame.EvaluateExpression("[my_class iCatchMyself]", options)
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertSuccess(value.GetError())
self.assertEquals(value.GetValueAsUnsigned(), 57)
self.check_after_call()
options.SetTrapExceptions(True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ def test_context_object_objc(self):
# Test retrieving of an objcClass's property through the self pointer
value = obj_val.EvaluateExpression("self.property")
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertSuccess(value.GetError())
self.assertEqual(value.GetValueAsSigned(), 2222)

# Test objcClass's methods evaluation through the self pointer
value = obj_val.EvaluateExpression("[self method]")
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertSuccess(value.GetError())
self.assertEqual(value.GetValueAsSigned(), 3333)

# Test if we can use a computation result reference object correctly
Expand All @@ -63,12 +63,12 @@ def test_context_object_objc(self):
# Test an expression evaluation on it
value = obj_val.EvaluateExpression("1")
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertSuccess(value.GetError())

# Test retrieving of a field on it
value = obj_val.EvaluateExpression("field")
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertSuccess(value.GetError())
self.assertEqual(value.GetValueAsSigned(), 1111)

def setUp(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ def test_context_object(self):
# Test retrieveing of a field (not a local with the same name)
value = obj_val.EvaluateExpression("field")
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertSuccess(value.GetError())
self.assertEqual(value.GetValueAsSigned(), 1111)

# Test functions evaluation
value = obj_val.EvaluateExpression("function()")
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertSuccess(value.GetError())
self.assertEqual(value.GetValueAsSigned(), 2222)

# Test that we retrieve the right global
value = obj_val.EvaluateExpression("global.field")
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertSuccess(value.GetError())
self.assertEqual(value.GetValueAsSigned(), 1111)

#
Expand All @@ -57,7 +57,7 @@ def test_context_object(self):
# Test retrieveing of a field
value = obj_val.EvaluateExpression("field_int")
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertSuccess(value.GetError())
self.assertEqual(value.GetValueAsSigned(), 5555)

#
Expand Down Expand Up @@ -87,7 +87,7 @@ def test_context_object(self):
# Test retrieveing of an element's field
value = obj_val.GetValueForExpressionPath("[7]").EvaluateExpression("field")
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertSuccess(value.GetError())
self.assertEqual(value.GetValueAsSigned(), 1111)

#
Expand All @@ -105,7 +105,7 @@ def test_context_object(self):
# Test retrieveing of a dereferenced object's field
value = obj_val.Dereference().EvaluateExpression("field")
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertSuccess(value.GetError())
self.assertEqual(value.GetValueAsSigned(), 1111)

#
Expand Down Expand Up @@ -135,7 +135,7 @@ def test_context_object(self):
# Test retrieveing of a dereferenced object's field
value = obj_val.Dereference().EvaluateExpression("field")
self.assertTrue(value.IsValid())
self.assertTrue(value.GetError().Success())
self.assertSuccess(value.GetError())
self.assertEqual(value.GetValueAsSigned(), 1111)

def setUp(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def expr_options_test(self):

# Now use the options:
result = frame.EvaluateExpression("call_me(10)", options)
self.assertTrue(result.GetError().Success(), "expression succeeded")
self.assertSuccess(result.GetError())
self.assertEqual(result.GetValueAsSigned(), 18, "got the right value.")

# Now disallow JIT and make sure it fails:
Expand All @@ -77,6 +77,6 @@ def expr_options_test(self):

# And again, make sure this works:
result = frame.EvaluateExpression("call_me(10)", options)
self.assertTrue(result.GetError().Success(), "expression succeeded")
self.assertSuccess(result.GetError())
self.assertEqual(result.GetValueAsSigned(), 18, "got the right value.")

Loading

0 comments on commit a1a3a9d

Please sign in to comment.