summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2014-08-01 01:42:01 +0000
committerRichard Trieu <rtrieu@google.com>2014-08-01 01:42:01 +0000
commit428058fb9a89586b43e9b6fe16e22664d9d37d00 (patch)
treef995fed25b101217e60d48e7af2e8fc2f6ded2b2 /clang/lib
parent82ecc7ff2a206068be74559134755e036ca9481e (diff)
downloadbcm5719-llvm-428058fb9a89586b43e9b6fe16e22664d9d37d00.tar.gz
bcm5719-llvm-428058fb9a89586b43e9b6fe16e22664d9d37d00.zip
Remove this pointer that is converted to bool. In well-defined contexts, the
this pointer is always non-null. If the this pointer is null, it is undefined and the compiler may optimize it away by assuming it is non-null. The null checks are pushed into the callers. llvm-svn: 214471
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Basic/DiagnosticIDs.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp
index 0bb0b9f928e..3c0216a1320 100644
--- a/clang/lib/Basic/DiagnosticIDs.cpp
+++ b/clang/lib/Basic/DiagnosticIDs.cpp
@@ -259,14 +259,14 @@ namespace clang {
/// getDescription - Return the description of the specified custom
/// diagnostic.
StringRef getDescription(unsigned DiagID) const {
- assert(this && DiagID-DIAG_UPPER_LIMIT < DiagInfo.size() &&
+ assert(DiagID - DIAG_UPPER_LIMIT < DiagInfo.size() &&
"Invalid diagnostic ID");
return DiagInfo[DiagID-DIAG_UPPER_LIMIT].second;
}
/// getLevel - Return the level of the specified custom diagnostic.
DiagnosticIDs::Level getLevel(unsigned DiagID) const {
- assert(this && DiagID-DIAG_UPPER_LIMIT < DiagInfo.size() &&
+ assert(DiagID - DIAG_UPPER_LIMIT < DiagInfo.size() &&
"Invalid diagnostic ID");
return DiagInfo[DiagID-DIAG_UPPER_LIMIT].first;
}
@@ -358,6 +358,7 @@ bool DiagnosticIDs::isDefaultMappingAsError(unsigned DiagID) {
StringRef DiagnosticIDs::getDescription(unsigned DiagID) const {
if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
return Info->getDescription();
+ assert(CustomDiagInfo && "Invalid CustomDiagInfo");
return CustomDiagInfo->getDescription(DiagID);
}
@@ -384,8 +385,10 @@ DiagnosticIDs::Level
DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, SourceLocation Loc,
const DiagnosticsEngine &Diag) const {
// Handle custom diagnostics, which cannot be mapped.
- if (DiagID >= diag::DIAG_UPPER_LIMIT)
+ if (DiagID >= diag::DIAG_UPPER_LIMIT) {
+ assert(CustomDiagInfo && "Invalid CustomDiagInfo");
return CustomDiagInfo->getLevel(DiagID);
+ }
unsigned DiagClass = getBuiltinDiagClass(DiagID);
if (DiagClass == CLASS_NOTE) return DiagnosticIDs::Note;
@@ -669,6 +672,7 @@ void DiagnosticIDs::EmitDiag(DiagnosticsEngine &Diag, Level DiagLevel) const {
bool DiagnosticIDs::isUnrecoverable(unsigned DiagID) const {
if (DiagID >= diag::DIAG_UPPER_LIMIT) {
+ assert(CustomDiagInfo && "Invalid CustomDiagInfo");
// Custom diagnostics.
return CustomDiagInfo->getLevel(DiagID) >= DiagnosticIDs::Error;
}
OpenPOWER on IntegriCloud