diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2013-02-01 08:13:20 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2013-02-01 08:13:20 +0000 |
commit | cd0655b17249c4c4908ca91462657f62285017e6 (patch) | |
tree | f591e7ddc3ef7fdc95b065a9ae56a34d7b42c906 /lib/Serialization | |
parent | be507b6e72df8ab5e7d8c31eb4453e1bdf5fcfaf (diff) |
Add a new -Wundefined-inline warning for inline functions which are used but not
defined. Fixes PR14993!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174158 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization')
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 21 | ||||
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 18 |
2 files changed, 19 insertions, 20 deletions
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index d38b5308de..1524da9bd6 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -2462,19 +2462,19 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) { KnownNamespaces.push_back(getGlobalDeclID(F, Record[I])); break; - case UNDEFINED_INTERNALS: - if (UndefinedInternals.size() % 2 != 0) { - Error("Invalid existing UndefinedInternals"); + case UNDEFINED_BUT_USED: + if (UndefinedButUsed.size() % 2 != 0) { + Error("Invalid existing UndefinedButUsed"); return true; } if (Record.size() % 2 != 0) { - Error("invalid undefined internals record"); + Error("invalid undefined-but-used record"); return true; } for (unsigned I = 0, N = Record.size(); I != N; /* in loop */) { - UndefinedInternals.push_back(getGlobalDeclID(F, Record[I++])); - UndefinedInternals.push_back( + UndefinedButUsed.push_back(getGlobalDeclID(F, Record[I++])); + UndefinedButUsed.push_back( ReadSourceLocation(F, Record, I).getRawEncoding()); } break; @@ -5962,16 +5962,15 @@ void ASTReader::ReadKnownNamespaces( } } -void ASTReader::ReadUndefinedInternals( +void ASTReader::ReadUndefinedButUsed( llvm::DenseMap<NamedDecl*, SourceLocation> &Undefined) { - for (unsigned Idx = 0, N = UndefinedInternals.size(); Idx != N;) { - NamedDecl *D = cast<NamedDecl>(GetDecl(UndefinedInternals[Idx++])); + for (unsigned Idx = 0, N = UndefinedButUsed.size(); Idx != N;) { + NamedDecl *D = cast<NamedDecl>(GetDecl(UndefinedButUsed[Idx++])); SourceLocation Loc = - SourceLocation::getFromRawEncoding(UndefinedInternals[Idx++]); + SourceLocation::getFromRawEncoding(UndefinedButUsed[Idx++]); Undefined.insert(std::make_pair(D, Loc)); } } - void ASTReader::ReadTentativeDefinitions( SmallVectorImpl<VarDecl *> &TentativeDefs) { diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 8120799c11..2d975466b5 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -824,7 +824,7 @@ void ASTWriter::WriteBlockInfoBlock() { RECORD(OPENCL_EXTENSIONS); RECORD(DELEGATING_CTORS); RECORD(KNOWN_NAMESPACES); - RECORD(UNDEFINED_INTERNALS); + RECORD(UNDEFINED_BUT_USED); RECORD(MODULE_OFFSET_MAP); RECORD(SOURCE_MANAGER_LINE_TABLE); RECORD(OBJC_CATEGORIES_MAP); @@ -3588,15 +3588,15 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, AddDeclRef(I->first, KnownNamespaces); } - // Build a record of all used, undefined objects with internal linkage. - RecordData UndefinedInternals; + // Build a record of all used, undefined objects that require definitions. + RecordData UndefinedButUsed; SmallVector<std::pair<NamedDecl *, SourceLocation>, 16> Undefined; - SemaRef.getUndefinedInternals(Undefined); + SemaRef.getUndefinedButUsed(Undefined); for (SmallVectorImpl<std::pair<NamedDecl *, SourceLocation> >::iterator I = Undefined.begin(), E = Undefined.end(); I != E; ++I) { - AddDeclRef(I->first, UndefinedInternals); - AddSourceLocation(I->second, UndefinedInternals); + AddDeclRef(I->first, UndefinedButUsed); + AddSourceLocation(I->second, UndefinedButUsed); } // Write the control block @@ -3814,9 +3814,9 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, if (!KnownNamespaces.empty()) Stream.EmitRecord(KNOWN_NAMESPACES, KnownNamespaces); - // Write the undefined internal functions and variables. - if (!UndefinedInternals.empty()) - Stream.EmitRecord(UNDEFINED_INTERNALS, UndefinedInternals); + // Write the undefined internal functions and variables, and inline functions. + if (!UndefinedButUsed.empty()) + Stream.EmitRecord(UNDEFINED_BUT_USED, UndefinedButUsed); // Write the visible updates to DeclContexts. for (llvm::SmallPtrSet<const DeclContext *, 16>::iterator |