[clang] c2f1831 - Move ASTRecordReader into its own header; NFC.
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 14 12:15:22 PST 2019
On 14 Dec 2019, at 14:37, Nico Weber wrote:
> One of the commits in this series, likely
> https://github.com/llvm/llvm-project/commit/d505e57cc273750541ec8bbce2065b8b87c99ad6
> (which for some reason doesn't show up on cfe-commits?)
> broke Modules/merge-lifetime-extended-temporary.cpp when using a clang
> built at r365097 as host compiler. (Full error log:
> http://45.33.8.238/linux/5720/step_7.txt , also copied to the bottom
> of
> this mail for indexing.)
>
> I tried the test with a few other clangs as host compilers and
> everything
> passes (I tried 362913, 369647, and the 9.0 release clang), so this
> very
> likely isn't worth looking into more. But in case others see this
> failure,
> maybe this note helps them.
Weird. Thanks for letting me know.
John.
>
> Nico
>
>
>
> Full error:
>
> FAIL: Clang :: Modules/merge-lifetime-extended-temporary.cpp (6905 of
> 16551)
> ******************** TEST 'Clang ::
> Modules/merge-lifetime-extended-temporary.cpp' FAILED
> ********************
> Script:
> --
> : 'RUN: at line 1';
> /usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang -cc1
> -internal-isystem
> /usr/local/google/home/thakis/src/llvm-project/out/gn/lib/clang/10.0.0/include
> -nostdsysteminc -fmodules -fimplicit-module-maps
> -fmodules-cache-path=/usr/local/google/home/thakis/src/llvm-project/out/gn/obj/clang/test/Modules/Output/merge-lifetime-extended-temporary.cpp.tmp
> -x c++
> -I/usr/local/google/home/thakis/src/llvm-project/clang/test/Modules/Inputs/merge-lifetime-extended-temporary
> -verify -std=c++11
> /usr/local/google/home/thakis/src/llvm-project/clang/test/Modules/merge-lifetime-extended-temporary.cpp
> -DORDER=1
> : 'RUN: at line 2';
> /usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang -cc1
> -internal-isystem
> /usr/local/google/home/thakis/src/llvm-project/out/gn/lib/clang/10.0.0/include
> -nostdsysteminc -fmodules -fimplicit-module-maps
> -fmodules-cache-path=/usr/local/google/home/thakis/src/llvm-project/out/gn/obj/clang/test/Modules/Output/merge-lifetime-extended-temporary.cpp.tmp
> -x c++
> -I/usr/local/google/home/thakis/src/llvm-project/clang/test/Modules/Inputs/merge-lifetime-extended-temporary
> -verify -std=c++11
> /usr/local/google/home/thakis/src/llvm-project/clang/test/Modules/merge-lifetime-extended-temporary.cpp
> -DORDER=2
> --
> Exit Code: 134
>
> Command Output (stderr):
> --
> clang: ../../clang/include/clang/AST/Type.h:666: const
> clang::ExtQualsTypeCommonBase *clang::QualType::getCommonPtr() const:
> Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed.
> Stack dump:
> 0. Program arguments:
> /usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang -cc1
> -internal-isystem
> /usr/local/google/home/thakis/src/llvm-project/out/gn/lib/clang/10.0.0/include
> -nostdsysteminc -fmodules -fimplicit-module-maps
> -fmodules-cache-path=/usr/local/google/home/thakis/src/llvm-project/out/gn/obj/clang/test/Modules/Output/merge-lifetime-extended-temporary.cpp.tmp
> -x c++
> -I/usr/local/google/home/thakis/src/llvm-project/clang/test/Modules/Inputs/merge-lifetime-extended-temporary
> -verify -std=c++11
> /usr/local/google/home/thakis/src/llvm-project/clang/test/Modules/merge-lifetime-extended-temporary.cpp
> -DORDER=1
> 1.
> /usr/local/google/home/thakis/src/llvm-project/clang/test/Modules/merge-lifetime-extended-temporary.cpp:13:24:
> current parser token '=='
> #0 0x0000000003e57cbd PrintStackTraceSignalHandler(void*)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x3e57cbd)
> #1 0x0000000003e55a0e llvm::sys::RunSignalHandlers()
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x3e55a0e)
> #2 0x0000000003e57e7c SignalHandler(int)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x3e57e7c)
> #3 0x00007fa76931f3a0 __restore_rt
> (/lib/x86_64-linux-gnu/libpthread.so.0+0x123a0)
> #4 0x00007fa7689e6cfb raise
> /build/glibc-XAwaOT/glibc-2.28/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
> #5 0x00007fa7689d18ad abort
> /build/glibc-XAwaOT/glibc-2.28/stdlib/abort.c:81:7
> #6 0x00007fa7689d177f get_sysdep_segment_value
> /build/glibc-XAwaOT/glibc-2.28/intl/loadmsgcat.c:509:8
> #7 0x00007fa7689d177f _nl_load_domain
> /build/glibc-XAwaOT/glibc-2.28/intl/loadmsgcat.c:970:34
> #8 0x00007fa7689df542 (/lib/x86_64-linux-gnu/libc.so.6+0x2f542)
> #9 0x0000000002fce25a
> clang::ASTContext::getCanonicalType(clang::QualType)
> const
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x2fce25a)
> #10 0x000000000455ebff
> clang::ASTContext::getLValueReferenceType(clang::QualType, bool) const
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x455ebff)
> #11 0x00000000054064a5 clang::ASTReader::readTypeRecord(unsigned int)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x54064a5)
> #12 0x00000000053fb305 clang::ASTReader::GetType(unsigned int)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x53fb305)
> #13 0x000000000544a0fe
> clang::ASTDeclReader::VisitValueDecl(clang::ValueDecl*)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x544a0fe)
> #14 0x000000000544a260
> clang::ASTDeclReader::VisitDeclaratorDecl(clang::DeclaratorDecl*)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x544a260)
> #15 0x000000000544e5cc
> clang::ASTDeclReader::VisitVarDeclImpl(clang::VarDecl*)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x544e5cc)
> #16 0x000000000544812f clang::ASTDeclReader::Visit(clang::Decl*)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x544812f)
> #17 0x000000000546a572 clang::ASTReader::ReadDeclRecord(unsigned int)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x546a572)
> #18 0x00000000053fbee0 clang::ASTReader::GetDecl(unsigned int)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x53fbee0)
> #19 0x000000000548118e
> clang::ASTStmtReader::VisitDeclRefExpr(clang::DeclRefExpr*)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x548118e)
> #20 0x000000000549098a
> clang::ASTReader::ReadStmtFromStream(clang::serialization::ModuleFile&)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x549098a)
> #21 0x0000000005490cd6
> clang::ASTReader::ReadExpr(clang::serialization::ModuleFile&)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x5490cd6)
> #22 0x000000000544eae3
> clang::ASTDeclReader::VisitVarDeclImpl(clang::VarDecl*)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x544eae3)
> #23 0x000000000544812f clang::ASTDeclReader::Visit(clang::Decl*)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x544812f)
> #24 0x000000000546a572 clang::ASTReader::ReadDeclRecord(unsigned int)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x546a572)
> #25 0x000000000540b563
> clang::ASTReader::FindExternalVisibleDeclsByName(clang::DeclContext
> const*,
> clang::DeclarationName)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x540b563)
> #26 0x00000000046f2b74
> clang::DeclContext::lookup(clang::DeclarationName)
> const
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x46f2b74)
> #27 0x00000000050dc38b LookupDirect(clang::Sema&,
> clang::LookupResult&,
> clang::DeclContext const*)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x50dc38b)
> #28 0x00000000050d8761 CppNamespaceLookup(clang::Sema&,
> clang::LookupResult&, clang::ASTContext&, clang::DeclContext*,
> (anonymous
> namespace)::UnqualUsingDirectiveSet&)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x50d8761)
> #29 0x00000000050d7aa1
> clang::Sema::CppLookupName(clang::LookupResult&,
> clang::Scope*)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x50d7aa1)
> #30 0x00000000050dbd85 clang::Sema::LookupName(clang::LookupResult&,
> clang::Scope*, bool)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x50dbd85)
> #31 0x0000000004f55f09 clang::Sema::ActOnIdExpression(clang::Scope*,
> clang::CXXScopeSpec&, clang::SourceLocation, clang::UnqualifiedId&,
> bool,
> bool, clang::CorrectionCandidateCallback*, bool, clang::Token*)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x4f55f09)
> #32 0x0000000004b75fde clang::Parser::ParseCastExpression(bool, bool,
> bool&, clang::Parser::TypeCastState, bool)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x4b75fde)
> #33 0x0000000004b73abd
> clang::Parser::ParseConstantExpressionInExprEvalContext(clang::Parser::TypeCastState)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x4b73abd)
> #34 0x0000000004b2b599
> clang::Parser::ParseStaticAssertDeclaration(clang::SourceLocation&)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x4b2b599)
> #35 0x0000000004b47059
> clang::Parser::ParseDeclaration(clang::DeclaratorContext,
> clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&,
> clang::SourceLocation*)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x4b47059)
> #36 0x0000000004b1dafb
> clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
> clang::ParsingDeclSpec*)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x4b1dafb)
> #37 0x0000000004b1c3a8
> clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&,
> bool)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x4b1c3a8)
> #38 0x0000000004b17d0d clang::ParseAST(clang::Sema&, bool, bool)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x4b17d0d)
> #39 0x00000000034eafa0 clang::FrontendAction::Execute()
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x34eafa0)
> #40 0x0000000003448362
> clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x3448362)
> #41 0x0000000003598b22
> clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x3598b22)
> #42 0x0000000002eb1abe cc1_main(llvm::ArrayRef<char const*>, char
> const*,
> void*)
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x2eb1abe)
> #43 0x0000000002ebf93e main
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x2ebf93e)
> #44 0x00007fa7689d352b __libc_start_main
> /build/glibc-XAwaOT/glibc-2.28/csu/../csu/libc-start.c:342:3
> #45 0x0000000002eb102a _start
> (/usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang+0x2eb102a)
> /usr/local/google/home/thakis/src/llvm-project/out/gn/obj/clang/test/Modules/Output/merge-lifetime-extended-temporary.cpp.script:
> line 2: 180489 Aborted
> /usr/local/google/home/thakis/src/llvm-project/out/gn/bin/clang -cc1
> -internal-isystem
> /usr/local/google/home/thakis/src/llvm-project/out/gn/lib/clang/10.0.0/include
> -nostdsysteminc -fmodules -fimplicit-module-maps
> -fmodules-cache-path=/usr/local/google/home/thakis/src/llvm-project/out/gn/obj/clang/test/Modules/Output/merge-lifetime-extended-temporary.cpp.tmp
> -x c++
> -I/usr/local/google/home/thakis/src/llvm-project/clang/test/Modules/Inputs/merge-lifetime-extended-temporary
> -verify -std=c++11
> /usr/local/google/home/thakis/src/llvm-project/clang/test/Modules/merge-lifetime-extended-temporary.cpp
> -DORDER=1
>
> On Sat, Dec 14, 2019 at 3:28 AM John McCall via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
>>
>> Author: John McCall
>> Date: 2019-12-14T03:28:23-05:00
>> New Revision: c2f18315ff53006e44afe065368019e41cb98053
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/c2f18315ff53006e44afe065368019e41cb98053
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/c2f18315ff53006e44afe065368019e41cb98053.diff
>>
>> LOG: Move ASTRecordReader into its own header; NFC.
>>
>> AbstractBasicReader.h has quite a few dependencies already,
>> and that's only likely to increase. Meanwhile, ASTRecordReader
>> is really an implementation detail of the ASTReader that is only
>> used in a small number of places.
>>
>> I've kept it in a public header for the use of projects like Swift
>> that might want to plug in to Clang's serialization framework.
>>
>> I've also moved OMPClauseReader into an implementation file,
>> although it can't be made private because of friendship.
>>
>> Added:
>> clang/include/clang/Serialization/ASTRecordReader.h
>>
>> Modified:
>> clang/include/clang/Serialization/ASTReader.h
>> clang/lib/Serialization/ASTReader.cpp
>> clang/lib/Serialization/ASTReaderDecl.cpp
>> clang/lib/Serialization/ASTReaderStmt.cpp
>> clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
>>
>> Removed:
>>
>>
>>
>>
>> ################################################################################
>> diff --git a/clang/include/clang/Serialization/ASTReader.h
>> b/clang/include/clang/Serialization/ASTReader.h
>> index 3f321f03d966..e74bf00e0872 100644
>> --- a/clang/include/clang/Serialization/ASTReader.h
>> +++ b/clang/include/clang/Serialization/ASTReader.h
>> @@ -13,26 +13,16 @@
>> #ifndef LLVM_CLANG_SERIALIZATION_ASTREADER_H
>> #define LLVM_CLANG_SERIALIZATION_ASTREADER_H
>>
>> -#include "clang/AST/AbstractBasicReader.h"
>> -#include "clang/AST/DeclCXX.h"
>> -#include "clang/AST/DeclObjC.h"
>> -#include "clang/AST/DeclarationName.h"
>> -#include "clang/AST/NestedNameSpecifier.h"
>> -#include "clang/AST/OpenMPClause.h"
>> -#include "clang/AST/TemplateBase.h"
>> -#include "clang/AST/TemplateName.h"
>> #include "clang/AST/Type.h"
>> #include "clang/Basic/Diagnostic.h"
>> #include "clang/Basic/DiagnosticOptions.h"
>> #include "clang/Basic/IdentifierTable.h"
>> -#include "clang/Basic/Module.h"
>> #include "clang/Basic/OpenCLOptions.h"
>> #include "clang/Basic/SourceLocation.h"
>> #include "clang/Basic/Version.h"
>> #include "clang/Lex/ExternalPreprocessorSource.h"
>> #include "clang/Lex/HeaderSearch.h"
>> #include "clang/Lex/PreprocessingRecord.h"
>> -#include "clang/Lex/Token.h"
>> #include "clang/Sema/ExternalSemaSource.h"
>> #include "clang/Sema/IdentifierResolver.h"
>> #include "clang/Serialization/ASTBitCodes.h"
>> @@ -40,9 +30,6 @@
>> #include "clang/Serialization/ModuleFile.h"
>> #include "clang/Serialization/ModuleFileExtension.h"
>> #include "clang/Serialization/ModuleManager.h"
>> -#include "llvm/ADT/APFloat.h"
>> -#include "llvm/ADT/APInt.h"
>> -#include "llvm/ADT/APSInt.h"
>> #include "llvm/ADT/ArrayRef.h"
>> #include "llvm/ADT/DenseMap.h"
>> #include "llvm/ADT/DenseSet.h"
>> @@ -58,8 +45,6 @@
>> #include "llvm/ADT/iterator.h"
>> #include "llvm/ADT/iterator_range.h"
>> #include "llvm/Bitstream/BitstreamReader.h"
>> -#include "llvm/Support/Casting.h"
>> -#include "llvm/Support/Endian.h"
>> #include "llvm/Support/MemoryBuffer.h"
>> #include "llvm/Support/Timer.h"
>> #include "llvm/Support/VersionTuple.h"
>> @@ -83,6 +68,7 @@ class ASTReader;
>> class ASTRecordReader;
>> class CXXTemporary;
>> class Decl;
>> +class DeclarationName;
>> class DeclaratorDecl;
>> class DeclContext;
>> class EnumDecl;
>> @@ -112,9 +98,8 @@ class SourceManager;
>> class Stmt;
>> class SwitchCase;
>> class TargetOptions;
>> -class TemplateParameterList;
>> +class Token;
>> class TypedefNameDecl;
>> -class TypeSourceInfo;
>> class ValueDecl;
>> class VarDecl;
>>
>> @@ -2280,341 +2265,6 @@ class ASTReader
>> bool isProcessingUpdateRecords() { return ProcessingUpdateRecords;
>> }
>> };
>>
>> -/// An object for streaming information from a record.
>> -class ASTRecordReader
>> - : public serialization::DataStreamBasicReader<ASTRecordReader> {
>> - using ModuleFile = serialization::ModuleFile;
>> -
>> - ASTReader *Reader;
>> - ModuleFile *F;
>> - unsigned Idx = 0;
>> - ASTReader::RecordData Record;
>> -
>> - using RecordData = ASTReader::RecordData;
>> - using RecordDataImpl = ASTReader::RecordDataImpl;
>> -
>> -public:
>> - /// Construct an ASTRecordReader that uses the default encoding
>> scheme.
>> - ASTRecordReader(ASTReader &Reader, ModuleFile &F)
>> - : DataStreamBasicReader(Reader.getContext()), Reader(&Reader),
>> F(&F)
>> {}
>> -
>> - /// Reads a record with id AbbrevID from Cursor, resetting the
>> - /// internal state.
>> - Expected<unsigned> readRecord(llvm::BitstreamCursor &Cursor,
>> - unsigned AbbrevID);
>> -
>> - /// Is this a module file for a module (rather than a PCH or
>> similar).
>> - bool isModule() const { return F->isModule(); }
>> -
>> - /// Retrieve the AST context that this AST reader supplements.
>> - ASTContext &getContext() { return Reader->getContext(); }
>> -
>> - /// The current position in this record.
>> - unsigned getIdx() const { return Idx; }
>> -
>> - /// The length of this record.
>> - size_t size() const { return Record.size(); }
>> -
>> - /// An arbitrary index in this record.
>> - const uint64_t &operator[](size_t N) { return Record[N]; }
>> -
>> - /// Returns the last value in this record.
>> - uint64_t back() { return Record.back(); }
>> -
>> - /// Returns the current value in this record, and advances to the
>> - /// next value.
>> - uint64_t readInt() { return Record[Idx++]; }
>> -
>> - ArrayRef<uint64_t> readIntArray(unsigned Len) {
>> - auto Array = llvm::makeArrayRef(Record).slice(Idx, Len);
>> - Idx += Len;
>> - return Array;
>> - }
>> -
>> - /// Returns the current value in this record, without advancing.
>> - uint64_t peekInt() { return Record[Idx]; }
>> -
>> - /// Skips the specified number of values.
>> - void skipInts(unsigned N) { Idx += N; }
>> -
>> - /// Retrieve the global submodule ID its local ID number.
>> - serialization::SubmoduleID
>> - getGlobalSubmoduleID(unsigned LocalID) {
>> - return Reader->getGlobalSubmoduleID(*F, LocalID);
>> - }
>> -
>> - /// Retrieve the submodule that corresponds to a global submodule
>> ID.
>> - Module *getSubmodule(serialization::SubmoduleID GlobalID) {
>> - return Reader->getSubmodule(GlobalID);
>> - }
>> -
>> - /// Read the record that describes the lexical contents of a DC.
>> - bool readLexicalDeclContextStorage(uint64_t Offset, DeclContext
>> *DC) {
>> - return Reader->ReadLexicalDeclContextStorage(*F, F->DeclsCursor,
>> Offset,
>> - DC);
>> - }
>> -
>> - /// Read the record that describes the visible contents of a DC.
>> - bool readVisibleDeclContextStorage(uint64_t Offset,
>> - serialization::DeclID ID) {
>> - return Reader->ReadVisibleDeclContextStorage(*F, F->DeclsCursor,
>> Offset,
>> - ID);
>> - }
>> -
>> - ExplicitSpecifier readExplicitSpec() {
>> - uint64_t Kind = readInt();
>> - bool HasExpr = Kind & 0x1;
>> - Kind = Kind >> 1;
>> - return ExplicitSpecifier(HasExpr ? readExpr() : nullptr,
>> - static_cast<ExplicitSpecKind>(Kind));
>> - }
>> -
>> - /// Read information about an exception specification (inherited).
>> - //FunctionProtoType::ExceptionSpecInfo
>> - //readExceptionSpecInfo(SmallVectorImpl<QualType>
>> &ExceptionStorage);
>> -
>> - /// Get the global offset corresponding to a local offset.
>> - uint64_t getGlobalBitOffset(uint32_t LocalOffset) {
>> - return Reader->getGlobalBitOffset(*F, LocalOffset);
>> - }
>> -
>> - /// Reads a statement.
>> - Stmt *readStmt() { return Reader->ReadStmt(*F); }
>> - Stmt *readStmtRef() { return readStmt(); /* FIXME: readSubStmt? */
>> }
>> -
>> - /// Reads an expression.
>> - Expr *readExpr() { return Reader->ReadExpr(*F); }
>> -
>> - /// Reads a sub-statement operand during statement reading.
>> - Stmt *readSubStmt() { return Reader->ReadSubStmt(); }
>> -
>> - /// Reads a sub-expression operand during statement reading.
>> - Expr *readSubExpr() { return Reader->ReadSubExpr(); }
>> -
>> - /// Reads a declaration with the given local ID in the given
>> module.
>> - ///
>> - /// \returns The requested declaration, casted to the given return
>> type.
>> - template<typename T>
>> - T *GetLocalDeclAs(uint32_t LocalID) {
>> - return cast_or_null<T>(Reader->GetLocalDecl(*F, LocalID));
>> - }
>> -
>> - /// Reads a TemplateArgumentLocInfo appropriate for the
>> - /// given TemplateArgument kind, advancing Idx.
>> - TemplateArgumentLocInfo
>> - readTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind);
>> -
>> - /// Reads a TemplateArgumentLoc, advancing Idx.
>> - TemplateArgumentLoc readTemplateArgumentLoc();
>> -
>> - const ASTTemplateArgumentListInfo*
>> - readASTTemplateArgumentListInfo();
>> -
>> - /// Reads a declarator info from the given record, advancing Idx.
>> - TypeSourceInfo *readTypeSourceInfo();
>> -
>> - /// Reads the location information for a type.
>> - void readTypeLoc(TypeLoc TL);
>> -
>> -
>> - /// Map a local type ID within a given AST file to a global type
>> ID.
>> - serialization::TypeID getGlobalTypeID(unsigned LocalID) const {
>> - return Reader->getGlobalTypeID(*F, LocalID);
>> - }
>> -
>> - Qualifiers readQualifiers() {
>> - return Qualifiers::fromOpaqueValue(readInt());
>> - }
>> -
>> - /// Read a type from the current position in the record.
>> - QualType readType() {
>> - return Reader->readType(*F, Record, Idx);
>> - }
>> - QualType readQualType() {
>> - return readType();
>> - }
>> -
>> - /// Reads a declaration ID from the given position in this record.
>> - ///
>> - /// \returns The declaration ID read from the record, adjusted to
>> a
>> global ID.
>> - serialization::DeclID readDeclID() {
>> - return Reader->ReadDeclID(*F, Record, Idx);
>> - }
>> -
>> - /// Reads a declaration from the given position in a record in the
>> - /// given module, advancing Idx.
>> - Decl *readDecl() {
>> - return Reader->ReadDecl(*F, Record, Idx);
>> - }
>> - Decl *readDeclRef() {
>> - return readDecl();
>> - }
>> -
>> - /// Reads a declaration from the given position in the record,
>> - /// advancing Idx.
>> - ///
>> - /// \returns The declaration read from this location, casted to
>> the
>> given
>> - /// result type.
>> - template<typename T>
>> - T *readDeclAs() {
>> - return Reader->ReadDeclAs<T>(*F, Record, Idx);
>> - }
>> -
>> - IdentifierInfo *readIdentifier() {
>> - return Reader->readIdentifier(*F, Record, Idx);
>> - }
>> -
>> - /// Read a selector from the Record, advancing Idx.
>> - Selector readSelector() {
>> - return Reader->ReadSelector(*F, Record, Idx);
>> - }
>> -
>> - /// Read a declaration name, advancing Idx.
>> - // DeclarationName readDeclarationName(); (inherited)
>> - DeclarationNameLoc readDeclarationNameLoc(DeclarationName Name);
>> - DeclarationNameInfo readDeclarationNameInfo();
>> -
>> - void readQualifierInfo(QualifierInfo &Info);
>> -
>> - /// Return a nested name specifier, advancing Idx.
>> - // NestedNameSpecifier *readNestedNameSpecifier(); (inherited)
>> -
>> - NestedNameSpecifierLoc readNestedNameSpecifierLoc();
>> -
>> - /// Read a template name, advancing Idx.
>> - // TemplateName readTemplateName(); (inherited)
>> -
>> - /// Read a template argument, advancing Idx. (inherited)
>> - // TemplateArgument readTemplateArgument(bool Canonicalize =
>> false);
>> -
>> - /// Read a template parameter list, advancing Idx.
>> - TemplateParameterList *readTemplateParameterList();
>> -
>> - /// Read a template argument array, advancing Idx.
>> - void readTemplateArgumentList(SmallVectorImpl<TemplateArgument>
>> &TemplArgs,
>> - bool Canonicalize = false);
>> -
>> - /// Read a UnresolvedSet structure, advancing Idx.
>> - void readUnresolvedSet(LazyASTUnresolvedSet &Set);
>> -
>> - /// Read a C++ base specifier, advancing Idx.
>> - CXXBaseSpecifier readCXXBaseSpecifier();
>> -
>> - /// Read a CXXCtorInitializer array, advancing Idx.
>> - CXXCtorInitializer **readCXXCtorInitializers();
>> -
>> - CXXTemporary *readCXXTemporary() {
>> - return Reader->ReadCXXTemporary(*F, Record, Idx);
>> - }
>> -
>> - /// Read a source location, advancing Idx.
>> - SourceLocation readSourceLocation() {
>> - return Reader->ReadSourceLocation(*F, Record, Idx);
>> - }
>> -
>> - /// Read a source range, advancing Idx.
>> - SourceRange readSourceRange() {
>> - return Reader->ReadSourceRange(*F, Record, Idx);
>> - }
>> -
>> - /// Read an arbitrary constant value, advancing Idx.
>> - APValue readAPValue();
>> -
>> - /// Read an integral value, advancing Idx.
>> - // llvm::APInt readAPInt(); (inherited)
>> -
>> - /// Read a signed integral value, advancing Idx.
>> - // llvm::APSInt readAPSInt(); (inherited)
>> -
>> - /// Read a floating-point value, advancing Idx.
>> - llvm::APFloat readAPFloat(const llvm::fltSemantics &Sem);
>> -
>> - /// Read a boolean value, advancing Idx.
>> - bool readBool() { return readInt() != 0; }
>> -
>> - /// Read a 32-bit unsigned value; required to satisfy BasicReader.
>> - uint32_t readUInt32() {
>> - return uint32_t(readInt());
>> - }
>> -
>> - /// Read a 64-bit unsigned value; required to satisfy BasicReader.
>> - uint64_t readUInt64() {
>> - return readInt();
>> - }
>> -
>> - /// Read a string, advancing Idx.
>> - std::string readString() {
>> - return Reader->ReadString(Record, Idx);
>> - }
>> -
>> - /// Read a path, advancing Idx.
>> - std::string readPath() {
>> - return Reader->ReadPath(*F, Record, Idx);
>> - }
>> -
>> - /// Read a version tuple, advancing Idx.
>> - VersionTuple readVersionTuple() {
>> - return ASTReader::ReadVersionTuple(Record, Idx);
>> - }
>> -
>> - /// Reads one attribute from the current stream position,
>> advancing Idx.
>> - Attr *readAttr();
>> -
>> - /// Reads attributes from the current stream position, advancing
>> Idx.
>> - void readAttributes(AttrVec &Attrs);
>> -
>> - /// Reads a token out of a record, advancing Idx.
>> - Token readToken() {
>> - return Reader->ReadToken(*F, Record, Idx);
>> - }
>> -
>> - void recordSwitchCaseID(SwitchCase *SC, unsigned ID) {
>> - Reader->RecordSwitchCaseID(SC, ID);
>> - }
>> -
>> - /// Retrieve the switch-case statement with the given ID.
>> - SwitchCase *getSwitchCaseWithID(unsigned ID) {
>> - return Reader->getSwitchCaseWithID(ID);
>> - }
>> -};
>> -
>> -/// Helper class that saves the current stream position and
>> -/// then restores it when destroyed.
>> -struct SavedStreamPosition {
>> - explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor)
>> - : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) {}
>> -
>> - ~SavedStreamPosition() {
>> - if (llvm::Error Err = Cursor.JumpToBit(Offset))
>> - llvm::report_fatal_error(
>> - "Cursor should always be able to go back, failed: " +
>> - toString(std::move(Err)));
>> - }
>> -
>> -private:
>> - llvm::BitstreamCursor &Cursor;
>> - uint64_t Offset;
>> -};
>> -
>> -inline void PCHValidator::Error(const char *Msg) {
>> - Reader.Error(Msg);
>> -}
>> -
>> -class OMPClauseReader : public OMPClauseVisitor<OMPClauseReader> {
>> - ASTRecordReader &Record;
>> - ASTContext &Context;
>> -
>> -public:
>> - OMPClauseReader(ASTRecordReader &Record)
>> - : Record(Record), Context(Record.getContext()) {}
>> -
>> -#define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C);
>> -#include "clang/Basic/OpenMPKinds.def"
>> - OMPClause *readClause();
>> - void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C);
>> - void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C);
>> -};
>> -
>> } // namespace clang
>>
>> #endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H
>>
>> diff --git a/clang/include/clang/Serialization/ASTRecordReader.h
>> b/clang/include/clang/Serialization/ASTRecordReader.h
>> new file mode 100644
>> index 000000000000..4fad2881ffd9
>> --- /dev/null
>> +++ b/clang/include/clang/Serialization/ASTRecordReader.h
>> @@ -0,0 +1,351 @@
>> +//===- ASTRecordReader.h - Helper classes for reading AST -------*-
>> C++
>> -*-===//
>> +//
>> +// Part of the LLVM Project, under the Apache License v2.0 with LLVM
>> Exceptions.
>> +// See https://llvm.org/LICENSE.txt for license information.
>> +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
>> +//
>>
>> +//===----------------------------------------------------------------------===//
>> +//
>> +// This file defines classes that are useful in the implementation
>> of
>> +// the ASTReader.
>> +//
>>
>> +//===----------------------------------------------------------------------===//
>> +
>> +#ifndef LLVM_CLANG_SERIALIZATION_ASTRECORDREADER_H
>> +#define LLVM_CLANG_SERIALIZATION_ASTRECORDREADER_H
>> +
>> +#include "clang/AST/AbstractBasicReader.h"
>> +#include "clang/Lex/Token.h"
>> +#include "clang/Serialization/ASTReader.h"
>> +#include "llvm/ADT/APFloat.h"
>> +#include "llvm/ADT/APInt.h"
>> +#include "llvm/ADT/APSInt.h"
>> +
>> +namespace clang {
>> +
>> +/// An object for streaming information from a record.
>> +class ASTRecordReader
>> + : public serialization::DataStreamBasicReader<ASTRecordReader> {
>> + using ModuleFile = serialization::ModuleFile;
>> +
>> + ASTReader *Reader;
>> + ModuleFile *F;
>> + unsigned Idx = 0;
>> + ASTReader::RecordData Record;
>> +
>> + using RecordData = ASTReader::RecordData;
>> + using RecordDataImpl = ASTReader::RecordDataImpl;
>> +
>> +public:
>> + /// Construct an ASTRecordReader that uses the default encoding
>> scheme.
>> + ASTRecordReader(ASTReader &Reader, ModuleFile &F)
>> + : DataStreamBasicReader(Reader.getContext()), Reader(&Reader),
>> F(&F)
>> {}
>> +
>> + /// Reads a record with id AbbrevID from Cursor, resetting the
>> + /// internal state.
>> + Expected<unsigned> readRecord(llvm::BitstreamCursor &Cursor,
>> + unsigned AbbrevID);
>> +
>> + /// Is this a module file for a module (rather than a PCH or
>> similar).
>> + bool isModule() const { return F->isModule(); }
>> +
>> + /// Retrieve the AST context that this AST reader supplements.
>> + ASTContext &getContext() { return Reader->getContext(); }
>> +
>> + /// The current position in this record.
>> + unsigned getIdx() const { return Idx; }
>> +
>> + /// The length of this record.
>> + size_t size() const { return Record.size(); }
>> +
>> + /// An arbitrary index in this record.
>> + const uint64_t &operator[](size_t N) { return Record[N]; }
>> +
>> + /// Returns the last value in this record.
>> + uint64_t back() { return Record.back(); }
>> +
>> + /// Returns the current value in this record, and advances to the
>> + /// next value.
>> + uint64_t readInt() { return Record[Idx++]; }
>> +
>> + ArrayRef<uint64_t> readIntArray(unsigned Len) {
>> + auto Array = llvm::makeArrayRef(Record).slice(Idx, Len);
>> + Idx += Len;
>> + return Array;
>> + }
>> +
>> + /// Returns the current value in this record, without advancing.
>> + uint64_t peekInt() { return Record[Idx]; }
>> +
>> + /// Skips the specified number of values.
>> + void skipInts(unsigned N) { Idx += N; }
>> +
>> + /// Retrieve the global submodule ID its local ID number.
>> + serialization::SubmoduleID
>> + getGlobalSubmoduleID(unsigned LocalID) {
>> + return Reader->getGlobalSubmoduleID(*F, LocalID);
>> + }
>> +
>> + /// Retrieve the submodule that corresponds to a global submodule
>> ID.
>> + Module *getSubmodule(serialization::SubmoduleID GlobalID) {
>> + return Reader->getSubmodule(GlobalID);
>> + }
>> +
>> + /// Read the record that describes the lexical contents of a DC.
>> + bool readLexicalDeclContextStorage(uint64_t Offset, DeclContext
>> *DC) {
>> + return Reader->ReadLexicalDeclContextStorage(*F, F->DeclsCursor,
>> Offset,
>> + DC);
>> + }
>> +
>> + /// Read the record that describes the visible contents of a DC.
>> + bool readVisibleDeclContextStorage(uint64_t Offset,
>> + serialization::DeclID ID) {
>> + return Reader->ReadVisibleDeclContextStorage(*F, F->DeclsCursor,
>> Offset,
>> + ID);
>> + }
>> +
>> + ExplicitSpecifier readExplicitSpec() {
>> + uint64_t Kind = readInt();
>> + bool HasExpr = Kind & 0x1;
>> + Kind = Kind >> 1;
>> + return ExplicitSpecifier(HasExpr ? readExpr() : nullptr,
>> + static_cast<ExplicitSpecKind>(Kind));
>> + }
>> +
>> + /// Read information about an exception specification (inherited).
>> + //FunctionProtoType::ExceptionSpecInfo
>> + //readExceptionSpecInfo(SmallVectorImpl<QualType>
>> &ExceptionStorage);
>> +
>> + /// Get the global offset corresponding to a local offset.
>> + uint64_t getGlobalBitOffset(uint32_t LocalOffset) {
>> + return Reader->getGlobalBitOffset(*F, LocalOffset);
>> + }
>> +
>> + /// Reads a statement.
>> + Stmt *readStmt() { return Reader->ReadStmt(*F); }
>> + Stmt *readStmtRef() { return readStmt(); /* FIXME: readSubStmt? */
>> }
>> +
>> + /// Reads an expression.
>> + Expr *readExpr() { return Reader->ReadExpr(*F); }
>> +
>> + /// Reads a sub-statement operand during statement reading.
>> + Stmt *readSubStmt() { return Reader->ReadSubStmt(); }
>> +
>> + /// Reads a sub-expression operand during statement reading.
>> + Expr *readSubExpr() { return Reader->ReadSubExpr(); }
>> +
>> + /// Reads a declaration with the given local ID in the given
>> module.
>> + ///
>> + /// \returns The requested declaration, casted to the given return
>> type.
>> + template<typename T>
>> + T *GetLocalDeclAs(uint32_t LocalID) {
>> + return cast_or_null<T>(Reader->GetLocalDecl(*F, LocalID));
>> + }
>> +
>> + /// Reads a TemplateArgumentLocInfo appropriate for the
>> + /// given TemplateArgument kind, advancing Idx.
>> + TemplateArgumentLocInfo
>> + readTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind);
>> +
>> + /// Reads a TemplateArgumentLoc, advancing Idx.
>> + TemplateArgumentLoc readTemplateArgumentLoc();
>> +
>> + const ASTTemplateArgumentListInfo*
>> + readASTTemplateArgumentListInfo();
>> +
>> + /// Reads a declarator info from the given record, advancing Idx.
>> + TypeSourceInfo *readTypeSourceInfo();
>> +
>> + /// Reads the location information for a type.
>> + void readTypeLoc(TypeLoc TL);
>> +
>> +
>> + /// Map a local type ID within a given AST file to a global type
>> ID.
>> + serialization::TypeID getGlobalTypeID(unsigned LocalID) const {
>> + return Reader->getGlobalTypeID(*F, LocalID);
>> + }
>> +
>> + Qualifiers readQualifiers() {
>> + return Qualifiers::fromOpaqueValue(readInt());
>> + }
>> +
>> + /// Read a type from the current position in the record.
>> + QualType readType() {
>> + return Reader->readType(*F, Record, Idx);
>> + }
>> + QualType readQualType() {
>> + return readType();
>> + }
>> +
>> + /// Reads a declaration ID from the given position in this record.
>> + ///
>> + /// \returns The declaration ID read from the record, adjusted to
>> a
>> global ID.
>> + serialization::DeclID readDeclID() {
>> + return Reader->ReadDeclID(*F, Record, Idx);
>> + }
>> +
>> + /// Reads a declaration from the given position in a record in the
>> + /// given module, advancing Idx.
>> + Decl *readDecl() {
>> + return Reader->ReadDecl(*F, Record, Idx);
>> + }
>> + Decl *readDeclRef() {
>> + return readDecl();
>> + }
>> +
>> + /// Reads a declaration from the given position in the record,
>> + /// advancing Idx.
>> + ///
>> + /// \returns The declaration read from this location, casted to
>> the
>> given
>> + /// result type.
>> + template<typename T>
>> + T *readDeclAs() {
>> + return Reader->ReadDeclAs<T>(*F, Record, Idx);
>> + }
>> +
>> + IdentifierInfo *readIdentifier() {
>> + return Reader->readIdentifier(*F, Record, Idx);
>> + }
>> +
>> + /// Read a selector from the Record, advancing Idx.
>> + Selector readSelector() {
>> + return Reader->ReadSelector(*F, Record, Idx);
>> + }
>> +
>> + /// Read a declaration name, advancing Idx.
>> + // DeclarationName readDeclarationName(); (inherited)
>> + DeclarationNameLoc readDeclarationNameLoc(DeclarationName Name);
>> + DeclarationNameInfo readDeclarationNameInfo();
>> +
>> + void readQualifierInfo(QualifierInfo &Info);
>> +
>> + /// Return a nested name specifier, advancing Idx.
>> + // NestedNameSpecifier *readNestedNameSpecifier(); (inherited)
>> +
>> + NestedNameSpecifierLoc readNestedNameSpecifierLoc();
>> +
>> + /// Read a template name, advancing Idx.
>> + // TemplateName readTemplateName(); (inherited)
>> +
>> + /// Read a template argument, advancing Idx. (inherited)
>> + // TemplateArgument readTemplateArgument(bool Canonicalize =
>> false);
>> +
>> + /// Read a template parameter list, advancing Idx.
>> + TemplateParameterList *readTemplateParameterList();
>> +
>> + /// Read a template argument array, advancing Idx.
>> + void readTemplateArgumentList(SmallVectorImpl<TemplateArgument>
>> &TemplArgs,
>> + bool Canonicalize = false);
>> +
>> + /// Read a UnresolvedSet structure, advancing Idx.
>> + void readUnresolvedSet(LazyASTUnresolvedSet &Set);
>> +
>> + /// Read a C++ base specifier, advancing Idx.
>> + CXXBaseSpecifier readCXXBaseSpecifier();
>> +
>> + /// Read a CXXCtorInitializer array, advancing Idx.
>> + CXXCtorInitializer **readCXXCtorInitializers();
>> +
>> + CXXTemporary *readCXXTemporary() {
>> + return Reader->ReadCXXTemporary(*F, Record, Idx);
>> + }
>> +
>> + /// Read an OpenMP clause, advancing Idx.
>> + OMPClause *readOMPClause();
>> +
>> + /// Read a source location, advancing Idx.
>> + SourceLocation readSourceLocation() {
>> + return Reader->ReadSourceLocation(*F, Record, Idx);
>> + }
>> +
>> + /// Read a source range, advancing Idx.
>> + SourceRange readSourceRange() {
>> + return Reader->ReadSourceRange(*F, Record, Idx);
>> + }
>> +
>> + /// Read an arbitrary constant value, advancing Idx.
>> + APValue readAPValue();
>> +
>> + /// Read an integral value, advancing Idx.
>> + // llvm::APInt readAPInt(); (inherited)
>> +
>> + /// Read a signed integral value, advancing Idx.
>> + // llvm::APSInt readAPSInt(); (inherited)
>> +
>> + /// Read a floating-point value, advancing Idx.
>> + llvm::APFloat readAPFloat(const llvm::fltSemantics &Sem);
>> +
>> + /// Read a boolean value, advancing Idx.
>> + bool readBool() { return readInt() != 0; }
>> +
>> + /// Read a 32-bit unsigned value; required to satisfy BasicReader.
>> + uint32_t readUInt32() {
>> + return uint32_t(readInt());
>> + }
>> +
>> + /// Read a 64-bit unsigned value; required to satisfy BasicReader.
>> + uint64_t readUInt64() {
>> + return readInt();
>> + }
>> +
>> + /// Read a string, advancing Idx.
>> + std::string readString() {
>> + return Reader->ReadString(Record, Idx);
>> + }
>> +
>> + /// Read a path, advancing Idx.
>> + std::string readPath() {
>> + return Reader->ReadPath(*F, Record, Idx);
>> + }
>> +
>> + /// Read a version tuple, advancing Idx.
>> + VersionTuple readVersionTuple() {
>> + return ASTReader::ReadVersionTuple(Record, Idx);
>> + }
>> +
>> + /// Reads one attribute from the current stream position,
>> advancing Idx.
>> + Attr *readAttr();
>> +
>> + /// Reads attributes from the current stream position, advancing
>> Idx.
>> + void readAttributes(AttrVec &Attrs);
>> +
>> + /// Reads a token out of a record, advancing Idx.
>> + Token readToken() {
>> + return Reader->ReadToken(*F, Record, Idx);
>> + }
>> +
>> + void recordSwitchCaseID(SwitchCase *SC, unsigned ID) {
>> + Reader->RecordSwitchCaseID(SC, ID);
>> + }
>> +
>> + /// Retrieve the switch-case statement with the given ID.
>> + SwitchCase *getSwitchCaseWithID(unsigned ID) {
>> + return Reader->getSwitchCaseWithID(ID);
>> + }
>> +};
>> +
>> +/// Helper class that saves the current stream position and
>> +/// then restores it when destroyed.
>> +struct SavedStreamPosition {
>> + explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor)
>> + : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) {}
>> +
>> + ~SavedStreamPosition() {
>> + if (llvm::Error Err = Cursor.JumpToBit(Offset))
>> + llvm::report_fatal_error(
>> + "Cursor should always be able to go back, failed: " +
>> + toString(std::move(Err)));
>> + }
>> +
>> +private:
>> + llvm::BitstreamCursor &Cursor;
>> + uint64_t Offset;
>> +};
>> +
>> +inline void PCHValidator::Error(const char *Msg) {
>> + Reader.Error(Msg);
>> +}
>> +
>> +} // namespace clang
>> +
>> +#endif
>>
>> diff --git a/clang/lib/Serialization/ASTReader.cpp
>> b/clang/lib/Serialization/ASTReader.cpp
>> index c85cfcd3a33f..a2e4e7b469c9 100644
>> --- a/clang/lib/Serialization/ASTReader.cpp
>> +++ b/clang/lib/Serialization/ASTReader.cpp
>> @@ -10,7 +10,7 @@
>> //
>>
>> //===----------------------------------------------------------------------===//
>>
>> -#include "clang/Serialization/ASTReader.h"
>> +#include "clang/Serialization/ASTRecordReader.h"
>> #include "ASTCommon.h"
>> #include "ASTReaderInternals.h"
>> #include "clang/AST/AbstractTypeReader.h"
>> @@ -30,6 +30,7 @@
>> #include "clang/AST/ExprCXX.h"
>> #include "clang/AST/ExternalASTSource.h"
>> #include "clang/AST/NestedNameSpecifier.h"
>> +#include "clang/AST/OpenMPClause.h"
>> #include "clang/AST/ODRHash.h"
>> #include "clang/AST/RawCommentList.h"
>> #include "clang/AST/TemplateBase.h"
>> @@ -11471,6 +11472,31 @@ Expected<unsigned>
>> ASTRecordReader::readRecord(llvm::BitstreamCursor &Cursor,
>> //// OMPClauseReader implementation
>>
>> ////===----------------------------------------------------------------------===//
>>
>> +// This has to be in namespace clang because it's friended by all
>> +// of the OMP clauses.
>> +namespace clang {
>> +
>> +class OMPClauseReader : public OMPClauseVisitor<OMPClauseReader> {
>> + ASTRecordReader &Record;
>> + ASTContext &Context;
>> +
>> +public:
>> + OMPClauseReader(ASTRecordReader &Record)
>> + : Record(Record), Context(Record.getContext()) {}
>> +
>> +#define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C);
>> +#include "clang/Basic/OpenMPKinds.def"
>> + OMPClause *readClause();
>> + void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C);
>> + void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C);
>> +};
>> +
>> +} // end namespace clang
>> +
>> +OMPClause *ASTRecordReader::readOMPClause() {
>> + return OMPClauseReader(*this).readClause();
>> +}
>> +
>> OMPClause *OMPClauseReader::readClause() {
>> OMPClause *C = nullptr;
>> switch (Record.readInt()) {
>>
>> diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp
>> b/clang/lib/Serialization/ASTReaderDecl.cpp
>> index 229bea8b031f..0240984d75a5 100644
>> --- a/clang/lib/Serialization/ASTReaderDecl.cpp
>> +++ b/clang/lib/Serialization/ASTReaderDecl.cpp
>> @@ -48,7 +48,7 @@
>> #include "clang/Basic/Specifiers.h"
>> #include "clang/Sema/IdentifierResolver.h"
>> #include "clang/Serialization/ASTBitCodes.h"
>> -#include "clang/Serialization/ASTReader.h"
>> +#include "clang/Serialization/ASTRecordReader.h"
>> #include "clang/Serialization/ContinuousRangeMap.h"
>> #include "clang/Serialization/ModuleFile.h"
>> #include "llvm/ADT/DenseMap.h"
>> @@ -2630,9 +2630,8 @@ void
>> ASTDeclReader::VisitOMPAllocateDecl(OMPAllocateDecl *D) {
>> D->setVars(Vars);
>> SmallVector<OMPClause *, 8> Clauses;
>> Clauses.reserve(NumClauses);
>> - OMPClauseReader ClauseReader(Record);
>> for (unsigned I = 0; I != NumClauses; ++I)
>> - Clauses.push_back(ClauseReader.readClause());
>> + Clauses.push_back(Record.readOMPClause());
>> D->setClauses(Clauses);
>> }
>>
>> @@ -2641,9 +2640,8 @@ void
>> ASTDeclReader::VisitOMPRequiresDecl(OMPRequiresDecl * D) {
>> unsigned NumClauses = D->clauselist_size();
>> SmallVector<OMPClause *, 8> Clauses;
>> Clauses.reserve(NumClauses);
>> - OMPClauseReader ClauseReader(Record);
>> for (unsigned I = 0; I != NumClauses; ++I)
>> - Clauses.push_back(ClauseReader.readClause());
>> + Clauses.push_back(Record.readOMPClause());
>> D->setClauses(Clauses);
>> }
>>
>> @@ -2674,9 +2672,8 @@ void
>> ASTDeclReader::VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D) {
>> unsigned NumClauses = D->clauselist_size();
>> SmallVector<OMPClause *, 8> Clauses;
>> Clauses.reserve(NumClauses);
>> - OMPClauseReader ClauseReader(Record);
>> for (unsigned I = 0; I != NumClauses; ++I)
>> - Clauses.push_back(ClauseReader.readClause());
>> + Clauses.push_back(Record.readOMPClause());
>> D->setClauses(Clauses);
>> }
>>
>>
>> diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp
>> b/clang/lib/Serialization/ASTReaderStmt.cpp
>> index 5d7c6762061c..533502116ed7 100644
>> --- a/clang/lib/Serialization/ASTReaderStmt.cpp
>> +++ b/clang/lib/Serialization/ASTReaderStmt.cpp
>> @@ -11,7 +11,7 @@
>> //
>>
>> //===----------------------------------------------------------------------===//
>>
>> -#include "clang/Serialization/ASTReader.h"
>> +#include "clang/Serialization/ASTRecordReader.h"
>> #include "clang/AST/ASTConcept.h"
>> #include "clang/AST/ASTContext.h"
>> #include "clang/AST/AttrIterator.h"
>> @@ -67,8 +67,6 @@ using namespace serialization;
>> namespace clang {
>>
>> class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
>> - friend class OMPClauseReader;
>> -
>> ASTRecordReader &Record;
>> llvm::BitstreamCursor &DeclsCursor;
>>
>> @@ -2026,10 +2024,9 @@ void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr
>> *E) {
>> void
>> ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective
>> *E) {
>> E->setLocStart(readSourceLocation());
>> E->setLocEnd(readSourceLocation());
>> - OMPClauseReader ClauseReader(Record);
>> SmallVector<OMPClause *, 5> Clauses;
>> for (unsigned i = 0; i < E->getNumClauses(); ++i)
>> - Clauses.push_back(ClauseReader.readClause());
>> + Clauses.push_back(Record.readOMPClause());
>> E->setClauses(Clauses);
>> if (E->hasAssociatedStmt())
>> E->setAssociatedStmt(Record.readSubStmt());
>>
>> diff --git a/clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
>> b/clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
>> index 687fda75db48..7baae6778ebd 100644
>> --- a/clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
>> +++ b/clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
>> @@ -11,6 +11,7 @@
>> #include "clang/Basic/IdentifierTable.h"
>> #include "clang/Basic/LangStandard.h"
>> #include "clang/Basic/Stack.h"
>> +#include "clang/AST/DeclObjC.h"
>> #include "clang/Frontend/ASTUnit.h"
>> #include "clang/Frontend/CompilerInstance.h"
>> #include "clang/Frontend/FrontendAction.h"
>>
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
More information about the cfe-commits
mailing list