================
@@ -422,27 +423,49 @@ class LifetimeSafetySemaHelperImpl : public
LifetimeSafetySemaHelper {
}
private:
- std::pair<SourceLocation, StringRef>
+ std::string getLifetimeBoundFixItText(SourceLocation Loc, bool LeadingSpace,
+ bool AllowGNUAttrMacro = true) {
+ StringRef Spelling = S.getLangOpts().LifetimeSafetyLifetimeBoundMacro;
+ if (Spelling.empty() && Loc.isValid()) {
+ const Preprocessor &PP = S.getPreprocessor();
+ Spelling = PP.getLastMacroWithSpelling(
+ Loc, {tok::l_square, tok::l_square, PP.getIdentifierInfo("clang"),
+ tok::coloncolon, PP.getIdentifierInfo("lifetimebound"),
+ tok::r_square, tok::r_square});
+
+ if (Spelling.empty() && AllowGNUAttrMacro)
+ Spelling = PP.getLastMacroWithSpelling(
+ Loc, {tok::kw___attribute, tok::l_paren, tok::l_paren,
+ PP.getIdentifierInfo("lifetimebound"), tok::r_paren,
+ tok::r_paren});
+ }
+ const std::string Text =
+ Spelling.empty() ? "[[clang::lifetimebound]]" : Spelling.str();
----------------
zeyi2 wrote:
I currently choose this way:
If `LangOpts` is C, use `__attribute((lifetimebound))` as the default fallback
and stop searching for `[[clang::lifetimebound]]` macro. IMO by doing so we
could make sure that C mode always gets a valid fixit.
If `LangOpts` is C++, use `[[clang::lifetimebound]]` as default fallback and
search for both `[[clang::lifetimebound]]` and `__attribute((lifetimebound))`
macros (though lower priority than `[[clang::lifetimebound]]`).
https://github.com/llvm/llvm-project/pull/204045
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits