Distinguish enum and class 'AidlError'.
These are in different namespaces, but it is still confusing and makes
refactoring more difficult. Renaming the class to AidlErrorLog.
Bug: N/A
Test: compilation suffices
Change-Id: Ib4d4e8c25d87756f182ff120feb9825f58a6d30e
diff --git a/aidl_language.cpp b/aidl_language.cpp
index bd2474c..d68c091 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -116,19 +116,19 @@
return ss.str();
}
-AidlError::AidlError(bool fatal) : os_(std::cerr), fatal_(fatal) {
+AidlErrorLog::AidlErrorLog(bool fatal) : os_(std::cerr), fatal_(fatal) {
sHadError = true;
os_ << "ERROR: ";
}
-AidlError::AidlError(bool fatal, const AidlLocation& location) : AidlError(fatal) {
+AidlErrorLog::AidlErrorLog(bool fatal, const AidlLocation& location) : AidlErrorLog(fatal) {
CHECK(!location.IsInternal())
<< "Logging an internal location should not happen. Offending location: " << location;
os_ << location << ": ";
}
-bool AidlError::sHadError = false;
+bool AidlErrorLog::sHadError = false;
static const string kNullable("nullable");
static const string kUtf8InCpp("utf8InCpp");
diff --git a/aidl_language.h b/aidl_language.h
index 97c8ba3..86640e9 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -110,7 +110,7 @@
virtual ~AidlNode() = default;
// To be able to print AidlLocation
- friend class AidlError;
+ friend class AidlErrorLog;
friend std::string android::aidl::mappings::dump_location(const AidlNode&);
friend std::string android::aidl::java::dump_location(const AidlNode&);
@@ -125,16 +125,18 @@
};
// Generic point for printing any error in the AIDL compiler.
-class AidlError {
+class AidlErrorLog {
public:
- AidlError(bool fatal, const std::string& filename) : AidlError(fatal) { os_ << filename << ": "; }
- AidlError(bool fatal, const AidlLocation& location);
- AidlError(bool fatal, const AidlNode& node) : AidlError(fatal, node.location_) {}
- AidlError(bool fatal, const AidlNode* node) : AidlError(fatal, *node) {}
+ AidlErrorLog(bool fatal, const std::string& filename) : AidlErrorLog(fatal) {
+ os_ << filename << ": ";
+ }
+ AidlErrorLog(bool fatal, const AidlLocation& location);
+ AidlErrorLog(bool fatal, const AidlNode& node) : AidlErrorLog(fatal, node.location_) {}
+ AidlErrorLog(bool fatal, const AidlNode* node) : AidlErrorLog(fatal, *node) {}
template <typename T>
- AidlError(bool fatal, const std::unique_ptr<T>& node) : AidlError(fatal, *node) {}
- ~AidlError() {
+ AidlErrorLog(bool fatal, const std::unique_ptr<T>& node) : AidlErrorLog(fatal, *node) {}
+ ~AidlErrorLog() {
os_ << std::endl;
if (fatal_) abort();
}
@@ -144,17 +146,17 @@
static bool hadError() { return sHadError; }
private:
- AidlError(bool fatal);
+ AidlErrorLog(bool fatal);
bool fatal_;
static bool sHadError;
- DISALLOW_COPY_AND_ASSIGN(AidlError);
+ DISALLOW_COPY_AND_ASSIGN(AidlErrorLog);
};
-#define AIDL_ERROR(CONTEXT) ::AidlError(false /*fatal*/, (CONTEXT)).os_
-#define AIDL_FATAL(CONTEXT) ::AidlError(true /*fatal*/, (CONTEXT)).os_
+#define AIDL_ERROR(CONTEXT) ::AidlErrorLog(false /*fatal*/, (CONTEXT)).os_
+#define AIDL_FATAL(CONTEXT) ::AidlErrorLog(true /*fatal*/, (CONTEXT)).os_
#define AIDL_FATAL_IF(CONDITION, CONTEXT) \
if (CONDITION) AIDL_FATAL(CONTEXT) << "Bad internal state: " << #CONDITION << ": "
diff --git a/main.cpp b/main.cpp
index 10b9274..d4ad37c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -67,7 +67,7 @@
// once AIDL_ERROR/AIDL_FATAL are used everywhere instead of std::cerr/LOG, we
// can make this assertion in both directions.
if (ret == 0) {
- AIDL_FATAL_IF(AidlError::hadError(), "Compiler success, but error emitted");
+ AIDL_FATAL_IF(AidlErrorLog::hadError(), "Compiler success, but error emitted");
}
return ret;