forked from swiftlang/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request swiftlang#9294 from augusto2112/test-clang-importe…
…r-align [lldb] Add test with custom alignment on a clang type
- Loading branch information
Showing
5 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
lldb/test/API/lang/swift/clangimporter/custom_alignment/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SWIFT_SOURCES := main.swift | ||
SWIFTFLAGS_EXTRAS = -I$(SRCDIR) | ||
|
||
include Makefile.rules |
47 changes: 47 additions & 0 deletions
47
...st/API/lang/swift/clangimporter/custom_alignment/TestSwiftClangImporterCustomAlignment.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# TestSwiftClangImporterCustomAlignment.py | ||
# | ||
# This source file is part of the Swift.org open source project | ||
# | ||
# Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors | ||
# Licensed under Apache License v2.0 with Runtime Library Exception | ||
# | ||
# See https://swift.org/LICENSE.txt for license information | ||
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
# | ||
# ------------------------------------------------------------------------------ | ||
import lldb | ||
from lldbsuite.test.decorators import * | ||
import lldbsuite.test.lldbtest as lldbtest | ||
import lldbsuite.test.lldbutil as lldbutil | ||
import os | ||
|
||
|
||
class TestSwiftClangImporterCustomAlignment(lldbtest.TestBase): | ||
|
||
mydir = lldbtest.TestBase.compute_mydir(__file__) | ||
|
||
@swiftTest | ||
@skipIf(setting=('symbols.use-swift-clangimporter', 'false')) | ||
def test(self): | ||
self.build() | ||
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( | ||
self, "break here", lldb.SBFileSpec("main.swift") | ||
) | ||
frame = thread.frames[0] | ||
v = frame.FindVariable("v") | ||
s = v.GetChildMemberWithName("s") | ||
|
||
field_1 = s.GetChildMemberWithName("field_64_1") | ||
lldbutil.check_variable(self, field_1, False, value="100") | ||
|
||
field_2 = s.GetChildMemberWithName("field_32_1") | ||
lldbutil.check_variable(self, field_2, False, value="200") | ||
|
||
field_3 = s.GetChildMemberWithName("field_32_2") | ||
lldbutil.check_variable(self, field_3, False, value="300") | ||
|
||
field_4 = s.GetChildMemberWithName("field_64_2") | ||
lldbutil.check_variable(self, field_4, False, value="400") | ||
|
||
x = v.GetChildMemberWithName("x") | ||
lldbutil.check_variable(self, x, False, value="1") |
14 changes: 14 additions & 0 deletions
14
lldb/test/API/lang/swift/clangimporter/custom_alignment/header.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "stdlib.h" | ||
#include <stdint.h> | ||
|
||
#pragma pack(push, 4) | ||
|
||
struct Struct { | ||
int64_t field_64_1; | ||
int32_t field_32_1; | ||
uint32_t field_32_2; | ||
int64_t field_64_2; | ||
}; | ||
|
||
#pragma pack(pop) | ||
|
17 changes: 17 additions & 0 deletions
17
lldb/test/API/lang/swift/clangimporter/custom_alignment/main.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Module | ||
|
||
struct Value { | ||
var x: Int32 = 1 | ||
var s = Struct() | ||
} | ||
|
||
func f() { | ||
var v = Value() | ||
v.s.field_64_1 = 100; | ||
v.s.field_32_1 = 200; | ||
v.s.field_32_2 = 300; | ||
v.s.field_64_2 = 400; | ||
print(v) // break here | ||
} | ||
|
||
f() |
4 changes: 4 additions & 0 deletions
4
lldb/test/API/lang/swift/clangimporter/custom_alignment/module.modulemap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Module { | ||
header "header.h" | ||
export * | ||
} |