aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-13 01:29:17 +0000
committerChris Lattner <sabre@nondot.org>2009-04-13 01:29:17 +0000
commitc1f9d828c733ec1eba06d01070735d1f36fda733 (patch)
tree48615af3823ebc732c7f63a75b4177c3ba02ece7 /lib/Frontend
parent1721a2dfc05d081e76d6dd4755d52c96e093dabc (diff)
implement the microsoft/gnu "__COUNTER__" macro: rdar://4329310
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68933 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend')
-rw-r--r--lib/Frontend/PCHReader.cpp6
-rw-r--r--lib/Frontend/PCHWriter.cpp10
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index b916deaa69..fa6ad6f0a0 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -318,7 +318,11 @@ bool PCHReader::ReadPreprocessorBlock() {
switch (RecType) {
default: // Default behavior: ignore unknown records.
break;
-
+ case pch::PP_COUNTER_VALUE:
+ if (!Record.empty())
+ PP.setCounterValue(Record[0]);
+ break;
+
case pch::PP_MACRO_OBJECT_LIKE:
case pch::PP_MACRO_FUNCTION_LIKE: {
IdentifierInfo *II = DecodeIdentifierInfo(Record[0]);
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index 6faf37fb29..2cf932ce9b 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -567,6 +567,13 @@ void PCHWriter::WritePreprocessor(const Preprocessor &PP) {
RecordData Record;
+ // If the preprocessor __COUNTER__ value has been bumped, remember it.
+ if (PP.getCounterValue() != 0) {
+ Record.push_back(PP.getCounterValue());
+ S.EmitRecord(pch::PP_COUNTER_VALUE, Record);
+ Record.clear();
+ }
+
// Loop over all the macro definitions that are live at the end of the file,
// emitting each to the PP section.
// FIXME: Eventually we want to emit an index so that we can lazily load
@@ -627,9 +634,6 @@ void PCHWriter::WritePreprocessor(const Preprocessor &PP) {
}
- // TODO: someday when PP supports __COUNTER__, emit a record for its value if
- // non-zero.
-
S.ExitBlock();
}