[cfe-commits] r59601 - in /cfe/trunk: include/clang/Analysis/PathSensitive/BugReporter.h include/clang/Basic/Diagnostic.h lib/Basic/Diagnostic.cpp lib/Sema/SemaDeclCXX.cpp
Chris Lattner
sabre at nondot.org
Tue Nov 18 23:32:16 PST 2008
Author: lattner
Date: Wed Nov 19 01:32:16 2008
New Revision: 59601
URL: http://llvm.org/viewvc/llvm-project?rev=59601&view=rev
Log:
Allow sending IdentifierInfo*'s into Diagnostics without turning them into strings
first. This should allow removal of a bunch of II->getName() calls.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/BugReporter.h
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/lib/Basic/Diagnostic.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/BugReporter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/BugReporter.h?rev=59601&r1=59600&r2=59601&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/BugReporter.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/BugReporter.h Wed Nov 19 01:32:16 2008
@@ -325,13 +325,15 @@
R.addString(Info.getArgCStr(i));
break;
case DiagnosticInfo::ak_sint:
- // FIXME: Optimize
R.addString(llvm::itostr(Info.getArgSInt(i)));
break;
case DiagnosticInfo::ak_uint:
- // FIXME: Optimize
R.addString(llvm::utostr_32(Info.getArgUInt(i)));
break;
+ case DiagnosticInfo::ak_identifierinfo:
+ R.addString(Info.getArgIdentifier(i)->getName());
+ break;
+
}
}
}
Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=59601&r1=59600&r2=59601&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Wed Nov 19 01:32:16 2008
@@ -27,6 +27,7 @@
class SourceRange;
class SourceManager;
class DiagnosticInfo;
+ class IdentifierInfo;
// Import the diagnostic enums themselves.
namespace diag {
@@ -237,10 +238,11 @@
void operator=(const DiagnosticInfo&); // DO NOT IMPLEMENT
public:
enum ArgumentKind {
- ak_std_string, // std::string
- ak_c_string, // const char *
- ak_sint, // int
- ak_uint // unsigned
+ ak_std_string, // std::string
+ ak_c_string, // const char *
+ ak_sint, // int
+ ak_uint, // unsigned
+ ak_identifierinfo // IdentifierInfo
};
@@ -316,6 +318,13 @@
return (unsigned)DiagObj->DiagArgumentsVal[Idx];
}
+ /// getArgIdentifier - Return the specified IdentifierInfo argument.
+ const IdentifierInfo *getArgIdentifier(unsigned Idx) const {
+ assert(getArgKind(Idx) == ak_identifierinfo &&"invalid argument accessor!");
+ return reinterpret_cast<const IdentifierInfo*>(
+ DiagObj->DiagArgumentsVal[Idx]);
+ }
+
/// getNumRanges - Return the number of source ranges associated with this
/// diagnostic.
unsigned getNumRanges() const {
@@ -360,6 +369,17 @@
return *this;
}
+ DiagnosticInfo &operator<<(const IdentifierInfo *II) {
+ assert((unsigned)DiagObj->NumDiagArgs < Diagnostic::MaxArguments &&
+ "Too many arguments to diagnostic!");
+ DiagObj->DiagArgumentsKind[DiagObj->NumDiagArgs] = ak_identifierinfo;
+ DiagObj->DiagArgumentsVal[DiagObj->NumDiagArgs++] =
+ reinterpret_cast<intptr_t>(II);
+ return *this;
+ }
+
+
+
DiagnosticInfo &operator<<(const SourceRange &R) {
assert((unsigned)DiagObj->NumDiagArgs <
Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=59601&r1=59600&r2=59601&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Wed Nov 19 01:32:16 2008
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
@@ -292,6 +293,11 @@
OutStr.append(S.begin(), S.end());
break;
}
+ case DiagnosticInfo::ak_identifierinfo: {
+ const IdentifierInfo *II = getArgIdentifier(StrNo);
+ OutStr.append(II->getName(), II->getName() + II->getLength());
+ break;
+ }
}
DiagStr += 2;
}
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=59601&r1=59600&r2=59601&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Nov 19 01:32:16 2008
@@ -234,7 +234,7 @@
if (Param->getIdentifier())
Diag(Param->getLocation(),
diag::err_param_default_argument_missing_name)
- << Param->getIdentifier()->getName();
+ << Param->getIdentifier();
else
Diag(Param->getLocation(),
diag::err_param_default_argument_missing);
More information about the cfe-commits
mailing list