r262552 - Serialize `pragma pointers_to_members` state.
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 2 16:17:35 PST 2016
Author: nico
Date: Wed Mar 2 18:17:35 2016
New Revision: 262552
URL: http://llvm.org/viewvc/llvm-project?rev=262552&view=rev
Log:
Serialize `pragma pointers_to_members` state.
Like r262539, but for pointers_to_members.
Added:
cfe/trunk/test/PCH/pragma-pointers_to_members.cpp
Modified:
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=262552&r1=262551&r2=262552&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Wed Mar 2 18:17:35 2016
@@ -578,7 +578,10 @@ namespace clang {
DELETE_EXPRS_TO_ANALYZE = 54,
/// \brief Record code for \#pragma ms_struct options.
- MSSTRUCT_PRAGMA_OPTIONS = 55
+ MSSTRUCT_PRAGMA_OPTIONS = 55,
+
+ /// \brief Record code for \#pragma ms_struct options.
+ POINTERS_TO_MEMBERS_PRAGMA_OPTIONS = 56
};
/// \brief Record types used within a source manager block.
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=262552&r1=262551&r2=262552&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Wed Mar 2 18:17:35 2016
@@ -788,6 +788,10 @@ private:
/// \brief The PragmaMSStructKind pragma ms_struct state if set, or -1.
int PragmaMSStructState;
+ /// \brief The PragmaMSPointersToMembersKind pragma pointers_to_members state.
+ int PragmaMSPointersToMembersState;
+ SourceLocation PointersToMembersPragmaLocation;
+
/// \brief The OpenCL extension settings.
SmallVector<uint64_t, 1> OpenCLExtensions;
Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=262552&r1=262551&r2=262552&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Wed Mar 2 18:17:35 2016
@@ -552,6 +552,7 @@ private:
void WriteLateParsedTemplates(Sema &SemaRef);
void WriteOptimizePragmaOptions(Sema &SemaRef);
void WriteMSStructPragmaOptions(Sema &SemaRef);
+ void WriteMSPointersToMembersPragmaOptions(Sema &SemaRef);
void WriteModuleFileExtension(Sema &SemaRef,
ModuleFileExtensionWriter &Writer);
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=262552&r1=262551&r2=262552&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Mar 2 18:17:35 2016
@@ -3225,6 +3225,15 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
PragmaMSStructState = Record[0];
break;
+ case POINTERS_TO_MEMBERS_PRAGMA_OPTIONS:
+ if (Record.size() != 2) {
+ Error("invalid pragma ms_struct record");
+ return Failure;
+ }
+ PragmaMSPointersToMembersState = Record[0];
+ PointersToMembersPragmaLocation = ReadSourceLocation(F, Record[1]);
+ break;
+
case UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES:
for (unsigned I = 0, N = Record.size(); I != N; ++I)
UnusedLocalTypedefNameCandidates.push_back(
@@ -7012,6 +7021,12 @@ void ASTReader::UpdateSema() {
SemaObj->ActOnPragmaOptimize(/* IsOn = */ false, OptimizeOffPragmaLocation);
if (PragmaMSStructState != -1)
SemaObj->ActOnPragmaMSStruct((PragmaMSStructKind)PragmaMSStructState);
+ if (PointersToMembersPragmaLocation.isValid()) {
+ SemaObj->ActOnPragmaMSPointersToMembers(
+ (LangOptions::PragmaMSPointersToMembersKind)
+ PragmaMSPointersToMembersState,
+ PointersToMembersPragmaLocation);
+ }
}
IdentifierInfo *ASTReader::get(StringRef Name) {
@@ -8707,6 +8722,7 @@ ASTReader::ASTReader(
Consumer(nullptr), ModuleMgr(PP.getFileManager(), PCHContainerRdr),
ReadTimer(std::move(ReadTimer)),
PragmaMSStructState(-1),
+ PragmaMSPointersToMembersState(-1),
isysroot(isysroot), DisableValidation(DisableValidation),
AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
AllowConfigurationMismatch(AllowConfigurationMismatch),
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=262552&r1=262551&r2=262552&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Wed Mar 2 18:17:35 2016
@@ -961,6 +961,7 @@ void ASTWriter::WriteBlockInfoBlock() {
RECORD(LATE_PARSED_TEMPLATE);
RECORD(OPTIMIZE_PRAGMA_OPTIONS);
RECORD(MSSTRUCT_PRAGMA_OPTIONS);
+ RECORD(POINTERS_TO_MEMBERS_PRAGMA_OPTIONS);
RECORD(UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES);
RECORD(CXX_CTOR_INITIALIZERS_OFFSETS);
RECORD(DELETE_EXPRS_TO_ANALYZE);
@@ -3936,6 +3937,15 @@ void ASTWriter::WriteMSStructPragmaOptio
Stream.EmitRecord(MSSTRUCT_PRAGMA_OPTIONS, Record);
}
+/// \brief Write the state of 'pragma pointers_to_members' at the end of the
+//module.
+void ASTWriter::WriteMSPointersToMembersPragmaOptions(Sema &SemaRef) {
+ RecordData Record;
+ Record.push_back(SemaRef.MSPointerToMemberRepresentationMethod);
+ AddSourceLocation(SemaRef.ImplicitMSInheritanceAttrLoc, Record);
+ Stream.EmitRecord(POINTERS_TO_MEMBERS_PRAGMA_OPTIONS, Record);
+}
+
void ASTWriter::WriteModuleFileExtension(Sema &SemaRef,
ModuleFileExtensionWriter &Writer) {
// Enter the extension block.
@@ -4616,6 +4626,7 @@ uint64_t ASTWriter::WriteASTCore(Sema &S
if(!WritingModule) {
WriteOptimizePragmaOptions(SemaRef);
WriteMSStructPragmaOptions(SemaRef);
+ WriteMSPointersToMembersPragmaOptions(SemaRef);
}
// Some simple statistics
Added: cfe/trunk/test/PCH/pragma-pointers_to_members.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/pragma-pointers_to_members.cpp?rev=262552&view=auto
==============================================================================
--- cfe/trunk/test/PCH/pragma-pointers_to_members.cpp (added)
+++ cfe/trunk/test/PCH/pragma-pointers_to_members.cpp Wed Mar 2 18:17:35 2016
@@ -0,0 +1,34 @@
+// Test this without pch.
+// RUN: %clang_cc1 %s -Wunknown-pragmas -Werror -triple i386-pc-win32 -fms-extensions -fsyntax-only -include %s -verify -std=c++11
+
+// Test with pch.
+// RUN: %clang_cc1 %s -Wunknown-pragmas -Werror -triple i386-pc-win32 -fms-extensions -emit-pch -o %t -std=c++11
+// RUN: %clang_cc1 %s -Wunknown-pragmas -Werror -triple i386-pc-win32 -fms-extensions -fsyntax-only -include-pch %t -verify -std=c++11
+
+// The first run line creates a pch, and since at that point HEADER is not
+// defined, the only thing contained in the pch is the pragma. The second line
+// then includes that pch, so HEADER is defined and the actual code is compiled.
+// The check then makes sure that the pragma is in effect in the file that
+// includes the pch.
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+struct S0;
+static_assert(sizeof(int S0::*) == 12, "");
+
+struct S1;
+struct S2;
+
+#pragma pointers_to_members(full_generality, single_inheritance)
+
+static_assert(sizeof(int S1::*) == 4, "");
+
+#else
+
+static_assert(sizeof(int S2::*) == 4, "");
+static_assert(sizeof(int S0::*) == 12, "");
+
+#endif
More information about the cfe-commits
mailing list