llvm-project/clang/test
Hal Finkel 0e2b975eb6 Don't crash on a self-alias declaration
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
2015-09-04 21:49:21 +00:00
..
ARCMT Revert "Revert r241620 and follow-up commits" and move the initialization 2015-07-08 01:00:30 +00:00
ASTMerge PR10405 - Desugar FunctionType and TemplateSpecializationType if any type that appears inside needs to be desugared. 2015-07-16 01:06:17 +00:00
Analysis [Static Analyzer] Remove sinks from nullability checks. 2015-09-03 23:16:21 +00:00
CXX PR24612: Don't bail out of checking a constexpr function before checking 2015-08-28 22:33:53 +00:00
CodeCompletion [Tests] Modified Lit Tests to be C++11 compatibile 2015-08-27 18:49:15 +00:00
CodeGen Increase accuracy of __builtin_object_size. 2015-09-04 21:28:13 +00:00
CodeGenCUDA [CUDA] Change initializer for CUDA device code based on CUDA documentation. 2015-08-22 05:49:28 +00:00
CodeGenCXX Don't use unreachable as a placeholder, it confuses EmitBlock 2015-09-04 21:39:15 +00:00
CodeGenObjC Fix CHECK directives that weren't checking. 2015-08-31 21:48:52 +00:00
CodeGenObjCXX When building a pseudo-object assignment, and the RHS is 2015-08-22 00:35:27 +00:00
CodeGenOpenCL Fix invalid shufflevector operands 2015-08-02 15:28:10 +00:00
Coverage
CoverageMapping InstrProf: Fix a misuse of the FunctionDecl API when generating coverage 2015-07-28 00:41:51 +00:00
Driver Put ext_implicit_lib_function_decl in ImplicitFunctionDeclare. 2015-09-04 16:07:39 +00:00
FixIt Replace __double_underscored type nullability qualifiers with _Uppercase_underscored 2015-06-24 22:02:08 +00:00
Format Disable style-on-command-line test on Windows 2015-06-09 17:47:59 +00:00
Frontend Do not include default sanitizer blacklists into -M/-MM/-MD/-MMD output. 2015-09-02 20:02:38 +00:00
Headers Revert "Revert r241620 and follow-up commits" and move the initialization 2015-07-08 01:00:30 +00:00
Index [libclang] Return deduced type for auto type, not the one written in the source. 2015-09-03 16:11:10 +00:00
Integration
Layout Fix the layout of bitfields in ms_struct unions: their 2015-08-19 22:42:36 +00:00
Lexer Turn off __has_feature(cxx_rtti) when -fno-rtti-data is present 2015-08-13 17:56:49 +00:00
Misc Put ext_implicit_lib_function_decl in ImplicitFunctionDeclare. 2015-09-04 16:07:39 +00:00
Modules [modules] Tighten up this test a bit. 2015-09-02 20:16:09 +00:00
OpenMP [OPENMP] Fix false diagnostic on instantiation-dependent exprs for atomic constructs. 2015-09-04 12:55:50 +00:00
PCH Fix crash on invalid if we can't find a suitable PCH file in a specified 2015-09-04 21:44:32 +00:00
Parser Windows ARM: ignore calling conventions as described on MSDN 2015-08-14 18:00:09 +00:00
Preprocessor [WebAssembly] Initial WebAssembly support in clang 2015-09-03 22:51:53 +00:00
Profile Tweak a couple of -fprofile tests in clang/test to accept backslash in path. 2015-07-10 13:11:08 +00:00
Rewriter __declspec is not a core Clang language extension. Instead, require -fms-extensions or -fborland to enable the language extension. 2015-05-26 19:44:52 +00:00
Sema Don't crash on a self-alias declaration 2015-09-04 21:49:21 +00:00
SemaCUDA [CUDA] Check register names on appropriate side of cuda compilation only. 2015-08-27 19:54:21 +00:00
SemaCXX Don't allow dllexport/import on static local variables 2015-09-04 19:59:39 +00:00
SemaObjC [SemaObjC] Remove unused code from test. 2015-08-21 20:28:16 +00:00
SemaObjCXX Add a new frontend warning for referencing members from the handler of a constructor or destructor function-try-block, which is UB in C++. 2015-09-01 14:49:24 +00:00
SemaOpenCL [OpenCL] Improve diagnostics detecting implicit vector conversion. 2015-08-30 18:06:39 +00:00
SemaTemplate Fix assertion failure in TransformOpaqueValueExpr 2015-09-01 22:50:31 +00:00
TableGen
Tooling Change the expectation for test/Tooling/ms-asm-no-target.cpp since 2015-07-08 01:39:38 +00:00
Unit
VFS Commit some test changes somehow missed in r239789. 2015-06-16 00:19:29 +00:00
.clang-format
CMakeLists.txt Revert "Revert r241620 and follow-up commits" and move the initialization 2015-07-08 01:00:30 +00:00
Makefile
TestRunner.sh
cxx-sections.data
lit.cfg Enable clang tests requiring "clang-driver" on mingw. 2015-07-25 20:05:21 +00:00
lit.site.cfg.in
make_test_dirs.pl