vitalybuka created this revision. Herald added a project: All. vitalybuka requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
There is no initialization of the data between allocation and first getBeginLoc call. llvm-project/clang/lib/AST/ASTContext.cpp:3022 llvm-project/clang/lib/AST/TypeLoc.cpp:222 Msan report https://reviews.llvm.org/P8306 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D150499 Files: clang/include/clang/AST/Type.h clang/include/clang/AST/TypeLoc.h clang/lib/AST/ASTContext.cpp Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -3019,7 +3019,7 @@ auto *TInfo = (TypeSourceInfo*)BumpAlloc.Allocate(sizeof(TypeSourceInfo) + DataSize, 8); - new (TInfo) TypeSourceInfo(T); + new (TInfo) TypeSourceInfo(T, DataSize); return TInfo; } Index: clang/include/clang/AST/TypeLoc.h =================================================================== --- clang/include/clang/AST/TypeLoc.h +++ clang/include/clang/AST/TypeLoc.h @@ -240,6 +240,11 @@ static SourceRange getLocalSourceRangeImpl(TypeLoc TL); }; +inline TypeSourceInfo::TypeSourceInfo(QualType ty, size_t DataSize) : Ty(ty) { + // Init data attached to the object. See getTypeLoc. + memset(this + 1, 255, DataSize); +} + /// Return the TypeLoc for a type source info. inline TypeLoc TypeSourceInfo::getTypeLoc() const { // TODO: is this alignment already sufficient? Index: clang/include/clang/AST/Type.h =================================================================== --- clang/include/clang/AST/Type.h +++ clang/include/clang/AST/Type.h @@ -6640,7 +6640,7 @@ QualType Ty; - TypeSourceInfo(QualType ty) : Ty(ty) {} + TypeSourceInfo(QualType ty, size_t DataSize); // implemented in TypeLoc.h public: /// Return the type wrapped by this type source info.
Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -3019,7 +3019,7 @@ auto *TInfo = (TypeSourceInfo*)BumpAlloc.Allocate(sizeof(TypeSourceInfo) + DataSize, 8); - new (TInfo) TypeSourceInfo(T); + new (TInfo) TypeSourceInfo(T, DataSize); return TInfo; } Index: clang/include/clang/AST/TypeLoc.h =================================================================== --- clang/include/clang/AST/TypeLoc.h +++ clang/include/clang/AST/TypeLoc.h @@ -240,6 +240,11 @@ static SourceRange getLocalSourceRangeImpl(TypeLoc TL); }; +inline TypeSourceInfo::TypeSourceInfo(QualType ty, size_t DataSize) : Ty(ty) { + // Init data attached to the object. See getTypeLoc. + memset(this + 1, 255, DataSize); +} + /// Return the TypeLoc for a type source info. inline TypeLoc TypeSourceInfo::getTypeLoc() const { // TODO: is this alignment already sufficient? Index: clang/include/clang/AST/Type.h =================================================================== --- clang/include/clang/AST/Type.h +++ clang/include/clang/AST/Type.h @@ -6640,7 +6640,7 @@ QualType Ty; - TypeSourceInfo(QualType ty) : Ty(ty) {} + TypeSourceInfo(QualType ty, size_t DataSize); // implemented in TypeLoc.h public: /// Return the type wrapped by this type source info.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits