llvm-project/clang/test
Joel E. Denny 7509a2f5cc [AST] Print correct tag decl for tag specifier
For example, given:

  void fn() {
    struct T *p0;
    struct T { int i; } *p1;
  }

-ast-print produced:

  void fn() {
    struct T { int i; } *p0;
    struct T { int i; } *p1;
  }

Compiling that fails with a redefinition error.

Given:

  void fn() {
    struct T *p0;
    struct __attribute__((deprecated)) T *p1;
  }

-ast-print dropped the attribute.

Details:

For a tag specifier (that is, struct/union/class/enum used as a type
specifier in a declaration) that was also a tag declaration (that is,
first occurrence of the tag) or tag redeclaration (that is, later
occurrence that specifies attributes or a member list), clang printed
the tag specifier as either (1) the full tag definition if one
existed, or (2) the first tag declaration otherwise.  Redefinition
errors were sometimes introduced, as in the first example above.  Even
when that was impossible because no member list was ever specified,
attributes were sometimes lost, thus changing semantics and
diagnostics, as in the second example above.

This patch fixes a major culprit for these problems.  It does so by
creating an ElaboratedType with a new OwnedDecl member wherever an
occurrence of a tag type is a (re)declaration of that tag type.
PrintingPolicy's IncludeTagDefinition used to trigger printing of the
member list, attributes, etc. for a tag specifier by using a tag
(re)declaration selected as described above.  Now, it triggers the
same thing except it uses the tag (re)declaration stored in the
OwnedDecl.  Of course, other tooling can now make use of the new
OwnedDecl as well.

Also, to be more faithful to the original source, this patch
suppresses printing of attributes inherited from previous
declarations.

Reviewed by: rsmith, aaron.ballman

Differential Revision: https://reviews.llvm.org/D45463

llvm-svn: 332281
2018-05-14 19:36:45 +00:00
..
ARCMT [ObjC] Allow declaring __strong pointer fields in structs in Objective-C 2018-02-28 07:15:55 +00:00
ASTMerge [ASTImporter] FriendDecl importing improvements 2018-04-25 17:28:03 +00:00
Analysis [analyzer] Ignore the nullability quantifiers for autoreleasewritechecker 2018-05-11 20:39:19 +00:00
CXX Improve diagnostics and error recovery for template name lookup. 2018-05-11 02:43:08 +00:00
CodeCompletion [CodeComplete] Provide completion in decls even for incomplete types 2018-05-14 13:50:36 +00:00
CodeGen [X86] Use __builtin_convertvector to replace some of the avx512 truncate builtins. 2018-05-14 17:50:40 +00:00
CodeGenCUDA Fix failure in lit test kernel-call.cu due to name mangling 2018-04-25 13:07:58 +00:00
CodeGenCXX CodeGen: Emit string literal in constant address space 2018-05-14 19:20:12 +00:00
CodeGenCoroutines [Coroutines] Catch exceptions in await_resume 2018-05-04 14:02:37 +00:00
CodeGenObjC [CodeGen] Fix a crash that occurs when a non-trivial C struct with a 2018-04-16 20:23:52 +00:00
CodeGenObjCXX [CodeGen] Avoid destructing a callee-destructued struct type in a 2018-04-27 06:57:00 +00:00
CodeGenOpenCL [OpenCL] Fix typos in emitted enqueue kernel function names 2018-05-09 17:07:06 +00:00
Coverage [analyzer] Fix filename in cross-file HTML report 2018-05-02 14:26:12 +00:00
CoverageMapping [Coverage] Handle break/continue outside of loop bodies 2018-02-16 07:59:43 +00:00
Driver Redirect output to /dev/null in the tests added in r332160. 2018-05-14 12:07:56 +00:00
FixIt [Parser][FixIt] Better diagnostics for "typedef" instead of "typename" typo 2018-02-08 14:37:58 +00:00
Format [clang-format] Fix bug where -dump-config failed on ObjC header 2018-01-29 17:36:43 +00:00
Frontend Move test input file into same directory as test. NFC 2018-05-08 00:29:21 +00:00
Headers [x86] Introduce the encl[u|s|v] intrinsics 2018-05-08 07:12:34 +00:00
Import [ASTImporter] Properly import SourceLocations of Attrs 2018-05-08 12:45:21 +00:00
Index [libclang] Stop assuming that the internal C++ ABI ExceptionSpecificationType enumeration is the same as CXCursor_ExceptionSpecificationKind. 2018-05-11 19:46:31 +00:00
Integration
Layout Non-zero-length bit-fields make a class non-empty. 2018-05-07 06:43:30 +00:00
Lexer Implement P0482R2, support for char8_t type. 2018-05-01 05:02:45 +00:00
Misc [AST] Print correct tag decl for tag specifier 2018-05-14 19:36:45 +00:00
Modules Track the result of evaluating a computed noexcept specification on the 2018-05-03 03:58:32 +00:00
OpenMP [OPENMP, NVPTX] Do not use SPMD mode for target simd and target teams 2018-05-11 19:45:14 +00:00
PCH [C++2a] Implement operator<=> CodeGen and ExprConstant 2018-05-07 21:07:10 +00:00
Parser [OpenCL] Restrict various keywords in OpenCL C++ mode 2018-05-09 13:16:17 +00:00
Preprocessor [X86] ptwrite intrinsic 2018-05-10 07:28:54 +00:00
Profile [PGO] Detect more structural changes with the stable hash 2017-11-14 23:56:53 +00:00
Refactor [refactor][extract] avoid extracting expressions from types in functions 2017-11-14 18:59:01 +00:00
Rewriter
Sema Added atomic_fetch_min, max, umin, umax intrinsics to clang. 2018-05-13 07:45:58 +00:00
SemaCUDA Fix typos in clang 2018-04-06 15:14:32 +00:00
SemaCXX Improve diagnostics and error recovery for template name lookup. 2018-05-11 02:43:08 +00:00
SemaObjC [ObjC] Supress the 'implementing unavailable method' warning when 2018-05-03 01:12:06 +00:00
SemaObjCXX Improve diagnostics and error recovery for template name lookup. 2018-05-11 02:43:08 +00:00
SemaOpenCL [OpenCL] Add constant address space to __func__ in AST. 2018-05-09 13:23:26 +00:00
SemaOpenCLCXX [OpenCL] Restrict various keywords in OpenCL C++ mode 2018-05-09 13:16:17 +00:00
SemaTemplate Improve diagnostics and error recovery for template name lookup. 2018-05-11 02:43:08 +00:00
TableGen TableGen: Give up on exact fixits for diagnostic groups 2018-03-06 17:55:00 +00:00
Templight [Templight] Template Instantiation Observer 2018-02-10 14:04:45 +00:00
Tooling Fix test clang-diff-json.cpp 2018-02-10 21:28:55 +00:00
Unit [lit] Set shlibpath_var on Solaris 2017-11-27 13:33:19 +00:00
VFS [vfs] Don't bail out after a missing -ivfsoverlay file 2018-03-23 17:37:27 +00:00
clang-rename
.clang-format
CMakeLists.txt [ThinLTO/CFI] Include TYPE_ID summaries into GLOBALVAL_SUMMARY_BLOCK 2018-02-14 22:41:15 +00:00
TestRunner.sh
cxx-sections.data
lit.cfg.py [lit] Fix running tests that require 'examples'. 2018-05-08 18:20:10 +00:00
lit.site.cfg.py.in Remove unused lit setting, see https://reviews.llvm.org/D46619 2018-05-09 12:38:51 +00:00
make_test_dirs.pl