Skip to content

Commit 8f63ab5

Browse files
committed
move attribute reading to PCHReaderDecl.cpp, remove some
extraneous braces. llvm-svn: 70191
1 parent 1de76db commit 8f63ab5

File tree

2 files changed

+165
-212
lines changed

2 files changed

+165
-212
lines changed

clang/lib/Frontend/PCHReader.cpp

Lines changed: 0 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,140 +1711,6 @@ std::string PCHReader::ReadString(const RecordData &Record, unsigned &Idx) {
17111711
return Result;
17121712
}
17131713

1714-
/// \brief Reads attributes from the current stream position.
1715-
Attr *PCHReader::ReadAttributes() {
1716-
unsigned Code = DeclsCursor.ReadCode();
1717-
assert(Code == llvm::bitc::UNABBREV_RECORD &&
1718-
"Expected unabbreviated record"); (void)Code;
1719-
1720-
RecordData Record;
1721-
unsigned Idx = 0;
1722-
unsigned RecCode = DeclsCursor.ReadRecord(Code, Record);
1723-
assert(RecCode == pch::DECL_ATTR && "Expected attribute record");
1724-
(void)RecCode;
1725-
1726-
#define SIMPLE_ATTR(Name) \
1727-
case Attr::Name: \
1728-
New = ::new (Context) Name##Attr(); \
1729-
break
1730-
1731-
#define STRING_ATTR(Name) \
1732-
case Attr::Name: \
1733-
New = ::new (Context) Name##Attr(ReadString(Record, Idx)); \
1734-
break
1735-
1736-
#define UNSIGNED_ATTR(Name) \
1737-
case Attr::Name: \
1738-
New = ::new (Context) Name##Attr(Record[Idx++]); \
1739-
break
1740-
1741-
Attr *Attrs = 0;
1742-
while (Idx < Record.size()) {
1743-
Attr *New = 0;
1744-
Attr::Kind Kind = (Attr::Kind)Record[Idx++];
1745-
bool IsInherited = Record[Idx++];
1746-
1747-
switch (Kind) {
1748-
STRING_ATTR(Alias);
1749-
UNSIGNED_ATTR(Aligned);
1750-
SIMPLE_ATTR(AlwaysInline);
1751-
SIMPLE_ATTR(AnalyzerNoReturn);
1752-
STRING_ATTR(Annotate);
1753-
STRING_ATTR(AsmLabel);
1754-
1755-
case Attr::Blocks:
1756-
New = ::new (Context) BlocksAttr(
1757-
(BlocksAttr::BlocksAttrTypes)Record[Idx++]);
1758-
break;
1759-
1760-
case Attr::Cleanup:
1761-
New = ::new (Context) CleanupAttr(
1762-
cast<FunctionDecl>(GetDecl(Record[Idx++])));
1763-
break;
1764-
1765-
SIMPLE_ATTR(Const);
1766-
UNSIGNED_ATTR(Constructor);
1767-
SIMPLE_ATTR(DLLExport);
1768-
SIMPLE_ATTR(DLLImport);
1769-
SIMPLE_ATTR(Deprecated);
1770-
UNSIGNED_ATTR(Destructor);
1771-
SIMPLE_ATTR(FastCall);
1772-
1773-
case Attr::Format: {
1774-
std::string Type = ReadString(Record, Idx);
1775-
unsigned FormatIdx = Record[Idx++];
1776-
unsigned FirstArg = Record[Idx++];
1777-
New = ::new (Context) FormatAttr(Type, FormatIdx, FirstArg);
1778-
break;
1779-
}
1780-
1781-
SIMPLE_ATTR(GNUInline);
1782-
1783-
case Attr::IBOutletKind:
1784-
New = ::new (Context) IBOutletAttr();
1785-
break;
1786-
1787-
SIMPLE_ATTR(NoReturn);
1788-
SIMPLE_ATTR(NoThrow);
1789-
SIMPLE_ATTR(Nodebug);
1790-
SIMPLE_ATTR(Noinline);
1791-
1792-
case Attr::NonNull: {
1793-
unsigned Size = Record[Idx++];
1794-
llvm::SmallVector<unsigned, 16> ArgNums;
1795-
ArgNums.insert(ArgNums.end(), &Record[Idx], &Record[Idx] + Size);
1796-
Idx += Size;
1797-
New = ::new (Context) NonNullAttr(&ArgNums[0], Size);
1798-
break;
1799-
}
1800-
1801-
SIMPLE_ATTR(ObjCException);
1802-
SIMPLE_ATTR(ObjCNSObject);
1803-
SIMPLE_ATTR(ObjCOwnershipRetain);
1804-
SIMPLE_ATTR(ObjCOwnershipReturns);
1805-
SIMPLE_ATTR(Overloadable);
1806-
UNSIGNED_ATTR(Packed);
1807-
SIMPLE_ATTR(Pure);
1808-
UNSIGNED_ATTR(Regparm);
1809-
STRING_ATTR(Section);
1810-
SIMPLE_ATTR(StdCall);
1811-
SIMPLE_ATTR(TransparentUnion);
1812-
SIMPLE_ATTR(Unavailable);
1813-
SIMPLE_ATTR(Unused);
1814-
SIMPLE_ATTR(Used);
1815-
1816-
case Attr::Visibility:
1817-
New = ::new (Context) VisibilityAttr(
1818-
(VisibilityAttr::VisibilityTypes)Record[Idx++]);
1819-
break;
1820-
1821-
SIMPLE_ATTR(WarnUnusedResult);
1822-
SIMPLE_ATTR(Weak);
1823-
SIMPLE_ATTR(WeakImport);
1824-
}
1825-
1826-
assert(New && "Unable to decode attribute?");
1827-
New->setInherited(IsInherited);
1828-
New->setNext(Attrs);
1829-
Attrs = New;
1830-
}
1831-
#undef UNSIGNED_ATTR
1832-
#undef STRING_ATTR
1833-
#undef SIMPLE_ATTR
1834-
1835-
// The list of attributes was built backwards. Reverse the list
1836-
// before returning it.
1837-
Attr *PrevAttr = 0, *NextAttr = 0;
1838-
while (Attrs) {
1839-
NextAttr = Attrs->getNext();
1840-
Attrs->setNext(PrevAttr);
1841-
PrevAttr = Attrs;
1842-
Attrs = NextAttr;
1843-
}
1844-
1845-
return PrevAttr;
1846-
}
1847-
18481714
DiagnosticBuilder PCHReader::Diag(unsigned DiagID) {
18491715
return Diag(SourceLocation(), DiagID);
18501716
}

0 commit comments

Comments
 (0)