Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 8856048

Browse files
committed
Revert r308327
I forgot to test clang-tools-extra which is now failing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308328 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 95c5cde commit 8856048

21 files changed

+30
-253
lines changed

include/clang/Basic/DiagnosticGroups.td

+1-2
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,8 @@ def IgnoredPragmaIntrinsic : DiagGroup<"ignored-pragma-intrinsic">;
467467
def UnknownPragmas : DiagGroup<"unknown-pragmas">;
468468
def IgnoredPragmas : DiagGroup<"ignored-pragmas", [IgnoredPragmaIntrinsic]>;
469469
def PragmaClangAttribute : DiagGroup<"pragma-clang-attribute">;
470-
def PragmaPack : DiagGroup<"pragma-pack">;
471470
def Pragmas : DiagGroup<"pragmas", [UnknownPragmas, IgnoredPragmas,
472-
PragmaClangAttribute, PragmaPack]>;
471+
PragmaClangAttribute]>;
473472
def UnknownWarningOption : DiagGroup<"unknown-warning-option">;
474473
def NSobjectAttribute : DiagGroup<"NSObject-attribute">;
475474
def IndependentClassAttribute : DiagGroup<"IndependentClass-attribute">;

include/clang/Basic/DiagnosticSemaKinds.td

-10
Original file line numberDiff line numberDiff line change
@@ -712,16 +712,6 @@ def err_pragma_options_align_mac68k_target_unsupported : Error<
712712
def warn_pragma_pack_invalid_alignment : Warning<
713713
"expected #pragma pack parameter to be '1', '2', '4', '8', or '16'">,
714714
InGroup<IgnoredPragmas>;
715-
def warn_pragma_pack_non_default_at_include : Warning<
716-
"non-default #pragma pack value might change the alignment of struct or "
717-
"union members in the included file">, InGroup<PragmaPack>;
718-
def warn_pragma_pack_modified_after_include : Warning<
719-
"the current #pragma pack aligment value is modified in the included "
720-
"file">, InGroup<PragmaPack>;
721-
def warn_pragma_pack_no_pop_eof : Warning<"unterminated "
722-
"'#pragma pack (push, ...)' at end of file">, InGroup<PragmaPack>;
723-
def note_pragma_pack_here : Note<
724-
"previous '#pragma pack' directive that modifies alignment is here">;
725715
// Follow the Microsoft implementation.
726716
def warn_pragma_pack_show : Warning<"value of #pragma pack(show) == %0">;
727717
def warn_pragma_pack_pop_identifer_and_alignment : Warning<

include/clang/Sema/Sema.h

+5-26
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ namespace sema {
208208
class FunctionScopeInfo;
209209
class LambdaScopeInfo;
210210
class PossiblyUnreachableDiag;
211-
class SemaPPCallbacks;
212211
class TemplateDeductionInfo;
213212
}
214213

@@ -382,12 +381,11 @@ class Sema {
382381
llvm::StringRef StackSlotLabel;
383382
ValueType Value;
384383
SourceLocation PragmaLocation;
385-
SourceLocation PragmaPushLocation;
386-
Slot(llvm::StringRef StackSlotLabel, ValueType Value,
387-
SourceLocation PragmaLocation, SourceLocation PragmaPushLocation)
388-
: StackSlotLabel(StackSlotLabel), Value(Value),
389-
PragmaLocation(PragmaLocation),
390-
PragmaPushLocation(PragmaPushLocation) {}
384+
Slot(llvm::StringRef StackSlotLabel,
385+
ValueType Value,
386+
SourceLocation PragmaLocation)
387+
: StackSlotLabel(StackSlotLabel), Value(Value),
388+
PragmaLocation(PragmaLocation) {}
391389
};
392390
void Act(SourceLocation PragmaLocation,
393391
PragmaMsStackAction Action,
@@ -418,8 +416,6 @@ class Sema {
418416
explicit PragmaStack(const ValueType &Default)
419417
: DefaultValue(Default), CurrentValue(Default) {}
420418

421-
bool hasValue() const { return CurrentValue != DefaultValue; }
422-
423419
SmallVector<Slot, 2> Stack;
424420
ValueType DefaultValue; // Value used for PSK_Reset action.
425421
ValueType CurrentValue;
@@ -441,8 +437,6 @@ class Sema {
441437
// Sentinel to represent when the stack is set to mac68k alignment.
442438
static const unsigned kMac68kAlignmentSentinel = ~0U;
443439
PragmaStack<unsigned> PackStack;
444-
// The current #pragma pack values and locations at each #include.
445-
SmallVector<std::pair<unsigned, SourceLocation>, 8> PackIncludeStack;
446440
// Segment #pragmas.
447441
PragmaStack<StringLiteral *> DataSegStack;
448442
PragmaStack<StringLiteral *> BSSSegStack;
@@ -8191,15 +8185,6 @@ class Sema {
81918185
void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
81928186
StringRef SlotLabel, Expr *Alignment);
81938187

8194-
enum class PragmaPackDiagnoseKind {
8195-
NonDefaultStateAtInclude,
8196-
ChangedStateAtExit
8197-
};
8198-
8199-
void DiagnoseNonDefaultPragmaPack(PragmaPackDiagnoseKind Kind,
8200-
SourceLocation IncludeLoc);
8201-
void DiagnoseUnterminatedPragmaPack();
8202-
82038188
/// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
82048189
void ActOnPragmaMSStruct(PragmaMSStructKind Kind);
82058190

@@ -10393,12 +10378,6 @@ class Sema {
1039310378

1039410379
IdentifierInfo *Ident_NSError = nullptr;
1039510380

10396-
/// \brief The handler for the FileChanged preprocessor events.
10397-
///
10398-
/// Used for diagnostics that implement custom semantic analysis for #include
10399-
/// directives, like -Wpragma-pack.
10400-
sema::SemaPPCallbacks *SemaPPCallbackHandler;
10401-
1040210381
protected:
1040310382
friend class Parser;
1040410383
friend class InitializationSequence;

include/clang/Serialization/ASTReader.h

-1
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,6 @@ class ASTReader
825825
struct PragmaPackStackEntry {
826826
unsigned Value;
827827
SourceLocation Location;
828-
SourceLocation PushLocation;
829828
StringRef SlotLabel;
830829
};
831830
llvm::SmallVector<PragmaPackStackEntry, 2> PragmaPackStack;

lib/Parse/ParsePragma.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -422,20 +422,15 @@ void Parser::HandlePragmaPack() {
422422
assert(Tok.is(tok::annot_pragma_pack));
423423
PragmaPackInfo *Info =
424424
static_cast<PragmaPackInfo *>(Tok.getAnnotationValue());
425-
SourceLocation PragmaLoc = Tok.getLocation();
425+
SourceLocation PragmaLoc = ConsumeAnnotationToken();
426426
ExprResult Alignment;
427427
if (Info->Alignment.is(tok::numeric_constant)) {
428428
Alignment = Actions.ActOnNumericConstant(Info->Alignment);
429-
if (Alignment.isInvalid()) {
430-
ConsumeAnnotationToken();
429+
if (Alignment.isInvalid())
431430
return;
432-
}
433431
}
434432
Actions.ActOnPragmaPack(PragmaLoc, Info->Action, Info->SlotLabel,
435433
Alignment.get());
436-
// Consume the token after processing the pragma to enable pragma-specific
437-
// #include warnings.
438-
ConsumeAnnotationToken();
439434
}
440435

441436
void Parser::HandlePragmaMSStruct() {

lib/Sema/Sema.cpp

-54
Original file line numberDiff line numberDiff line change
@@ -70,49 +70,6 @@ void Sema::ActOnTranslationUnitScope(Scope *S) {
7070
PushDeclContext(S, Context.getTranslationUnitDecl());
7171
}
7272

73-
namespace clang {
74-
namespace sema {
75-
76-
class SemaPPCallbacks : public PPCallbacks {
77-
Sema *S = nullptr;
78-
llvm::SmallVector<SourceLocation, 8> IncludeStack;
79-
80-
public:
81-
void set(Sema &S) { this->S = &S; }
82-
83-
void reset() { S = nullptr; }
84-
85-
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
86-
SrcMgr::CharacteristicKind FileType,
87-
FileID PrevFID) override {
88-
if (!S)
89-
return;
90-
switch (Reason) {
91-
case EnterFile: {
92-
SourceManager &SM = S->getSourceManager();
93-
SourceLocation IncludeLoc = SM.getIncludeLoc(SM.getFileID(Loc));
94-
if (IncludeLoc.isValid()) {
95-
IncludeStack.push_back(IncludeLoc);
96-
S->DiagnoseNonDefaultPragmaPack(
97-
Sema::PragmaPackDiagnoseKind::NonDefaultStateAtInclude, IncludeLoc);
98-
}
99-
break;
100-
}
101-
case ExitFile:
102-
if (!IncludeStack.empty())
103-
S->DiagnoseNonDefaultPragmaPack(
104-
Sema::PragmaPackDiagnoseKind::ChangedStateAtExit,
105-
IncludeStack.pop_back_val());
106-
break;
107-
default:
108-
break;
109-
}
110-
}
111-
};
112-
113-
} // end namespace sema
114-
} // end namespace clang
115-
11673
Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
11774
TranslationUnitKind TUKind, CodeCompleteConsumer *CodeCompleter)
11875
: ExternalSource(nullptr), isMultiplexExternalSource(false),
@@ -165,12 +122,6 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
165122

166123
// Initilization of data sharing attributes stack for OpenMP
167124
InitDataSharingAttributesStack();
168-
169-
std::unique_ptr<sema::SemaPPCallbacks> Callbacks =
170-
llvm::make_unique<sema::SemaPPCallbacks>();
171-
SemaPPCallbackHandler = Callbacks.get();
172-
PP.addPPCallbacks(std::move(Callbacks));
173-
SemaPPCallbackHandler->set(*this);
174125
}
175126

176127
void Sema::addImplicitTypedef(StringRef Name, QualType T) {
@@ -355,10 +306,6 @@ Sema::~Sema() {
355306
// Destroys data sharing attributes stack for OpenMP
356307
DestroyDataSharingAttributesStack();
357308

358-
// Detach from the PP callback handler which outlives Sema since it's owned
359-
// by the preprocessor.
360-
SemaPPCallbackHandler->reset();
361-
362309
assert(DelayedTypos.empty() && "Uncorrected typos!");
363310
}
364311

@@ -819,7 +766,6 @@ void Sema::ActOnEndOfTranslationUnit() {
819766
CheckDelayedMemberExceptionSpecs();
820767
}
821768

822-
DiagnoseUnterminatedPragmaPack();
823769
DiagnoseUnterminatedPragmaAttribute();
824770

825771
// All delayed member exception specs should be checked or we end up accepting

lib/Sema/SemaAttr.cpp

+1-36
Original file line numberDiff line numberDiff line change
@@ -202,40 +202,6 @@ void Sema::ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
202202
PackStack.Act(PragmaLoc, Action, SlotLabel, AlignmentVal);
203203
}
204204

205-
void Sema::DiagnoseNonDefaultPragmaPack(PragmaPackDiagnoseKind Kind,
206-
SourceLocation IncludeLoc) {
207-
if (Kind == PragmaPackDiagnoseKind::NonDefaultStateAtInclude) {
208-
SourceLocation PrevLocation = PackStack.CurrentPragmaLocation;
209-
// Warn about non-default alignment at #includes (without redundant
210-
// warnings for the same directive in nested includes).
211-
if (PackStack.hasValue() &&
212-
(PackIncludeStack.empty() ||
213-
PackIncludeStack.back().second != PrevLocation)) {
214-
Diag(IncludeLoc, diag::warn_pragma_pack_non_default_at_include);
215-
Diag(PrevLocation, diag::note_pragma_pack_here);
216-
}
217-
PackIncludeStack.push_back(
218-
{PackStack.CurrentValue,
219-
PackStack.hasValue() ? PrevLocation : SourceLocation()});
220-
return;
221-
}
222-
223-
assert(Kind == PragmaPackDiagnoseKind::ChangedStateAtExit && "invalid kind");
224-
unsigned PreviousValue = PackIncludeStack.pop_back_val().first;
225-
// Warn about modified alignment after #includes.
226-
if (PreviousValue != PackStack.CurrentValue) {
227-
Diag(IncludeLoc, diag::warn_pragma_pack_modified_after_include);
228-
Diag(PackStack.CurrentPragmaLocation, diag::note_pragma_pack_here);
229-
}
230-
}
231-
232-
void Sema::DiagnoseUnterminatedPragmaPack() {
233-
if (PackStack.Stack.empty())
234-
return;
235-
for (const auto &StackSlot : llvm::reverse(PackStack.Stack))
236-
Diag(StackSlot.PragmaPushLocation, diag::warn_pragma_pack_no_pop_eof);
237-
}
238-
239205
void Sema::ActOnPragmaMSStruct(PragmaMSStructKind Kind) {
240206
MSStructPragmaOn = (Kind == PMSST_ON);
241207
}
@@ -283,8 +249,7 @@ void Sema::PragmaStack<ValueType>::Act(SourceLocation PragmaLocation,
283249
return;
284250
}
285251
if (Action & PSK_Push)
286-
Stack.emplace_back(StackSlotLabel, CurrentValue, CurrentPragmaLocation,
287-
PragmaLocation);
252+
Stack.push_back(Slot(StackSlotLabel, CurrentValue, CurrentPragmaLocation));
288253
else if (Action & PSK_Pop) {
289254
if (!StackSlotLabel.empty()) {
290255
// If we've got a label, try to find it and jump there.

lib/Serialization/ASTReader.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -3384,7 +3384,6 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
33843384
PragmaPackStackEntry Entry;
33853385
Entry.Value = Record[Idx++];
33863386
Entry.Location = ReadSourceLocation(F, Record[Idx++]);
3387-
Entry.PushLocation = ReadSourceLocation(F, Record[Idx++]);
33883387
PragmaPackStrings.push_back(ReadString(Record, Idx));
33893388
Entry.SlotLabel = PragmaPackStrings.back();
33903389
PragmaPackStack.push_back(Entry);
@@ -7580,14 +7579,13 @@ void ASTReader::UpdateSema() {
75807579
"Expected a default alignment value");
75817580
SemaObj->PackStack.Stack.emplace_back(
75827581
PragmaPackStack.front().SlotLabel, SemaObj->PackStack.CurrentValue,
7583-
SemaObj->PackStack.CurrentPragmaLocation,
7584-
PragmaPackStack.front().PushLocation);
7582+
SemaObj->PackStack.CurrentPragmaLocation);
75857583
DropFirst = true;
75867584
}
75877585
for (const auto &Entry :
75887586
llvm::makeArrayRef(PragmaPackStack).drop_front(DropFirst ? 1 : 0))
75897587
SemaObj->PackStack.Stack.emplace_back(Entry.SlotLabel, Entry.Value,
7590-
Entry.Location, Entry.PushLocation);
7588+
Entry.Location);
75917589
if (PragmaPackCurrentLocation.isInvalid()) {
75927590
assert(*PragmaPackCurrentValue == SemaObj->PackStack.DefaultValue &&
75937591
"Expected a default alignment value");

lib/Serialization/ASTWriter.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -4295,7 +4295,6 @@ void ASTWriter::WritePackPragmaOptions(Sema &SemaRef) {
42954295
for (const auto &StackEntry : SemaRef.PackStack.Stack) {
42964296
Record.push_back(StackEntry.Value);
42974297
AddSourceLocation(StackEntry.PragmaLocation, Record);
4298-
AddSourceLocation(StackEntry.PragmaPushLocation, Record);
42994298
AddString(StackEntry.StackSlotLabel, Record);
43004299
}
43014300
Stream.EmitRecord(PACK_PRAGMA_OPTIONS, Record);

test/OpenMP/declare_simd_messages.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -x c++ -std=c++11 -fms-extensions -Wno-pragma-pack %s
1+
// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -x c++ -std=c++11 -fms-extensions %s
22

33
// expected-error@+1 {{expected an OpenMP directive}}
44
#pragma omp declare

test/PCH/pragma-pack.c

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
// Test this without pch.
2-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -include %s -verify -fsyntax-only -Wno-pragma-pack -DSET
3-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -include %s -verify -fsyntax-only -Wno-pragma-pack -DRESET
4-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -include %s -verify -fsyntax-only -Wno-pragma-pack -DPUSH
5-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -include %s -verify -fsyntax-only -Wno-pragma-pack -DPUSH_POP
6-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -include %s -verify -fsyntax-only -Wno-pragma-pack -DPUSH_POP_LABEL
2+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -include %s -verify -fsyntax-only -DSET
3+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -include %s -verify -fsyntax-only -DRESET
4+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -include %s -verify -fsyntax-only -DPUSH
5+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -include %s -verify -fsyntax-only -DPUSH_POP
6+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -include %s -verify -fsyntax-only -DPUSH_POP_LABEL
77

88
// Test with pch.
9-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -Wno-pragma-pack -DSET -emit-pch -o %t
10-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -Wno-pragma-pack -DSET -verify -include-pch %t
11-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -Wno-pragma-pack -DRESET -emit-pch -o %t
12-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -Wno-pragma-pack -DRESET -verify -include-pch %t
13-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -Wno-pragma-pack -DPUSH -emit-pch -o %t
14-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -Wno-pragma-pack -DPUSH -verify -include-pch %t
15-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -Wno-pragma-pack -DPUSH_POP -emit-pch -o %t
16-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -Wno-pragma-pack -DPUSH_POP -verify -include-pch %t
17-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -Wno-pragma-pack -DPUSH_POP_LABEL -emit-pch -o %t
18-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -Wno-pragma-pack -DPUSH_POP_LABEL -verify -include-pch %t
9+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DSET -emit-pch -o %t
10+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DSET -verify -include-pch %t
11+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DRESET -emit-pch -o %t
12+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DRESET -verify -include-pch %t
13+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DPUSH -emit-pch -o %t
14+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DPUSH -verify -include-pch %t
15+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DPUSH_POP -emit-pch -o %t
16+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DPUSH_POP -verify -include-pch %t
17+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DPUSH_POP_LABEL -emit-pch -o %t
18+
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -DPUSH_POP_LABEL -verify -include-pch %t
1919

2020
#ifndef HEADER
2121
#define HEADER

test/PCH/suspicious-pragma-pack.c

-8
This file was deleted.

test/Parser/pragma-options.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple i386-apple-darwin9 -Wno-pragma-pack -fsyntax-only -verify %s
1+
// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
22

33
/* expected-warning {{expected 'align' following '#pragma options'}} */ #pragma options
44
/* expected-warning {{expected '=' following '#pragma options align'}} */ #pragma options align

test/Parser/pragma-options.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple i386-apple-darwin9 -Wno-pragma-pack -fsyntax-only -verify %s
1+
// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
22
// expected-no-diagnostics
33

44
class C {

test/Parser/pragma-pack.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -fsyntax-only -Wno-pragma-pack -verify %s
1+
// RUN: %clang_cc1 -fsyntax-only -verify %s
22

33
// Note that this puts the expected lines before the directives to work around
44
// limitations in the -verify mode.

test/Sema/Inputs/pragma-pack1.h

-23
This file was deleted.

test/Sema/Inputs/pragma-pack2.h

-6
This file was deleted.

0 commit comments

Comments
 (0)