Ericsson / clang

Cross Translation Unit analysis capability for Clang Static Analyzer. (Fork of official clang at http://llvm.org/git/clang)
http://clang.llvm.org/
Other
15 stars 10 forks source link

Odr warning overhaul #618

Closed gamesh411 closed 5 years ago

gamesh411 commented 5 years ago

Make ODR violations warnings when using ASTImporter, but leave them errors when using Sema. Please have a look at it before I send the patch to Phabricator.

balazske commented 5 years ago

The ASTImporter generates now only warnings for ODR mismatch, the structural equivalence may generate error or warning. My observation is only that there are warning-error pairs and code in getApplicableDiagnostic for every existing error type but many of these are not used in ASTStructuralEquivalence. These are used in ASTImporter but only with warning (many of the obj-c related things). It looks better to have uniform handling for every type (the current code) but now there are unused error codes. Probably later these should be used if the structural equivalence code is improved to handle the obj-c cases that currently produce warning in ASTImporter.

gamesh411 commented 5 years ago

I agree. There are some diagnostics which we don't use currently, however we might later. I would like the code to work this way: if the ErrorOnTagTypeMismatch flag is set, then automatically get the error for a bug category (err_odr_tag_type_inconsistent in case the detected fault is due to inconsistent tag types), otherwise the warning (warn_odr_tag_type_inconsistent). I think associating errors with their corresponding warnings is what is missing from the diagnostic library, as they are now modeled as unrelated diagnostics.