Implement one-definition-rule (ODR) feature.
When compiling multiple RS files, we say two RS files A and B break ODR
iff:
1. They have at least one common struct named [S] and [S] will be reflected
to ScriptField_[S].java, and
2. [S] defined in A is not *exactly the same* (number of fields, field
type and field name) as the one defined in B.
This CL detects such error.
diff --git a/slang.cpp b/slang.cpp
index cd3cf93..98610c6 100644
--- a/slang.cpp
+++ b/slang.cpp
@@ -185,6 +185,7 @@
mDiagClient = new DiagnosticBuffer();
// This takes the ownership of mDiagClient.
mDiagnostics->setClient(mDiagClient);
+ initDiagnostic();
return;
}
@@ -272,11 +273,15 @@
OT);
}
-Slang::Slang(const std::string &Triple, const std::string &CPU,
- const std::vector<std::string> &Features)
- : mDiagClient(NULL),
- mOT(OT_Default) {
+Slang::Slang() : mInitialized(false), mDiagClient(NULL), mOT(OT_Default) {
GlobalInitialization();
+ return;
+}
+
+void Slang::init(const std::string &Triple, const std::string &CPU,
+ const std::vector<std::string> &Features) {
+ if (mInitialized)
+ return;
createDiagnostic();
llvm::install_fatal_error_handler(LLVMErrorHandler, mDiagnostics.getPtr());
@@ -285,6 +290,8 @@
createFileManager();
createSourceManager();
+ mInitialized = true;
+
return;
}