r268674 - Fix some Clang-tidy readability-simplify-boolean-expr and Include What You Use warnings.

Eugene Zelenko via cfe-commits cfe-commits at lists.llvm.org
Thu May 5 13:15:31 PDT 2016


Author: eugenezelenko
Date: Thu May  5 15:15:31 2016
New Revision: 268674

URL: http://llvm.org/viewvc/llvm-project?rev=268674&view=rev
Log:
Fix some Clang-tidy readability-simplify-boolean-expr and Include What You Use warnings.

Differential revision: http://reviews.llvm.org/D19947

Modified:
    cfe/trunk/include/clang/Lex/Token.h
    cfe/trunk/include/clang/Sema/ParsedTemplate.h

Modified: cfe/trunk/include/clang/Lex/Token.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Token.h?rev=268674&r1=268673&r2=268674&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Token.h (original)
+++ cfe/trunk/include/clang/Lex/Token.h Thu May  5 15:15:31 2016
@@ -14,12 +14,10 @@
 #ifndef LLVM_CLANG_LEX_TOKEN_H
 #define LLVM_CLANG_LEX_TOKEN_H
 
-#include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Basic/TemplateKinds.h"
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/StringRef.h"
-#include <cstdlib>
+#include <cassert>
 
 namespace clang {
 
@@ -69,8 +67,8 @@ class Token {
 
   /// Flags - Bits we track about this token, members of the TokenFlags enum.
   unsigned short Flags;
-public:
 
+public:
   // Various flags set per token:
   enum TokenFlags {
     StartOfLine   = 0x01,  // At start of line or only after whitespace
@@ -236,6 +234,11 @@ public:
     Flags |= Flag;
   }
 
+  /// \brief Get the specified flag.
+  bool getFlag(TokenFlags Flag) const {
+    return (Flags & Flag) != 0;
+  }
+
   /// \brief Unset the specified flag.
   void clearFlag(TokenFlags Flag) {
     Flags &= ~Flag;
@@ -259,17 +262,15 @@ public:
 
   /// isAtStartOfLine - Return true if this token is at the start of a line.
   ///
-  bool isAtStartOfLine() const { return (Flags & StartOfLine) ? true : false; }
+  bool isAtStartOfLine() const { return getFlag(StartOfLine); }
 
   /// \brief Return true if this token has whitespace before it.
   ///
-  bool hasLeadingSpace() const { return (Flags & LeadingSpace) ? true : false; }
+  bool hasLeadingSpace() const { return getFlag(LeadingSpace); }
 
   /// \brief Return true if this identifier token should never
   /// be expanded in the future, due to C99 6.10.3.4p2.
-  bool isExpandDisabled() const {
-    return (Flags & DisableExpand) ? true : false;
-  }
+  bool isExpandDisabled() const { return getFlag(DisableExpand); }
 
   /// \brief Return true if we have an ObjC keyword identifier.
   bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const;
@@ -278,31 +279,25 @@ public:
   tok::ObjCKeywordKind getObjCKeywordID() const;
 
   /// \brief Return true if this token has trigraphs or escaped newlines in it.
-  bool needsCleaning() const { return (Flags & NeedsCleaning) ? true : false; }
+  bool needsCleaning() const { return getFlag(NeedsCleaning); }
 
   /// \brief Return true if this token has an empty macro before it.
   ///
-  bool hasLeadingEmptyMacro() const {
-    return (Flags & LeadingEmptyMacro) ? true : false;
-  }
+  bool hasLeadingEmptyMacro() const { return getFlag(LeadingEmptyMacro); }
 
   /// \brief Return true if this token is a string or character literal which
   /// has a ud-suffix.
-  bool hasUDSuffix() const { return (Flags & HasUDSuffix) ? true : false; }
+  bool hasUDSuffix() const { return getFlag(HasUDSuffix); }
 
   /// Returns true if this token contains a universal character name.
-  bool hasUCN() const { return (Flags & HasUCN) ? true : false; }
+  bool hasUCN() const { return getFlag(HasUCN); }
 
   /// Returns true if this token is formed by macro by stringizing or charizing
   /// operator.
-  bool stringifiedInMacro() const {
-    return (Flags & StringifiedInMacro) ? true : false;
-  }
+  bool stringifiedInMacro() const { return getFlag(StringifiedInMacro); }
 
   /// Returns true if the comma after this token was elided.
-  bool commaAfterElided() const {
-    return (Flags & CommaAfterElided) ? true : false;
-  }
+  bool commaAfterElided() const { return getFlag(CommaAfterElided); }
 };
 
 /// \brief Information about the conditional stack (\#if directives)
@@ -324,11 +319,11 @@ struct PPConditionalInfo {
   bool FoundElse;
 };
 
-}  // end namespace clang
+} // end namespace clang
 
 namespace llvm {
   template <>
   struct isPodLike<clang::Token> { static const bool value = true; };
-}  // end namespace llvm
+} // end namespace llvm
 
-#endif
+#endif // LLVM_CLANG_LEX_TOKEN_H

Modified: cfe/trunk/include/clang/Sema/ParsedTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedTemplate.h?rev=268674&r1=268673&r2=268674&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/ParsedTemplate.h (original)
+++ cfe/trunk/include/clang/Sema/ParsedTemplate.h Thu May  5 15:15:31 2016
@@ -1,4 +1,4 @@
-//===--- ParsedTemplate.h - Template Parsing Data Types -------------------===//
+//===--- ParsedTemplate.h - Template Parsing Data Types ---------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -11,12 +11,19 @@
 //  templates.
 //
 //===----------------------------------------------------------------------===//
+
 #ifndef LLVM_CLANG_SEMA_PARSEDTEMPLATE_H
 #define LLVM_CLANG_SEMA_PARSEDTEMPLATE_H
 
+#include "clang/Basic/OperatorKinds.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TemplateKinds.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/Ownership.h"
+#include "llvm/ADT/SmallVector.h"
 #include <cassert>
+#include <cstdlib>
+#include <new>
 
 namespace clang {  
   /// \brief Represents the parsed form of a C++ template argument.
@@ -209,6 +216,6 @@ namespace clang {
   /// Retrieves the range of the given template parameter lists.
   SourceRange getTemplateParamsRange(TemplateParameterList const *const *Params,
                                      unsigned NumParams);  
-}
+} // end namespace clang
 
-#endif
+#endif // LLVM_CLANG_SEMA_PARSEDTEMPLATE_H




More information about the cfe-commits mailing list