aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-09 01:24:17 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-09 01:24:17 +0000
commit87429a05ff66fe6460eaa4855fd0da574e26bf7b (patch)
treed1f1993b2ae1e371850176c7ed0b88789b4e7158 /lib
parent75d0fe7100939c8f32ddf25e7b3f25e22e4a5878 (diff)
[PCH] Fix reading from PCH of diagnostic pragmas.
In certain cases ASTReader would call the normal DiagnosticsEngine API to initialize the state of diagnostic pragmas but DiagnosticsEngine would try to compare source locations leading to crash because the main FileID was not yet initialized. Yet another case of the ASTReader trying to use the normal APIs and inadvertently breaking invariants. Fix this by having the ASTReader set up the internal state directly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144153 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Basic/Diagnostic.cpp11
-rw-r--r--lib/Serialization/ASTReader.cpp8
2 files changed, 7 insertions, 12 deletions
diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp
index e5f390196d..7ea296233a 100644
--- a/lib/Basic/Diagnostic.cpp
+++ b/lib/Basic/Diagnostic.cpp
@@ -169,18 +169,9 @@ void DiagnosticsEngine::setDiagnosticMapping(diag::kind Diag, diag::Mapping Map,
"Cannot map errors into warnings!");
assert(!DiagStatePoints.empty());
- bool isPragma = L.isValid();
FullSourceLoc Loc(L, *SourceMgr);
FullSourceLoc LastStateChangePos = DiagStatePoints.back().Loc;
- DiagnosticMappingInfo MappingInfo = DiagnosticMappingInfo::Make(
- Map, /*IsUser=*/true, isPragma);
-
- // If this is a pragma mapping, then set the diagnostic mapping flags so that
- // we override command line options.
- if (isPragma) {
- MappingInfo.setNoWarningAsError(true);
- MappingInfo.setNoErrorAsFatal(true);
- }
+ DiagnosticMappingInfo MappingInfo = makeMappingInfo(Map, L);
// Common case; setting all the diagnostics of a group in one place.
if (Loc.isInvalid() || Loc == LastStateChangePos) {
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index cbf6cd0c5c..3aeaf19cd5 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -3109,6 +3109,10 @@ void ASTReader::ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag) {
unsigned Idx = 0;
while (Idx < F.PragmaDiagMappings.size()) {
SourceLocation Loc = ReadSourceLocation(F, F.PragmaDiagMappings[Idx++]);
+ Diag.DiagStates.push_back(*Diag.GetCurDiagState());
+ Diag.DiagStatePoints.push_back(
+ DiagnosticsEngine::DiagStatePoint(&Diag.DiagStates.back(),
+ FullSourceLoc(Loc, SourceMgr)));
while (1) {
assert(Idx < F.PragmaDiagMappings.size() &&
"Invalid data, didn't find '-1' marking end of diag/map pairs");
@@ -3121,8 +3125,8 @@ void ASTReader::ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag) {
break; // no more diag/map pairs for this location.
}
diag::Mapping Map = (diag::Mapping)F.PragmaDiagMappings[Idx++];
- // The user bit gets set by WritePragmaDiagnosticMappings.
- Diag.setDiagnosticMapping(DiagID, Map, Loc);
+ DiagnosticMappingInfo MappingInfo = Diag.makeMappingInfo(Map, Loc);
+ Diag.GetCurDiagState()->setMappingInfo(DiagID, MappingInfo);
}
}
}