xazax.hun created this revision.
xazax.hun added reviewers: hokein, alexfh.
xazax.hun added a subscriber: cfe-commits.
xazax.hun set the repository for this revision to rL LLVM.
xazax.hun added a project: clang-tools-extra.
Herald added a subscriber: nemanjai.

In some cases do not register the matcher when the check method of a checker 
should not run anyways.

Refactor some checks to use a shorter way to get language options.

Repository:
  rL LLVM

https://reviews.llvm.org/D24881

Files:
  clang-tidy/cert/StrToNumCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp
  clang-tidy/google/AvoidCStyleCastsCheck.cpp
  clang-tidy/google/ExplicitConstructorCheck.cpp
  clang-tidy/llvm/TwineLocalCheck.cpp
  clang-tidy/misc/AssertSideEffectCheck.cpp
  clang-tidy/misc/InaccurateEraseCheck.cpp
  clang-tidy/misc/InefficientAlgorithmCheck.cpp
  clang-tidy/misc/StringIntegerAssignmentCheck.cpp
  clang-tidy/misc/SuspiciousStringCompareCheck.cpp
  clang-tidy/misc/UniqueptrResetReleaseCheck.cpp
  clang-tidy/misc/UnusedAliasDeclsCheck.cpp
  clang-tidy/misc/UnusedRAIICheck.cpp
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tidy/modernize/PassByValueCheck.cpp
  clang-tidy/modernize/RawStringLiteralCheck.cpp
  clang-tidy/modernize/RedundantVoidArgCheck.cpp
  clang-tidy/modernize/ShrinkToFitCheck.cpp
  clang-tidy/modernize/UseOverrideCheck.cpp
  clang-tidy/mpi/TypeMismatchCheck.cpp
  clang-tidy/readability/AvoidConstParamsInDecls.cpp
  clang-tidy/readability/ContainerSizeEmptyCheck.cpp
  clang-tidy/readability/NamespaceCommentCheck.cpp
  clang-tidy/readability/RedundantControlFlowCheck.cpp
  clang-tidy/readability/RedundantSmartptrGetCheck.cpp
  clang-tidy/readability/SimplifyBooleanExprCheck.cpp
  clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp
  clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp

Index: clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
===================================================================
--- clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
+++ clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
@@ -53,7 +53,7 @@
 
   SourceLocation AfterPtr =
       Lexer::getLocForEndOfToken(PtrExpr->getLocEnd(), 0, *Result.SourceManager,
-                                 Result.Context->getLangOpts());
+                                 getLangOpts());
 
   diag(DeleteExpr->getLocStart(),
        "prefer '= nullptr' to 'delete x.release()' to reset unique_ptr<> "
Index: clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp
===================================================================
--- clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp
+++ clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp
@@ -54,11 +54,11 @@
   SourceLocation Loc = Def->getSourceRange().getBegin();
   while (Loc < Def->getSourceRange().getEnd() &&
          !Lexer::getRawToken(Loc, Tok, *Result.SourceManager,
-                             Result.Context->getLangOpts(), true)) {
+                             getLangOpts(), true)) {
     SourceRange TokenRange(Tok.getLocation(), Tok.getEndLoc());
     StringRef SourceText = Lexer::getSourceText(
         CharSourceRange::getTokenRange(TokenRange),
-        *Result.SourceManager, Result.Context->getLangOpts());
+        *Result.SourceManager, getLangOpts());
     if (SourceText == "static") {
       Diag << FixItHint::CreateRemoval(TokenRange);
       break;
Index: clang-tidy/readability/SimplifyBooleanExprCheck.cpp
===================================================================
--- clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ clang-tidy/readability/SimplifyBooleanExprCheck.cpp
@@ -561,7 +561,7 @@
     StringRef Replacement) {
   CharSourceRange CharRange = Lexer::makeFileCharRange(
       CharSourceRange::getTokenRange(ReplacementRange), *Result.SourceManager,
-      Result.Context->getLangOpts());
+      getLangOpts());
 
   DiagnosticBuilder Diag = diag(Loc, Description);
   if (!containsDiscardedTokens(Result, CharRange))
Index: clang-tidy/readability/RedundantSmartptrGetCheck.cpp
===================================================================
--- clang-tidy/readability/RedundantSmartptrGetCheck.cpp
+++ clang-tidy/readability/RedundantSmartptrGetCheck.cpp
@@ -119,7 +119,7 @@
 
   StringRef SmartptrText = Lexer::getSourceText(
       CharSourceRange::getTokenRange(Smartptr->getSourceRange()),
-      *Result.SourceManager, Result.Context->getLangOpts());
+      *Result.SourceManager, getLangOpts());
   // Replace foo->get() with *foo, and foo.get() with foo.
   std::string Replacement = Twine(IsPtrToPtr ? "*" : "", SmartptrText).str();
   diag(GetCall->getLocStart(), "redundant get() call on smart pointer")
Index: clang-tidy/readability/RedundantControlFlowCheck.cpp
===================================================================
--- clang-tidy/readability/RedundantControlFlowCheck.cpp
+++ clang-tidy/readability/RedundantControlFlowCheck.cpp
@@ -81,14 +81,14 @@
   if (Previous != Block->body_rend())
     Start = Lexer::findLocationAfterToken(
         dyn_cast<Stmt>(*Previous)->getLocEnd(), tok::semi, SM,
-        Result.Context->getLangOpts(),
+        getLangOpts(),
         /*SkipTrailingWhitespaceAndNewLine=*/true);
   if (!Start.isValid())
     Start = StmtRange.getBegin();
   auto RemovedRange = CharSourceRange::getCharRange(
       Start,
       Lexer::findLocationAfterToken(StmtRange.getEnd(), tok::semi, SM,
-                                    Result.Context->getLangOpts(),
+                                    getLangOpts(),
                                     /*SkipTrailingWhitespaceAndNewLine=*/true));
 
   diag(StmtRange.getBegin(), Diag) << FixItHint::CreateRemoval(RemovedRange);
Index: clang-tidy/readability/NamespaceCommentCheck.cpp
===================================================================
--- clang-tidy/readability/NamespaceCommentCheck.cpp
+++ clang-tidy/readability/NamespaceCommentCheck.cpp
@@ -75,7 +75,7 @@
   SourceLocation Loc = AfterRBrace;
   Token Tok;
   // Skip whitespace until we find the next token.
-  while (Lexer::getRawToken(Loc, Tok, Sources, Result.Context->getLangOpts()) ||
+  while (Lexer::getRawToken(Loc, Tok, Sources, getLangOpts()) ||
          Tok.is(tok::semi)) {
     Loc = Loc.getLocWithOffset(1);
   }
Index: clang-tidy/readability/ContainerSizeEmptyCheck.cpp
===================================================================
--- clang-tidy/readability/ContainerSizeEmptyCheck.cpp
+++ clang-tidy/readability/ContainerSizeEmptyCheck.cpp
@@ -71,7 +71,7 @@
   FixItHint Hint;
   std::string ReplacementText = Lexer::getSourceText(
       CharSourceRange::getTokenRange(E->getSourceRange()),
-      *Result.SourceManager, Result.Context->getLangOpts());
+      *Result.SourceManager, getLangOpts());
   if (E->getType()->isPointerType())
     ReplacementText += "->empty()";
   else
Index: clang-tidy/readability/AvoidConstParamsInDecls.cpp
===================================================================
--- clang-tidy/readability/AvoidConstParamsInDecls.cpp
+++ clang-tidy/readability/AvoidConstParamsInDecls.cpp
@@ -100,7 +100,7 @@
 
   CharSourceRange FileRange = Lexer::makeFileCharRange(
       CharSourceRange::getTokenRange(getTypeRange(*Param)),
-      *Result.SourceManager, Result.Context->getLangOpts());
+      *Result.SourceManager, getLangOpts());
 
   if (!FileRange.isValid())
     return;
Index: clang-tidy/mpi/TypeMismatchCheck.cpp
===================================================================
--- clang-tidy/mpi/TypeMismatchCheck.cpp
+++ clang-tidy/mpi/TypeMismatchCheck.cpp
@@ -297,7 +297,7 @@
     }
   }
   checkArguments(BufferTypes, BufferExprs, MPIDatatypes,
-                 Result.Context->getLangOpts());
+                 getLangOpts());
 }
 
 void TypeMismatchCheck::checkArguments(ArrayRef<const Type *> BufferTypes,
Index: clang-tidy/modernize/UseOverrideCheck.cpp
===================================================================
--- clang-tidy/modernize/UseOverrideCheck.cpp
+++ clang-tidy/modernize/UseOverrideCheck.cpp
@@ -104,7 +104,7 @@
 
   CharSourceRange FileRange = Lexer::makeFileCharRange(
       CharSourceRange::getTokenRange(Method->getSourceRange()), Sources,
-      Result.Context->getLangOpts());
+      getLangOpts());
 
   if (!FileRange.isValid())
     return;
Index: clang-tidy/modernize/ShrinkToFitCheck.cpp
===================================================================
--- clang-tidy/modernize/ShrinkToFitCheck.cpp
+++ clang-tidy/modernize/ShrinkToFitCheck.cpp
@@ -20,6 +20,9 @@
 namespace modernize {
 
 void ShrinkToFitCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus11)
+    return;
+
   // Swap as a function need not to be considered, because rvalue can not
   // be bound to a non-const reference.
   const auto ShrinkableAsMember =
@@ -51,17 +54,13 @@
 }
 
 void ShrinkToFitCheck::check(const MatchFinder::MatchResult &Result) {
-  const LangOptions &Opts = Result.Context->getLangOpts();
-
-  if (!Opts.CPlusPlus11)
-    return;
-
   const auto *MemberCall =
       Result.Nodes.getNodeAs<CXXMemberCallExpr>("CopyAndSwapTrick");
   const auto *Container = Result.Nodes.getNodeAs<Expr>("ContainerToShrink");
   FixItHint Hint;
 
   if (!MemberCall->getLocStart().isMacroID()) {
+    const LangOptions &Opts = getLangOpts();
     std::string ReplacementText;
     if (const auto *UnaryOp = llvm::dyn_cast<UnaryOperator>(Container)) {
       ReplacementText =
Index: clang-tidy/modernize/RedundantVoidArgCheck.cpp
===================================================================
--- clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -45,6 +45,9 @@
 } // namespace
 
 void RedundantVoidArgCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+    return;
+
   Finder->addMatcher(functionDecl(parameterCountIs(0), unless(isImplicit()),
                                   unless(isExternC()))
                          .bind(FunctionId),
@@ -72,10 +75,6 @@
 }
 
 void RedundantVoidArgCheck::check(const MatchFinder::MatchResult &Result) {
-  if (!Result.Context->getLangOpts().CPlusPlus) {
-    return;
-  }
-
   const BoundNodes &Nodes = Result.Nodes;
   if (const auto *Function = Nodes.getNodeAs<FunctionDecl>(FunctionId)) {
     processFunctionDecl(Result, Function);
@@ -120,12 +119,12 @@
     StringRef GrammarLocation) {
   CharSourceRange CharRange = Lexer::makeFileCharRange(
       CharSourceRange::getTokenRange(Range), *Result.SourceManager,
-      Result.Context->getLangOpts());
+      getLangOpts());
 
   std::string DeclText = Lexer::getSourceText(CharRange, *Result.SourceManager,
-                                              Result.Context->getLangOpts())
+                                              getLangOpts())
                              .str();
-  Lexer PrototypeLexer(CharRange.getBegin(), Result.Context->getLangOpts(),
+  Lexer PrototypeLexer(CharRange.getBegin(), getLangOpts(),
                        DeclText.data(), DeclText.data(),
                        DeclText.data() + DeclText.size());
   enum TokenState {
Index: clang-tidy/modernize/RawStringLiteralCheck.cpp
===================================================================
--- clang-tidy/modernize/RawStringLiteralCheck.cpp
+++ clang-tidy/modernize/RawStringLiteralCheck.cpp
@@ -108,15 +108,15 @@
 }
 
 void RawStringLiteralCheck::registerMatchers(MatchFinder *Finder) {
+  // Raw string literals require C++11 or later.
+  if (!getLangOpts().CPlusPlus11)
+    return;
+
   Finder->addMatcher(
       stringLiteral(unless(hasParent(predefinedExpr()))).bind("lit"), this);
 }
 
 void RawStringLiteralCheck::check(const MatchFinder::MatchResult &Result) {
-  // Raw string literals require C++11 or later.
-  if (!Result.Context->getLangOpts().CPlusPlus11)
-    return;
-
   const auto *Literal = Result.Nodes.getNodeAs<StringLiteral>("lit");
   if (Literal->getLocStart().isMacroID())
     return;
@@ -129,7 +129,7 @@
     const MatchFinder::MatchResult &Result, const StringLiteral *Literal) {
   CharSourceRange CharRange = Lexer::makeFileCharRange(
       CharSourceRange::getTokenRange(Literal->getSourceRange()),
-      *Result.SourceManager, Result.Context->getLangOpts());
+      *Result.SourceManager, getLangOpts());
   diag(Literal->getLocStart(),
        "escaped string literal can be written as a raw string literal")
       << FixItHint::CreateReplacement(
Index: clang-tidy/modernize/PassByValueCheck.cpp
===================================================================
--- clang-tidy/modernize/PassByValueCheck.cpp
+++ clang-tidy/modernize/PassByValueCheck.cpp
@@ -203,7 +203,7 @@
     std::string ValueStr =
         Lexer::getSourceText(
             CharSourceRange::getTokenRange(ValueTL.getSourceRange()), SM,
-            Result.Context->getLangOpts())
+            getLangOpts())
             .str();
     ValueStr += ' ';
     Diag << FixItHint::CreateReplacement(TypeRange, ValueStr);
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===================================================================
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -65,7 +65,7 @@
         Using->getLocStart(),
         Lexer::findLocationAfterToken(
             Using->getLocEnd(), tok::semi, *Result.SourceManager,
-            Result.Context->getLangOpts(),
+            getLangOpts(),
             /*SkipTrailingWhitespaceAndNewLine=*/true));
     for (const auto *UsingShadow : Using->shadows()) {
       const auto *TargetDecl = UsingShadow->getTargetDecl()->getCanonicalDecl();
Index: clang-tidy/misc/UnusedRAIICheck.cpp
===================================================================
--- clang-tidy/misc/UnusedRAIICheck.cpp
+++ clang-tidy/misc/UnusedRAIICheck.cpp
@@ -85,7 +85,7 @@
   const auto *TL = selectFirst<TypeLoc>("t", Matches);
   D << FixItHint::CreateInsertion(
       Lexer::getLocForEndOfToken(TL->getLocEnd(), 0, *Result.SourceManager,
-                                 Result.Context->getLangOpts()),
+                                 getLangOpts()),
       Replacement);
 }
 
Index: clang-tidy/misc/UnusedAliasDeclsCheck.cpp
===================================================================
--- clang-tidy/misc/UnusedAliasDeclsCheck.cpp
+++ clang-tidy/misc/UnusedAliasDeclsCheck.cpp
@@ -37,7 +37,7 @@
         AliasDecl->getLocStart(),
         Lexer::findLocationAfterToken(
             AliasDecl->getLocEnd(), tok::semi, *Result.SourceManager,
-            Result.Context->getLangOpts(),
+            getLangOpts(),
             /*SkipTrailingWhitespaceAndNewLine=*/true));
     return;
   }
Index: clang-tidy/misc/UniqueptrResetReleaseCheck.cpp
===================================================================
--- clang-tidy/misc/UniqueptrResetReleaseCheck.cpp
+++ clang-tidy/misc/UniqueptrResetReleaseCheck.cpp
@@ -107,10 +107,10 @@
 
   std::string LeftText = clang::Lexer::getSourceText(
       CharSourceRange::getTokenRange(Left->getSourceRange()),
-      *Result.SourceManager, Result.Context->getLangOpts());
+      *Result.SourceManager, getLangOpts());
   std::string RightText = clang::Lexer::getSourceText(
       CharSourceRange::getTokenRange(Right->getSourceRange()),
-      *Result.SourceManager, Result.Context->getLangOpts());
+      *Result.SourceManager, getLangOpts());
 
   if (ResetMember->isArrow())
     LeftText = "*" + LeftText;
Index: clang-tidy/misc/SuspiciousStringCompareCheck.cpp
===================================================================
--- clang-tidy/misc/SuspiciousStringCompareCheck.cpp
+++ clang-tidy/misc/SuspiciousStringCompareCheck.cpp
@@ -177,7 +177,7 @@
   if (Result.Nodes.getNodeAs<Stmt>("missing-comparison")) {
     SourceLocation EndLoc = Lexer::getLocForEndOfToken(
         Call->getRParenLoc(), 0, Result.Context->getSourceManager(),
-        Result.Context->getLangOpts());
+        getLangOpts());
 
     diag(Call->getLocStart(),
          "function %0 is called without explicitly comparing result")
@@ -187,7 +187,7 @@
   if (const auto *E = Result.Nodes.getNodeAs<Expr>("logical-not-comparison")) {
     SourceLocation EndLoc = Lexer::getLocForEndOfToken(
         Call->getRParenLoc(), 0, Result.Context->getSourceManager(),
-        Result.Context->getLangOpts());
+        getLangOpts());
     SourceLocation NotLoc = E->getLocStart();
 
     diag(Call->getLocStart(),
Index: clang-tidy/misc/StringIntegerAssignmentCheck.cpp
===================================================================
--- clang-tidy/misc/StringIntegerAssignmentCheck.cpp
+++ clang-tidy/misc/StringIntegerAssignmentCheck.cpp
@@ -63,7 +63,7 @@
 
   SourceLocation EndLoc = Lexer::getLocForEndOfToken(
       Argument->getLocEnd(), 0, *Result.SourceManager,
-      Result.Context->getLangOpts());
+      getLangOpts());
   if (IsOneDigit) {
     Diag << FixItHint::CreateInsertion(Loc, IsWideCharType ? "L'" : "'")
          << FixItHint::CreateInsertion(EndLoc, "'");
Index: clang-tidy/misc/InefficientAlgorithmCheck.cpp
===================================================================
--- clang-tidy/misc/InefficientAlgorithmCheck.cpp
+++ clang-tidy/misc/InefficientAlgorithmCheck.cpp
@@ -117,7 +117,7 @@
   FixItHint Hint;
 
   SourceManager &SM = *Result.SourceManager;
-  LangOptions LangOpts = Result.Context->getLangOpts();
+  LangOptions LangOpts = getLangOpts();
 
   CharSourceRange CallRange =
       CharSourceRange::getTokenRange(AlgCall->getSourceRange());
Index: clang-tidy/misc/InaccurateEraseCheck.cpp
===================================================================
--- clang-tidy/misc/InaccurateEraseCheck.cpp
+++ clang-tidy/misc/InaccurateEraseCheck.cpp
@@ -57,10 +57,10 @@
     const auto *AlgCall = Result.Nodes.getNodeAs<CallExpr>("InaccAlgCall");
     std::string ReplacementText = Lexer::getSourceText(
         CharSourceRange::getTokenRange(EndExpr->getSourceRange()),
-        *Result.SourceManager, Result.Context->getLangOpts());
+        *Result.SourceManager, getLangOpts());
     const SourceLocation EndLoc = Lexer::getLocForEndOfToken(
         AlgCall->getLocEnd(), 0, *Result.SourceManager,
-        Result.Context->getLangOpts());
+        getLangOpts());
     Hint = FixItHint::CreateInsertion(EndLoc, ", " + ReplacementText);
   }
 
Index: clang-tidy/misc/AssertSideEffectCheck.cpp
===================================================================
--- clang-tidy/misc/AssertSideEffectCheck.cpp
+++ clang-tidy/misc/AssertSideEffectCheck.cpp
@@ -101,7 +101,7 @@
 
 void AssertSideEffectCheck::check(const MatchFinder::MatchResult &Result) {
   const SourceManager &SM = *Result.SourceManager;
-  const LangOptions LangOpts = Result.Context->getLangOpts();
+  const LangOptions LangOpts = getLangOpts();
   SourceLocation Loc = Result.Nodes.getNodeAs<Stmt>("condStmt")->getLocStart();
 
   StringRef AssertMacroName;
Index: clang-tidy/llvm/TwineLocalCheck.cpp
===================================================================
--- clang-tidy/llvm/TwineLocalCheck.cpp
+++ clang-tidy/llvm/TwineLocalCheck.cpp
@@ -46,7 +46,7 @@
         C->getType()->getCanonicalTypeUnqualified()) {
       SourceLocation EndLoc = Lexer::getLocForEndOfToken(
           VD->getInit()->getLocEnd(), 0, *Result.SourceManager,
-          Result.Context->getLangOpts());
+          getLangOpts());
       Diag << FixItHint::CreateReplacement(TypeRange, "std::string")
            << FixItHint::CreateInsertion(VD->getInit()->getLocStart(), "(")
            << FixItHint::CreateInsertion(EndLoc, ").str()");
Index: clang-tidy/google/ExplicitConstructorCheck.cpp
===================================================================
--- clang-tidy/google/ExplicitConstructorCheck.cpp
+++ clang-tidy/google/ExplicitConstructorCheck.cpp
@@ -92,7 +92,7 @@
              Tok.getRawIdentifier() == "explicit";
     };
     SourceRange ExplicitTokenRange =
-        FindToken(*Result.SourceManager, Result.Context->getLangOpts(),
+        FindToken(*Result.SourceManager, getLangOpts(),
                   Ctor->getOuterLocStart(), Ctor->getLocEnd(), isKWExplicit);
     StringRef ConstructorDescription;
     if (Ctor->isMoveConstructor())
Index: clang-tidy/google/AvoidCStyleCastsCheck.cpp
===================================================================
--- clang-tidy/google/AvoidCStyleCastsCheck.cpp
+++ clang-tidy/google/AvoidCStyleCastsCheck.cpp
@@ -87,7 +87,7 @@
 
 
   // The rest of this check is only relevant to C++.
-  if (!Result.Context->getLangOpts().CPlusPlus)
+  if (!getLangOpts().CPlusPlus)
     return;
   // Ignore code inside extern "C" {} blocks.
   if (!match(expr(hasAncestor(linkageSpecDecl())), *CastExpr, *Result.Context)
@@ -109,7 +109,7 @@
       Lexer::getSourceText(CharSourceRange::getTokenRange(
                                CastExpr->getLParenLoc().getLocWithOffset(1),
                                CastExpr->getRParenLoc().getLocWithOffset(-1)),
-                           SM, Result.Context->getLangOpts());
+                           SM, getLangOpts());
 
   auto diag_builder =
       diag(CastExpr->getLocStart(), "C-style casts are discouraged; use %0");
@@ -123,7 +123,7 @@
       CastText.push_back('(');
       diag_builder << FixItHint::CreateInsertion(
           Lexer::getLocForEndOfToken(SubExpr->getLocEnd(), 0, SM,
-                                     Result.Context->getLangOpts()),
+                                     getLangOpts()),
           ")");
     }
     diag_builder << FixItHint::CreateReplacement(ParenRange, CastText);
Index: clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp
===================================================================
--- clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp
@@ -68,7 +68,7 @@
           CharSourceRange::getTokenRange(
               MatchedCast->getLParenLoc().getLocWithOffset(1),
               MatchedCast->getRParenLoc().getLocWithOffset(-1)),
-          *Result.SourceManager, Result.Context->getLangOpts());
+          *Result.SourceManager, getLangOpts());
 
       auto diag_builder = diag(
           MatchedCast->getLocStart(),
@@ -83,7 +83,7 @@
         diag_builder << FixItHint::CreateInsertion(
             Lexer::getLocForEndOfToken(SubExpr->getLocEnd(), 0,
                                        *Result.SourceManager,
-                                       Result.Context->getLangOpts()),
+                                       getLangOpts()),
             ")");
       }
       auto ParenRange = CharSourceRange::getTokenRange(
Index: clang-tidy/cert/StrToNumCheck.cpp
===================================================================
--- clang-tidy/cert/StrToNumCheck.cpp
+++ clang-tidy/cert/StrToNumCheck.cpp
@@ -214,7 +214,7 @@
 
     // Formatted input functions need further checking of the format string to
     // determine whether a problematic conversion may be happening.
-    Conversion = ClassifyFormatString(FmtStr, Result.Context->getLangOpts(),
+    Conversion = ClassifyFormatString(FmtStr, getLangOpts(),
                                       Result.Context->getTargetInfo());
     if (Conversion != ConversionKind::None)
       FuncDecl = FFD;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to