Description
Bugzilla Link | 26752 |
Version | unspecified |
OS | All |
Reporter | LLVM Bugzilla Contributor |
Extended Description
C++/CLI and C++/CX by Microsoft is C++ with a few extension to allow interacting with the .NET runtime:
clang-format works on such source files without any problem except for handling the "hat notation" which is used to indicate managed objects.
- Foo&: usual C++ reference
- Foo*: usual C++ pointer
- Foo^: Managed object (C++/CLI and C++/CX only)
As in:
Foo^ foo = ref new Foo();
Since clang-format doesn't know about this special syntax, it "incorrectly" reformats:
String^ StringToPlatformString(const std::string& in) {
return gcnew String(StringToWString(in).c_str());
}
std::string PlatformStringToString(String^ in) {
pin_ptr ptr = PtrToStringChars(in); // Must pin the pointer to avoid GC while in unmanaged code
return WStringToString(ptr);
}
as
String ^ StringToPlatformString(const std::string& in) {
return gcnew String(StringToWString(in).c_str());
}
std::string PlatformStringToString(String ^ in) {
pin_ptr ptr = PtrToStringChars(in); // Must pin the pointer to avoid GC while in unmanaged code
return WStringToString(ptr);
}