r198598 - Apply some LLVM_READONLY / LLVM_READNONE on diagnostic functions
Alp Toker
alp at nuanti.com
Mon Jan 6 03:30:15 PST 2014
Author: alp
Date: Mon Jan 6 05:30:15 2014
New Revision: 198598
URL: http://llvm.org/viewvc/llvm-project?rev=198598&view=rev
Log:
Apply some LLVM_READONLY / LLVM_READNONE on diagnostic functions
Modified:
cfe/trunk/include/clang/Basic/DiagnosticIDs.h
cfe/trunk/include/clang/Basic/TokenKinds.h
cfe/trunk/lib/Basic/TokenKinds.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=198598&r1=198597&r2=198598&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Mon Jan 6 05:30:15 2014
@@ -247,15 +247,15 @@ private:
///
/// \param Loc The source location for which we are interested in finding out
/// the diagnostic state. Can be null in order to query the latest state.
- DiagnosticIDs::Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc,
- const DiagnosticsEngine &Diag) const;
+ DiagnosticIDs::Level
+ getDiagnosticLevel(unsigned DiagID, SourceLocation Loc,
+ const DiagnosticsEngine &Diag) const LLVM_READONLY;
/// \brief An internal implementation helper used when \p DiagClass is
/// already known.
- DiagnosticIDs::Level getDiagnosticLevel(unsigned DiagID,
- unsigned DiagClass,
- SourceLocation Loc,
- const DiagnosticsEngine &Diag) const;
+ DiagnosticIDs::Level
+ getDiagnosticLevel(unsigned DiagID, unsigned DiagClass, SourceLocation Loc,
+ const DiagnosticsEngine &Diag) const LLVM_READONLY;
/// \brief Used to report a diagnostic that is finally fully formed.
///
Modified: cfe/trunk/include/clang/Basic/TokenKinds.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.h?rev=198598&r1=198597&r2=198598&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TokenKinds.h (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.h Mon Jan 6 05:30:15 2014
@@ -54,7 +54,7 @@ enum OnOffSwitch {
///
/// The name of a token will be an internal name (such as "l_square")
/// and should not be used as part of diagnostic messages.
-const char *getTokenName(enum TokenKind Kind);
+const char *getTokenName(enum TokenKind Kind) LLVM_READNONE;
/// \brief Determines the spelling of simple punctuation tokens like
/// '!' or '%', and returns NULL for literal and annotation tokens.
@@ -63,7 +63,7 @@ const char *getTokenName(enum TokenKind
/// and will not produce any alternative spellings (e.g., a
/// digraph). For the actual spelling of a given Token, use
/// Preprocessor::getSpelling().
-const char *getTokenSimpleSpelling(enum TokenKind Kind);
+const char *getTokenSimpleSpelling(enum TokenKind Kind) LLVM_READNONE;
/// \brief Return true if this is a raw identifier or an identifier kind.
inline bool isAnyIdentifier(TokenKind K) {
Modified: cfe/trunk/lib/Basic/TokenKinds.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TokenKinds.cpp?rev=198598&r1=198597&r2=198598&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/TokenKinds.cpp (original)
+++ cfe/trunk/lib/Basic/TokenKinds.cpp Mon Jan 6 05:30:15 2014
@@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Basic/TokenKinds.h"
-#include <cassert>
+#include "llvm/Support/ErrorHandling.h"
using namespace clang;
static const char * const TokNames[] = {
@@ -23,8 +23,10 @@ static const char * const TokNames[] = {
};
const char *tok::getTokenName(enum TokenKind Kind) {
- assert(Kind < tok::NUM_TOKENS);
- return TokNames[Kind];
+ if (Kind < tok::NUM_TOKENS)
+ return TokNames[Kind];
+ llvm_unreachable("unknown TokenKind");
+ return 0;
}
const char *tok::getTokenSimpleSpelling(enum TokenKind Kind) {
More information about the cfe-commits
mailing list