llvm-project/clang/lib/AST
Yonghong Song b875343873 [Clang] Ignore BTFTag attr if used as a type attribute
Currently, linux kernel has a __user attribute ([1]) defined as
   __attribute__((noderef, address_space(__user)))
which is used by sparse tool ([2]) to do some
type checking of pointers to user space memory.
During normal compilation, __user will be defined
to nothing so it won't have an impact on compilation.

The btf_tag attribute, which is motivated by
carrying linux kernel annotations into dwarf/BTF,
is introduced in [3]. We intended to define __user as
   __attribute__((btf_tag("user")))
so such information will be encoded in dwarf/BTF
and can be used later by bpf verification or other
tracing tools.

But linux kernel __user attribute is also used during
type conversion which btf_tag doesn't support ([4]) since
such type conversion is only used for compiler analysis
and not encoded in dwarf/btf. Theoretically, it is
possible for clang to understand these tags and
do a sparse-like type checking work. But I would like
to leave that to future work and for now suggest simply
ignore these btf_tag attributes if they are used
as type attributes.

  [1] https://github.com/torvalds/linux/blob/master/include/linux/compiler_types.h#L10
  [2] https://sparse.docs.kernel.org/en/latest/
  [3] https://reviews.llvm.org/D106614
  [4] https://github.com/torvalds/linux/blob/master/fs/binfmt_flat.c#L135

Differential Revision: https://reviews.llvm.org/D110116
2021-09-22 13:48:29 -07:00
..
Interp [clang] Fix a few more comment typos to cycle bots 2021-09-20 20:06:03 -04:00
APValue.cpp [NFC] Move readAPValue/writeAPValue up the inheritance hierarchy 2021-01-06 16:44:50 -08:00
ASTConcept.cpp [llvm][clang][NFC] updates inline licence info 2021-08-11 02:48:53 +00:00
ASTConsumer.cpp
ASTContext.cpp [clang] Fix a few more comment typos to cycle bots 2021-09-20 20:06:03 -04:00
ASTDiagnostic.cpp Fix missing qualifier in template type diffing 2021-08-16 18:34:18 -07:00
ASTDumper.cpp Undo Revert "Ignore template instantiations if not in AsIs mode" 2020-11-03 13:59:01 -08:00
ASTImporter.cpp [clang][ASTImporter] Generic attribute import handling (first step). 2021-09-22 10:14:03 +02:00
ASTImporterLookupTable.cpp [clang][AST] Set correct DeclContext in ASTImporter lookup table for ParmVarDecl. 2021-06-04 14:24:44 +02:00
ASTStructuralEquivalence.cpp [ADT] Remove APInt/APSInt toString() std::string variants 2021-06-11 13:19:15 +01:00
ASTTypeTraits.cpp Reapply "Support Attr in DynTypedNode and ASTMatchers." 2021-08-06 22:30:32 +02:00
AttrDocTable.cpp [gn build] manually port 18f9e25ce1 (AttrDocTable) 2021-08-12 21:30:59 -04:00
AttrImpl.cpp [OpenMP] Overhaul `declare target` handling 2021-05-06 02:10:41 -05:00
CMakeLists.txt [gn build] manually port 18f9e25ce1 (AttrDocTable) 2021-08-12 21:30:59 -04:00
CXXABI.h Recommit of a2fdf9d4d7. 2021-02-05 11:27:30 -05:00
CXXInheritance.cpp Make iteration over the DeclContext::lookup_result safe. 2021-03-17 08:59:04 +00:00
Comment.cpp
CommentBriefParser.cpp [clang] Fix a few more comment typos to cycle bots 2021-09-20 20:06:03 -04:00
CommentCommandTraits.cpp
CommentLexer.cpp [clang][NFC] Rearrange Comment Token and Lexer fields to reduce padding 2020-10-27 00:03:43 +00:00
CommentParser.cpp
CommentSema.cpp
ComparisonCategories.cpp [clang] Fix a few more comment typos to cycle bots 2021-09-20 20:06:03 -04:00
ComputeDependence.cpp [clang] Make CXXDefaultArgExpr inherit dependence from the inner Expr 2021-06-10 14:51:08 +02:00
DataCollection.cpp
Decl.cpp [AST] Pick last tentative definition as the acting definition 2021-08-26 16:49:54 -05:00
DeclBase.cpp Replace an unnecessary null check with an assert; NFC 2021-08-20 12:04:46 -04:00
DeclCXX.cpp [clang] Fix a few more comment typos to cycle bots 2021-09-20 20:06:03 -04:00
DeclFriend.cpp
DeclGroup.cpp
DeclObjC.cpp [ObjC] Add a command line flag that disables recognition of objc_direct for testability 2021-04-06 11:17:01 -04:00
DeclOpenMP.cpp
DeclPrinter.cpp Add dumping support for RequiresExpr. 2021-06-30 14:27:19 -07:00
DeclTemplate.cpp [clang] Fix a few more comment typos to cycle bots 2021-09-20 20:06:03 -04:00
DeclarationName.cpp [clang][AST] Encapsulate DeclarationNameLoc, NFCI 2021-01-27 11:21:01 +00:00
Expr.cpp [OpenCL] Defines helper function for OpenCL default address space 2021-09-21 15:12:08 +01:00
ExprCXX.cpp [Clang] Introduce Swift async calling convention. 2021-07-09 11:50:10 -07:00
ExprClassification.cpp [clang] NFC: change uses of `Expr->getValueKind` into `is?Value` 2021-07-28 03:09:31 +02:00
ExprConcepts.cpp [clang] NFC: Rename rvalue to prvalue 2021-06-09 12:27:10 +02:00
ExprConstant.cpp [clang] don't mark as Elidable CXXConstruct expressions used in NRVO 2021-09-21 21:41:20 +02:00
ExprObjC.cpp [clang] NFC: refactor multiple implementations of getDecltypeForParenthesizedExpr 2021-07-28 23:27:43 +02:00
ExternalASTMerger.cpp Make iteration over the DeclContext::lookup_result safe. 2021-03-17 08:59:04 +00:00
ExternalASTSource.cpp
FormatString.cpp
FormatStringParsing.h
InheritViz.cpp
ItaniumCXXABI.cpp Recommit of a2fdf9d4d7. 2021-02-05 11:27:30 -05:00
ItaniumMangle.cpp [Clang] Add __ibm128 type to represent ppc_fp128 2021-09-06 18:00:58 +08:00
JSONNodeDumper.cpp Add dumping support for RequiresExpr. 2021-06-30 14:27:19 -07:00
Linkage.h [c++20] For P0732R2 / P1907R1: Basic code generation and name 2020-11-09 22:10:27 -08:00
Mangle.cpp [clang/Basic] Make TargetInfo.h not use DataLayout again 2021-04-27 22:26:10 -04:00
MicrosoftCXXABI.cpp Recommit of a2fdf9d4d7. 2021-02-05 11:27:30 -05:00
MicrosoftMangle.cpp [clang] Fix a few more comment typos to cycle bots 2021-09-20 20:06:03 -04:00
NSAPI.cpp [Clang] Add __ibm128 type to represent ppc_fp128 2021-09-06 18:00:58 +08:00
NestedNameSpecifier.cpp Fully qualify template template parameters when printing 2021-09-02 15:04:34 -07:00
ODRHash.cpp Revert "Following up on PR48517, fix handling of template arguments that refer" 2021-01-20 15:55:35 +01:00
OSLog.cpp
OpenMPClause.cpp OpenMP 5.0 metadirective 2021-09-18 13:40:44 -05:00
ParentMap.cpp
ParentMapContext.cpp Reapply "Support Attr in DynTypedNode and ASTMatchers." 2021-08-06 22:30:32 +02:00
PrintfFormatString.cpp [Clang] Add __ibm128 type to represent ppc_fp128 2021-09-06 18:00:58 +08:00
QualTypeNames.cpp Fully-qualify template args of outer types in getFullyQualifiedType 2021-06-03 10:50:00 -07:00
RawCommentList.cpp
RecordLayout.cpp
RecordLayoutBuilder.cpp [clang] Fix a few more comment typos to cycle bots 2021-09-20 20:06:03 -04:00
ScanfFormatString.cpp
SelectorLocationsKind.cpp
Stmt.cpp [cfe] Support target-specific escaped character in inline asm 2021-05-24 21:39:21 -07:00
StmtCXX.cpp
StmtIterator.cpp
StmtObjC.cpp
StmtOpenMP.cpp OpenMP 5.0 metadirective 2021-09-18 13:40:44 -05:00
StmtPrinter.cpp OpenMP 5.0 metadirective 2021-09-18 13:40:44 -05:00
StmtProfile.cpp OpenMP 5.0 metadirective 2021-09-18 13:40:44 -05:00
StmtViz.cpp
TemplateBase.cpp Fully qualify template template parameters when printing 2021-09-02 15:04:34 -07:00
TemplateName.cpp Fully qualify template template parameters when printing 2021-09-02 15:04:34 -07:00
TextNodeDumper.cpp Add dumping support for RequiresExpr. 2021-06-30 14:27:19 -07:00
Type.cpp Print nullptr_t namespace qualified within std:: 2021-09-21 11:21:40 -07:00
TypeLoc.cpp [Clang] Add __ibm128 type to represent ppc_fp128 2021-09-06 18:00:58 +08:00
TypePrinter.cpp [Clang] Ignore BTFTag attr if used as a type attribute 2021-09-22 13:48:29 -07:00
VTTBuilder.cpp
VTableBuilder.cpp [NFC] [Clang]: fix spelling mistake in assert message 2021-04-12 14:10:52 +08:00