Go to file
Manman Ren 073db02476 Add TreatUnavailableAsInvalid for the verification-only mode in InitListChecker.
Given the following test case:
typedef struct {
  const char *name;
  id field;
} Test9;
extern void doSomething(Test9 arg);
void test9() {
  Test9 foo2 = {0, 0};
  doSomething(foo2);
}
With a release compiler, we don't emit any message and silently ignore the
variable "foo2". With an assert compiler, we get an assertion failure.

The root cause —————————————
Back in r140457 we gave InitListChecker a verification-only mode, and will use
CanUseDecl instead of DiagnoseUseOfDecl for verification-only mode.

These two functions handle unavailable issues differently:
In Sema::CanUseDecl, we say the decl is invalid when the Decl is unavailable and
the current context is available.

In Sema::DiagnoseUseOfDecl, we say the decl is usable by ignoring the return
code of DiagnoseAvailabilityOfDecl

So with an assert build, we will hit an assertion in diagnoseListInit
assert(DiagnoseInitList.HadError() &&
       "Inconsistent init list check result.");

The fix -------------------
If we follow what is implemented in CanUseDecl and treat Decls with
unavailable issues as invalid, the variable decl of “foo2” will be marked as
invalid. Since unavailable checking is processed in delayed diagnostics
(r197627), we will silently ignore the diagnostics when we find out that
the variable decl is invalid.

We add a flag "TreatUnavailableAsInvalid" for the verification-only mode.
For overload resolution, we want to say decls with unavailable issues are
invalid; but for everything else, we should say they are valid and
emit diagnostics. Depending on the value of the flag, CanUseDecl
can return different values for unavailable issues.

rdar://23557300
Differential Revision: http://reviews.llvm.org/D15314

llvm-svn: 263149
2016-03-10 18:53:19 +00:00
clang Add TreatUnavailableAsInvalid for the verification-only mode in InitListChecker. 2016-03-10 18:53:19 +00:00
clang-tools-extra [docs] Clean up doxygen comments a bit. 2016-03-06 04:05:59 +00:00
compiler-rt [sanitizer_common tests] Make Darwin a Posix system and bring the stable-runtime definition from ASan tests. 2016-03-10 18:46:23 +00:00
debuginfo-tests New round of fixes for "Always compile debuginfo-tests for the host triple" 2014-10-18 23:47:59 +00:00
libclc math: Fix ilogb(double) return type 2016-02-24 00:52:15 +00:00
libcxx Update status to mark 2579 complete 2016-03-09 18:09:07 +00:00
libcxxabi Reducing stack usage of test 2016-03-04 14:25:13 +00:00
libunwind [AArch64] Fix libunwind build when using GNU assembler 2016-02-11 21:22:57 +00:00
lld [ELF] - Refactor of SymbolBody::compare() 2016-03-10 18:49:24 +00:00
lldb [Renderscript] Add stack argument reading code for Mipsel 3 2016-03-10 17:50:01 +00:00
llgo [llgo] Force exporting __morestack from llgoi 2015-11-27 04:46:46 +00:00
llvm [TableGen] more helpful error message in MapTableEmitter 2016-03-10 18:51:58 +00:00
openmp [STATS] fix output formatting when sample count is 0 2016-03-03 21:24:13 +00:00
polly Also clang-format *.c run-time library files 2016-03-08 07:34:58 +00:00