forked from OSchip/llvm-project
0e2b975eb6
We were crashing in CodeGen given input like this: int self_alias(void) __attribute__((weak, alias("self_alias"))); such a self-alias is invalid, but instead of diagnosing the situation, we'd proceed to produce IR for both the function declaration and the alias. Because we already had a function named 'self_alias', the alias could not be named the same thing, and so LLVM would pick a different name ('self_alias1' for example) for that value. When we later called CodeGenModule::checkAliases, we'd look up the IR value corresponding to the alias name, find the function declaration instead, and then assert in a cast to llvm::GlobalAlias. The easiest way to prevent this is simply to avoid creating the wrongly-named alias value in the first place and issue the diagnostic there (instead of in checkAliases). We detect a related cycle case in CodeGenModule::EmitAliasDefinition already, so this just adds a second such check. Even though the other test cases for this 'alias definition is part of a cycle' diagnostic are in test/Sema/attr-alias-elf.c, I've added a separate regression test for this case. This is because I can't add this check to test/Sema/attr-alias-elf.c without disturbing the other test cases in that file. In order to avoid construction of the bad IR values, this diagnostic is emitted from within CodeGenModule::EmitAliasDefinition (and the relevant declaration is not added to the Aliases vector). The other cycle checks are done within the CodeGenModule::checkAliases function based on the Aliases vector, called from CodeGenModule::Release. However, if there have been errors earlier, HandleTranslationUnit does not call Release, and so checkAliases is never called, and so none of the other diagnostics would be produced. Fixes PR23509. llvm-svn: 246882 |
||
---|---|---|
.. | ||
ARCMT | ||
ASTMerge | ||
Analysis | ||
CXX | ||
CodeCompletion | ||
CodeGen | ||
CodeGenCUDA | ||
CodeGenCXX | ||
CodeGenObjC | ||
CodeGenObjCXX | ||
CodeGenOpenCL | ||
Coverage | ||
CoverageMapping | ||
Driver | ||
FixIt | ||
Format | ||
Frontend | ||
Headers | ||
Index | ||
Integration | ||
Layout | ||
Lexer | ||
Misc | ||
Modules | ||
OpenMP | ||
PCH | ||
Parser | ||
Preprocessor | ||
Profile | ||
Rewriter | ||
Sema | ||
SemaCUDA | ||
SemaCXX | ||
SemaObjC | ||
SemaObjCXX | ||
SemaOpenCL | ||
SemaTemplate | ||
TableGen | ||
Tooling | ||
Unit | ||
VFS | ||
.clang-format | ||
CMakeLists.txt | ||
Makefile | ||
TestRunner.sh | ||
cxx-sections.data | ||
lit.cfg | ||
lit.site.cfg.in | ||
make_test_dirs.pl |