forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 341
[lldb] Add setting to override ClangImporter driver options #8682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
adrian-prantl
merged 5 commits into
swift/release/6.0
from
dl/lldb-Add-setting-to-override-ClangImporter-driver-options
May 4, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2d7060f
[lldb] Add setting to override ClangImporter driver options
kastiglione e956438
Use types log; Fix headerdoc comment style
kastiglione 41d1faa
Use @skipUnlessFoundation decorator
kastiglione 7a19064
Improve comment
kastiglione b9a9711
Update the test to use the types log
kastiglione File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
4 changes: 4 additions & 0 deletions
4
lldb/test/API/lang/swift/clangimporter/override_options/Makefile
This file contains hidden or 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 = -Xcc -DDELETEME=1 | ||
|
||
include Makefile.rules |
23 changes: 23 additions & 0 deletions
23
lldb/test/API/lang/swift/clangimporter/override_options/TestSwiftClangOverrideOptions.py
This file contains hidden or 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,23 @@ | ||
import lldb | ||
from lldbsuite.test.decorators import * | ||
import lldbsuite.test.lldbtest as lldbtest | ||
import lldbsuite.test.lldbutil as lldbutil | ||
|
||
|
||
class TestCase(lldbtest.TestBase): | ||
@swiftTest | ||
@skipUnlessFoundation | ||
def test(self): | ||
"""Check that ClangImporter options can be overridden.""" | ||
self.build() | ||
|
||
log = self.getBuildArtifact("lldb.log") | ||
self.runCmd(f"log enable lldb types -f '{log}'") | ||
self.runCmd("settings set target.swift-clang-override-options x-DDELETEME=1") | ||
|
||
lldbutil.run_to_name_breakpoint(self, "main", bkpt_module="a.out") | ||
self.expect("expression 1") | ||
|
||
self.filecheck(f"platform shell cat {log}", __file__) | ||
# CHECK: CCC_OVERRIDE_OPTIONS: x-DDELETEME=1 | ||
# CHECK: Deleting argument -DDELETEME=1 |
3 changes: 3 additions & 0 deletions
3
lldb/test/API/lang/swift/clangimporter/override_options/main.swift
This file contains hidden or 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,3 @@ | ||
import Foundation | ||
|
||
// empty main |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this very scary because we don't know if args contents is nullterminated and it's easy to break this contract in the future.
Could we just make this a
std::vector<std::string>
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the type of
args
isstd::vector<std::string>
.If you are referring to
raw_args
and its typellvm::SmallVector<const char *, 64>
, note that it's used because that's the signature ofclang::driver::applyOverrideOptions
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see!
Is the null-terminator guaranteed, or should this be
arg.c_str()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's guaranteed to be null terminated:
https://en.cppreference.com/w/cpp/string/basic_string/data