Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Standalone View
clang/include/clang/Basic/DiagnosticSemaKinds.td
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 7,003 Lines • ▼ Show 20 Lines | |||||
def err_typecheck_three_way_comparison_of_pointer_and_zero : Error< | def err_typecheck_three_way_comparison_of_pointer_and_zero : Error< | ||||
"three-way comparison between pointer and zero">; | "three-way comparison between pointer and zero">; | ||||
def ext_typecheck_compare_complete_incomplete_pointers : Extension< | def ext_typecheck_compare_complete_incomplete_pointers : Extension< | ||||
"pointer comparisons before C11 " | "pointer comparisons before C11 " | ||||
"need to be between two complete or two incomplete types; " | "need to be between two complete or two incomplete types; " | ||||
"%0 is %select{|in}2complete and " | "%0 is %select{|in}2complete and " | ||||
"%1 is %select{|in}3complete">, | "%1 is %select{|in}3complete">, | ||||
InGroup<C11>; | InGroup<C11>; | ||||
def warn_typecheck_comparison_of_function_pointers : Warning< | |||||
"distinct function pointers (%0 and %1) may compare equal " | |||||
cjdb: This diagnostic feels very bare bones, and doesn't explain why the user should care. It would… | |||||
Not Done ReplyInline ActionsAgreed -- diagnostic wording is usually trying to tell the user what they did wrong to guide them how to fix it, but this reads more like the diagnostic explains what the code does. This one will be especially interesting because people would naturally expect that comparison to work per the standard. And if enabling ICF breaks that then ICF is non-conforming because it makes valid code silently invalid. I think this is an ICF bug (it may still be worth warning users about though because you can use newer Clang with an older lld and hit the issue even if lld addresses this issue). CC @lhames @sbc100 @ruiu in to try to scare up an lld code owner to see if this is known and if there's something that can be done on the lld side to not break valid code. aaron.ballman: Agreed -- diagnostic wording is usually trying to tell the user what they did wrong to guide… | |||||
There's already an ICF option that doesn't break valid code: -icf=safe. Only if you explicitly decide that you don't care about the results of function pointer comparisons would you use -icf=all, which enables more code folding to be done than the safe option. adriandole: There's already an ICF option that doesn't break valid code: `-icf=safe`. Only if you… | |||||
Not Done ReplyInline ActionsOhhh interesting, so it's probably known that -icf=all will break code because it's not conforming and thus isn't an lld bug at all. Do (most?) other linkers also have the same functionality as -icf=all? I'm trying to understand whether this should be added to clang at all as it seems like it's a warning for a very particular usage pattern (a specific linker with a specific option ), which make it more reasonable for clang-tidy instead of the compiler. aaron.ballman: Ohhh interesting, so it's probably known that `-icf=all` will break code because it's not… | |||||
ld.gold and mold have it (same name, -icf=all) as does MSVC (/OPT:ICF). adriandole: ld.gold and mold have it (same name, `-icf=all`) as does MSVC (`/OPT:ICF`). | |||||
Not Done ReplyInline ActionsThanks for the details, that makes this seem more reasonable in Clang itself IMO. aaron.ballman: Thanks for the details, that makes this seem more reasonable in Clang itself IMO. | |||||
"when using identical code folding">, | |||||
Not Done ReplyInline ActionsIt's very rare that we set a warning to DefaultIgnore. What's the motivation for this? cjdb: It's very rare that we set a warning to `DefaultIgnore`. What's the motivation for this? | |||||
Not Done ReplyInline Actions
I see why now. Perhaps this warning should be enabled by default when ICF is also enabled, and an error otherwise. cjdb: > This warning is disabled by default, since it's only relevant if ICF is explicitly enabled. | |||||
Not Done ReplyInline ActionsThe problem is: ICF is an lld thing, it's not a Clang thing; so Clang has no idea if ICF will or won't be enabled. aaron.ballman: The problem is: ICF is an lld thing, it's not a Clang thing; so Clang has no idea if ICF will… | |||||
Not Done ReplyInline ActionsOkay, that sounds like we can't make it an error to turn this warning on when ICF isn't enabled, but what about turning it on when the driver sees -icf=all? Or does that bypass clang_cc1 altogether? cjdb: Okay, that sounds like we can't make it an error to turn this warning on when ICF isn't enabled… | |||||
Not Done ReplyInline ActionsThe diagnostic serves no purpose unless the user is linking with -icf=all, so agreed we can't enable this by default. We might be able to do something by looking at linker flags passed through clang on to the driver, but it's not going to be perfect (users can link manually without invoking through the compiler, and I'm not certain what IDEs do when driving builds with Clang). aaron.ballman: The diagnostic serves no purpose unless the user is linking with `-icf=all`, so agreed we can't… | |||||
Not Done ReplyInline Actions@MaskRay -- do you think we should try to enable this diagnostic by default by looking at driver flags that will be passed to the linker, or does it seem more reasonable to you to have this ignored by default? aaron.ballman: @MaskRay -- do you think we should try to enable this diagnostic by default by looking at… | |||||
Not Done ReplyInline ActionsI think it should remain ignored by default. Link actions happen separate at a late stage and we generally don't want linker options to affect compiles. (e.g. We haven't allowed -fuse-ld= to affect compiles). MaskRay: I think it should remain ignored by default.
Link actions happen separate at a late stage and… | |||||
InGroup<CompareFunctionPointers>, DefaultIgnore; | |||||
def warn_typecheck_ordered_comparison_of_function_pointers : Warning< | def warn_typecheck_ordered_comparison_of_function_pointers : Warning< | ||||
"ordered comparison of function pointers (%0 and %1)">, | "ordered comparison of function pointers (%0 and %1)">, | ||||
InGroup<OrderedCompareFunctionPointers>; | InGroup<OrderedCompareFunctionPointers>; | ||||
def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn< | def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn< | ||||
"ordered comparison of function pointers (%0 and %1)">, | "ordered comparison of function pointers (%0 and %1)">, | ||||
InGroup<OrderedCompareFunctionPointers>; | InGroup<OrderedCompareFunctionPointers>; | ||||
def err_typecheck_ordered_comparison_of_function_pointers : Error< | def err_typecheck_ordered_comparison_of_function_pointers : Error< | ||||
"ordered comparison of function pointers (%0 and %1)">; | "ordered comparison of function pointers (%0 and %1)">; | ||||
▲ Show 20 Lines • Show All 4,763 Lines • Show Last 20 Lines |
This diagnostic feels very bare bones, and doesn't explain why the user should care. It would be good to rephrase the message so that it can incorporate some kind of reason too.