Provide better abstraction of class Slang.
1. Remove the Slang C APIs support (not used by any other programs.)
2. All RS relatives are now in slang_rs_*.cpp.
diff --git a/slang_rs_backend.cpp b/slang_rs_backend.cpp
index 450a686..e6d4437 100644
--- a/slang_rs_backend.cpp
+++ b/slang_rs_backend.cpp
@@ -30,7 +30,7 @@
const clang::TargetOptions &TargetOpts,
const PragmaList &Pragmas,
llvm::raw_ostream *OS,
- SlangCompilerOutputTy OutputType,
+ Slang::OutputType OT,
clang::SourceManager &SourceMgr,
bool AllowRSPrefix)
: Backend(Diags,
@@ -38,10 +38,10 @@
TargetOpts,
Pragmas,
OS,
- OutputType,
- SourceMgr,
- AllowRSPrefix),
+ OT),
mContext(Context),
+ mSourceMgr(SourceMgr),
+ mAllowRSPrefix(AllowRSPrefix),
mExportVarMetadata(NULL),
mExportFuncMetadata(NULL),
mExportTypeMetadata(NULL) {
@@ -49,6 +49,23 @@
}
void RSBackend::HandleTopLevelDecl(clang::DeclGroupRef D) {
+ // Disallow user-defined functions with prefix "rs"
+ if (!mAllowRSPrefix) {
+ clang::DeclGroupRef::iterator I;
+ for (I = D.begin(); I != D.end(); I++) {
+ clang::FunctionDecl *FD = dyn_cast<clang::FunctionDecl>(*I);
+ if (!FD || !FD->isThisDeclarationADefinition()) continue;
+ if (FD->getName().startswith("rs")) {
+ mDiags.Report(clang::FullSourceLoc(FD->getLocStart(), mSourceMgr),
+ mDiags.getCustomDiagID(clang::Diagnostic::Error,
+ "invalid function name prefix,"
+ " \"rs\" is reserved: '%0'")
+ )
+ << FD->getNameAsString();
+ }
+ }
+ }
+
Backend::HandleTopLevelDecl(D);
return;
}