Apply some LLVM_READONLY / LLVM_READNONE on diagnostic functions
authorAlp Toker <alp@nuanti.com>
Mon, 6 Jan 2014 11:30:15 +0000 (11:30 +0000)
committerAlp Toker <alp@nuanti.com>
Mon, 6 Jan 2014 11:30:15 +0000 (11:30 +0000)
llvm-svn: 198598

clang/include/clang/Basic/DiagnosticIDs.h
clang/include/clang/Basic/TokenKinds.h
clang/lib/Basic/TokenKinds.cpp

index 56e30fb..2be4acf 100644 (file)
@@ -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.
   ///
index 029cbdd..53f006a 100644 (file)
@@ -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 Kind);
 /// 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) {
index 6ce076e..f62624c 100644 (file)
@@ -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) {