Skip to content

[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

Conversation

kastiglione
Copy link

@kastiglione kastiglione commented May 2, 2024

Introduce the target.swift-clang-override-options setting, which provides the debugger the same functionality as CCC_OVERRIDE_OPTIONS. This is useful as an additional means to workaround issues that can arise with ClangImporter options. This is more powerful than the existing target.swift-extra-clang-flags setting, which only allows flags to be added, not deleted or rewritten.

Depends on llvm#85425

@kastiglione kastiglione requested a review from adrian-prantl May 2, 2024 19:59
@kastiglione
Copy link
Author

@swift-ci test

// the first argument.
raw_args.push_back("clang");
for (const std::string &arg : args)
raw_args.push_back(arg.data());

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>?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the type of args is std::vector<std::string>.

If you are referring to raw_args and its type llvm::SmallVector<const char *, 64>, note that it's used because that's the signature of clang::driver::applyOverrideOptions.

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()?

Copy link
Author

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:

The returned array is null-terminated, that is, data() and c_str() perform the same function. (since C++11)

https://en.cppreference.com/w/cpp/string/basic_string/data

Copy link

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conceptually very useful, couple of nits inside.

@kastiglione
Copy link
Author

@swift-ci test

@kastiglione
Copy link
Author

@swift-ci test

@adrian-prantl adrian-prantl self-requested a review May 4, 2024 23:19
@adrian-prantl adrian-prantl merged commit b8ce84d into swift/release/6.0 May 4, 2024
3 checks passed
@kastiglione kastiglione deleted the dl/lldb-Add-setting-to-override-ClangImporter-driver-options branch May 7, 2024 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants