swift-api-digester: simplify the API to emit diagnostics. NFC

All diagnostics in the abi/api checker shares empty source location
and a screening info string as the first argument. This patch
adds a new forwarding function to avoid duplicating these common
logics.
This commit is contained in:
Xi Ge
2019-03-27 14:18:09 -07:00
parent 72ea2426c1
commit 350ed65def
2 changed files with 70 additions and 86 deletions

View File

@@ -38,6 +38,7 @@
#include "swift/AST/USRGeneration.h"
#include "swift/AST/GenericSignature.h"
#include "swift/AST/ProtocolConformance.h"
#include "swift/AST/DiagnosticsModuleDiffer.h"
#include "swift/Basic/ColorUtils.h"
#include "swift/Basic/JSONSerialization.h"
#include "swift/Basic/LLVMInitialize.h"
@@ -195,6 +196,7 @@ public:
bool shouldIgnore(Decl *D, const Decl* Parent = nullptr) const;
ArrayRef<BreakingAttributeInfo> getBreakingAttributeInfo() const { return BreakingAttrs; }
Optional<uint8_t> getFixedBinaryOrder(ValueDecl *VD) const;
template<class YAMLNodeTy, typename ...ArgTypes>
void diagnose(YAMLNodeTy node, Diag<ArgTypes...> ID,
typename detail::PassArgument<ArgTypes>::type... args) {
@@ -336,6 +338,19 @@ public:
uint8_t getFixedBinaryOrder() const { return *FixedBinaryOrder; }
virtual void jsonize(json::Output &Out) override;
virtual void diagnose(SDKNode *Right) override;
// The first argument of the diag is always screening info.
template<typename ...ArgTypes>
void emitDiag(Diag<StringRef, ArgTypes...> ID,
typename detail::PassArgument<ArgTypes>::type... Args) const {
// Don't emit objc decls if we care about swift exclusively
if (Ctx.getOpts().SwiftOnly) {
if (isObjc())
return;
}
Ctx.getDiags().diagnose(SourceLoc(), ID, getScreenInfo(),
std::move(Args)...);
}
};
class SDKNodeRoot: public SDKNode {