[APINotes] Introduce APINotes infrastructure in Clang Sema and Frontend
This upstreams more of the Clang API Notes functionality that is currently implemented in the Apple fork: https://github.com/apple/llvm-project/tree/next/clang/lib/APINotes This adds the initial Clang APINotes infrastructure to Clang Sema and Clang Frontend. There will shortly be a follow-up patch with the actual usages of this API. I'm splitting these changes into separate PRs to keep the diffs easier to review.
This commit is contained in:
1 parent
56f569049c
commit
e6ef315247
6 files changed
+15
-1
No files matched your search
@@ -304,6 +304,11 @@ public:
|
||||
return Invocation->getHeaderSearchOptsPtr();
|
||||
}
|
||||
|
||||
APINotesOptions &getAPINotesOpts() { return Invocation->getAPINotesOpts(); }
|
||||
const APINotesOptions &getAPINotesOpts() const {
|
||||
return Invocation->getAPINotesOpts();
|
||||
}
|
||||
|
||||
LangOptions &getLangOpts() { return Invocation->getLangOpts(); }
|
||||
const LangOptions &getLangOpts() const { return Invocation->getLangOpts(); }
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#ifndef LLVM_CLANG_SEMA_SEMA_H
|
||||
#define LLVM_CLANG_SEMA_SEMA_H
|
||||
|
||||
#include "clang/APINotes/APINotesManager.h"
|
||||
#include "clang/AST/ASTConcept.h"
|
||||
#include "clang/AST/ASTFwd.h"
|
||||
#include "clang/AST/Attr.h"
|
||||
@@ -408,6 +409,7 @@ public:
|
||||
ASTConsumer &Consumer;
|
||||
DiagnosticsEngine &Diags;
|
||||
SourceManager &SourceMgr;
|
||||
api_notes::APINotesManager APINotes;
|
||||
|
||||
/// Flag indicating whether or not to collect detailed statistics.
|
||||
bool CollectStats;
|
||||
|
||||
@@ -48,6 +48,7 @@ add_clang_library(clangFrontend
|
||||
intrinsics_gen
|
||||
|
||||
LINK_LIBS
|
||||
clangAPINotes
|
||||
clangAST
|
||||
clangBasic
|
||||
clangDriver
|
||||
|
||||
@@ -747,6 +747,10 @@ void CompilerInstance::createSema(TranslationUnitKind TUKind,
|
||||
CodeCompleteConsumer *CompletionConsumer) {
|
||||
TheSema.reset(new Sema(getPreprocessor(), getASTContext(), getASTConsumer(),
|
||||
TUKind, CompletionConsumer));
|
||||
|
||||
// Set up API notes.
|
||||
TheSema->APINotes.setSwiftVersion(getAPINotesOpts().SwiftVersion);
|
||||
|
||||
// Attach the external sema source if there is any.
|
||||
if (ExternalSemaSrc) {
|
||||
TheSema->addExternalSource(ExternalSemaSrc.get());
|
||||
|
||||
@@ -74,6 +74,7 @@ add_clang_library(clangSema
|
||||
ClangDriverOptions
|
||||
|
||||
LINK_LIBS
|
||||
clangAPINotes
|
||||
clangAST
|
||||
clangAnalysis
|
||||
clangBasic
|
||||
|
||||
@@ -191,7 +191,8 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
|
||||
: ExternalSource(nullptr), CurFPFeatures(pp.getLangOpts()),
|
||||
LangOpts(pp.getLangOpts()), PP(pp), Context(ctxt), Consumer(consumer),
|
||||
Diags(PP.getDiagnostics()), SourceMgr(PP.getSourceManager()),
|
||||
CollectStats(false), CodeCompleter(CodeCompleter), CurContext(nullptr),
|
||||
APINotes(SourceMgr, LangOpts), CollectStats(false),
|
||||
CodeCompleter(CodeCompleter), CurContext(nullptr),
|
||||
OriginalLexicalContext(nullptr), MSStructPragmaOn(false),
|
||||
MSPointerToMemberRepresentationMethod(
|
||||
LangOpts.getMSPointerToMemberRepresentationMethod()),
|
||||
|
||||
Reference in new issue
Block a user