mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-11 17:08:42 +00:00
[modules] When instantiating the contents of an imported CXXRecordDecl, we can
emit lexical contents for a declaration for another module. Track which module those contents came from, and ensure that we only grab the lexical contents from a single such instantiation. llvm-svn: 244682
This commit is contained in:
parent
c6f0468937
commit
9c9173dcc8
@ -499,7 +499,8 @@ private:
|
||||
typedef ArrayRef<llvm::support::unaligned_uint32_t> LexicalContents;
|
||||
|
||||
/// \brief Map from a DeclContext to its lexical contents.
|
||||
llvm::DenseMap<const DeclContext*, LexicalContents> LexicalDecls;
|
||||
llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>>
|
||||
LexicalDecls;
|
||||
|
||||
/// \brief Map from the TU to its lexical contents from each module file.
|
||||
std::vector<std::pair<ModuleFile*, LexicalContents>> TULexicalDecls;
|
||||
|
@ -975,11 +975,18 @@ bool ASTReader::ReadLexicalDeclContextStorage(ModuleFile &M,
|
||||
|
||||
assert(!isa<TranslationUnitDecl>(DC) &&
|
||||
"expected a TU_UPDATE_LEXICAL record for TU");
|
||||
// FIXME: Once we remove RewriteDecl, assert that we didn't already have
|
||||
// lexical decls for this context.
|
||||
LexicalDecls[DC] = llvm::makeArrayRef(
|
||||
reinterpret_cast<const llvm::support::unaligned_uint32_t *>(Blob.data()),
|
||||
Blob.size() / 4);
|
||||
// If we are handling a C++ class template instantiation, we can see multiple
|
||||
// lexical updates for the same record. It's important that we select only one
|
||||
// of them, so that field numbering works properly. Just pick the first one we
|
||||
// see.
|
||||
auto &Lex = LexicalDecls[DC];
|
||||
if (!Lex.first) {
|
||||
Lex = std::make_pair(
|
||||
&M, llvm::makeArrayRef(
|
||||
reinterpret_cast<const llvm::support::unaligned_uint32_t *>(
|
||||
Blob.data()),
|
||||
Blob.size() / 4));
|
||||
}
|
||||
DC->setHasExternalLexicalStorage(true);
|
||||
return false;
|
||||
}
|
||||
@ -6253,7 +6260,7 @@ void ASTReader::FindExternalLexicalDecls(
|
||||
} else {
|
||||
auto I = LexicalDecls.find(DC);
|
||||
if (I != LexicalDecls.end())
|
||||
Visit(getOwningModuleFile(cast<Decl>(DC)), I->second);
|
||||
Visit(I->second.first, I->second.second);
|
||||
}
|
||||
|
||||
++NumLexicalDeclContextsRead;
|
||||
|
@ -38,6 +38,10 @@ int defineListDoubleRight() {
|
||||
return ld.size;
|
||||
}
|
||||
|
||||
inline void defineListLongRight() {
|
||||
List<long> ll;
|
||||
}
|
||||
|
||||
template<typename T> struct MergePatternDecl;
|
||||
|
||||
void outOfLineInlineUseRightF(void (OutOfLineInline<int>::*)() = &OutOfLineInline<int>::f);
|
||||
|
@ -10,6 +10,7 @@ public:
|
||||
};
|
||||
|
||||
extern List<double> *instantiateListDoubleDeclaration;
|
||||
extern List<long> *instantiateListLongDeclaration;
|
||||
|
||||
namespace A {
|
||||
class Y {
|
||||
|
@ -28,6 +28,8 @@ void testTemplateClasses() {
|
||||
N::Set<char> set_char;
|
||||
set_char.insert('A');
|
||||
|
||||
static_assert(sizeof(List<long>) == sizeof(List<short>), "");
|
||||
|
||||
List<double> list_double;
|
||||
list_double.push_back(0.0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user