/// \returns true if the diagnostic was emitted, false if it was
/// suppressed.
bool ProcessDiag();
+
+ friend class ASTReader;
+ friend class ASTWriter;
};
//===----------------------------------------------------------------------===//
/// \brief Record code for the table of offsets to CXXBaseSpecifier
/// sets.
- CXX_BASE_SPECIFIER_OFFSETS = 37
+ CXX_BASE_SPECIFIER_OFFSETS = 37,
+
+ /// \brief Record code for diagnostic mappings specified by the user.
+ DIAG_USER_MAPPINGS = 38
};
/// \brief Record types used within a source manager block.
//@}
+ /// \brief Diagnostic IDs and their mappings that the user changed.
+ llvm::SmallVector<uint64_t, 8> UserDiagMappings;
+
/// \brief The original file name that was used to build the primary AST file,
/// which may have been modified for relocatable-pch support.
std::string OriginalFileName;
/// \brief Read preprocessed entities into the
virtual void ReadPreprocessedEntities();
+ void ReadUserDiagnosticMappings(Diagnostic &Diag);
+
/// \brief Returns the number of source locations found in the chain.
unsigned getTotalNumSLocs() const {
return TotalNumSLocEntries;
const Preprocessor &PP,
const char* isysroot);
void WritePreprocessor(const Preprocessor &PP);
+ void WriteUserDiagnosticMappings(const Diagnostic &Diag);
void WriteType(QualType T);
uint64_t WriteDeclContextLexicalBlock(ASTContext &Context, DeclContext *DC);
uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC);
F.CXXBaseSpecifiersOffsets = (const uint32_t *)BlobStart;
break;
}
+
+ case DIAG_USER_MAPPINGS:
+ if (Record.size() % 2 != 0) {
+ Error("invalid DIAG_USER_MAPPINGS block in AST file");
+ return Failure;
+ }
+ if (UserDiagMappings.empty())
+ UserDiagMappings.swap(Record);
+ else
+ UserDiagMappings.insert(UserDiagMappings.end(),
+ Record.begin(), Record.end());
+ break;
}
First = false;
}
if (SpecialTypes[SPECIAL_TYPE_INT128_INSTALLED])
Context->setInt128Installed();
+
+ ReadUserDiagnosticMappings(Context->getDiagnostics());
}
/// \brief Retrieve the name of the original source file name
ReadDefinedMacros();
}
+void ASTReader::ReadUserDiagnosticMappings(Diagnostic &Diag) {
+ unsigned Idx = 0;
+ while (Idx < UserDiagMappings.size()) {
+ unsigned DiagID = UserDiagMappings[Idx++];
+ unsigned Map = UserDiagMappings[Idx++];
+ Diag.setDiagnosticMappingInternal(DiagID, Map, /*isUser=*/true);
+ }
+}
+
/// \brief Get the correct cursor and offset for loading a type.
ASTReader::RecordLocation ASTReader::TypeCursorForIndex(unsigned Index) {
PerFileData *F = 0;
}
}
+void ASTWriter::WriteUserDiagnosticMappings(const Diagnostic &Diag) {
+ RecordData Record;
+ for (unsigned i = 0; i != diag::DIAG_UPPER_LIMIT; ++i) {
+ diag::Mapping Map = Diag.getDiagnosticMappingInfo(i);
+ if (Map & 0x8) { // user mapping.
+ Record.push_back(i);
+ Record.push_back(Map & 0x7);
+ }
+ }
+
+ Stream.EmitRecord(DIAG_USER_MAPPINGS, Record);
+}
+
//===----------------------------------------------------------------------===//
// Type Serialization
//===----------------------------------------------------------------------===//
WriteIdentifierTable(PP);
WriteTypeDeclOffsets();
+ WriteUserDiagnosticMappings(Context.getDiagnostics());
// Write the C++ base-specifier set offsets.
if (!CXXBaseSpecifiersOffsets.empty()) {
WriteReferencedSelectorsPool(SemaRef);
WriteIdentifierTable(PP);
WriteTypeDeclOffsets();
+ // FIXME: For chained PCH only write the new mappings (we currently
+ // write all of them again).
+ WriteUserDiagnosticMappings(Context.getDiagnostics());
/// Build a record containing first declarations from a chained PCH and the
/// most recent declarations in this AST that they point to.
--- /dev/null
+// Test this without pch.
+// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only
+
+// Test with pch.
+// RUN: %clang_cc1 %s -emit-pch -o %t
+// RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only
+
+#ifndef HEADER
+#define HEADER
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+#else
+
+void f() {
+ int b = b==b;
+}
+
+#endif