Skip to content

Commit

Permalink
[clang-tidy] Revert my readability-uppercase-literal-suffix check.
Browse files Browse the repository at this point in the history
There are some lurking issues with the handling of the SourceManager.
Somehow sometimes we end up extracting completely wrong
portions of the source buffer.

Reverts r344772, r44760, r344758, r344755.

llvm-svn: 345305
  • Loading branch information
LebedevRI committed Oct 25, 2018
1 parent cf95524 commit 5aa945e
Show file tree
Hide file tree
Showing 24 changed files with 19 additions and 1,454 deletions.
10 changes: 0 additions & 10 deletions clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "../misc/StaticAssertCheck.h"
#include "../misc/ThrowByValueCatchByReferenceCheck.h"
#include "../performance/MoveConstructorInitCheck.h"
#include "../readability/UppercaseLiteralSuffixCheck.h"
#include "CommandProcessorCheck.h"
#include "DontModifyStdNamespaceCheck.h"
#include "FloatLoopCounter.h"
Expand Down Expand Up @@ -66,8 +65,6 @@ class CERTModule : public ClangTidyModule {
// C checkers
// DCL
CheckFactories.registerCheck<misc::StaticAssertCheck>("cert-dcl03-c");
CheckFactories.registerCheck<readability::UppercaseLiteralSuffixCheck>(
"cert-dcl16-c");
// ENV
CheckFactories.registerCheck<CommandProcessorCheck>("cert-env33-c");
// FLP
Expand All @@ -81,13 +78,6 @@ class CERTModule : public ClangTidyModule {
CheckFactories.registerCheck<ProperlySeededRandomGeneratorCheck>(
"cert-msc32-c");
}

ClangTidyOptions getModuleOptions() override {
ClangTidyOptions Options;
ClangTidyOptions::OptionMap &Opts = Options.CheckOptions;
Opts["cert-dcl16-c.NewSuffixes"] = "L;LL;LU;LLU";
return Options;
}
};

} // namespace cert
Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/clang-tidy/cert/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ add_clang_library(clangTidyCERTModule
clangTidyGoogleModule
clangTidyMiscModule
clangTidyPerformanceModule
clangTidyReadabilityModule
clangTidyUtils
)
3 changes: 0 additions & 3 deletions clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "../readability/BracesAroundStatementsCheck.h"
#include "../readability/FunctionSizeCheck.h"
#include "../readability/IdentifierNamingCheck.h"
#include "../readability/UppercaseLiteralSuffixCheck.h"
#include "ExceptionBaseclassCheck.h"
#include "MultiwayPathsCoveredCheck.h"
#include "NoAssemblerCheck.h"
Expand Down Expand Up @@ -101,8 +100,6 @@ class HICPPModule : public ClangTidyModule {
"hicpp-use-nullptr");
CheckFactories.registerCheck<modernize::UseOverrideCheck>(
"hicpp-use-override");
CheckFactories.registerCheck<readability::UppercaseLiteralSuffixCheck>(
"hicpp-uppercase-literal-suffix");
CheckFactories.registerCheck<cppcoreguidelines::ProTypeVarargCheck>(
"hicpp-vararg");
}
Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/clang-tidy/readability/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ add_clang_library(clangTidyReadabilityModule
StaticDefinitionInAnonymousNamespaceCheck.cpp
StringCompareCheck.cpp
UniqueptrDeleteReleaseCheck.cpp
UppercaseLiteralSuffixCheck.cpp

LINK_LIBS
clangAST
Expand Down
21 changes: 19 additions & 2 deletions clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "IdentifierNamingCheck.h"

#include "../utils/ASTUtils.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Lex/PPCallbacks.h"
Expand Down Expand Up @@ -682,7 +681,25 @@ static void addUsage(IdentifierNamingCheck::NamingCheckFailureMap &Failures,
if (!Failure.ShouldFix)
return;

Failure.ShouldFix = utils::rangeCanBeFixed(Range, SourceMgr);
// Check if the range is entirely contained within a macro argument.
SourceLocation MacroArgExpansionStartForRangeBegin;
SourceLocation MacroArgExpansionStartForRangeEnd;
bool RangeIsEntirelyWithinMacroArgument =
SourceMgr &&
SourceMgr->isMacroArgExpansion(Range.getBegin(),
&MacroArgExpansionStartForRangeBegin) &&
SourceMgr->isMacroArgExpansion(Range.getEnd(),
&MacroArgExpansionStartForRangeEnd) &&
MacroArgExpansionStartForRangeBegin == MacroArgExpansionStartForRangeEnd;

// Check if the range contains any locations from a macro expansion.
bool RangeContainsMacroExpansion = RangeIsEntirelyWithinMacroArgument ||
Range.getBegin().isMacroID() ||
Range.getEnd().isMacroID();

bool RangeCanBeFixed =
RangeIsEntirelyWithinMacroArgument || !RangeContainsMacroExpansion;
Failure.ShouldFix = RangeCanBeFixed;
}

/// Convenience method when the usage to be added is a NamedDecl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "StaticDefinitionInAnonymousNamespaceCheck.h"
#include "StringCompareCheck.h"
#include "UniqueptrDeleteReleaseCheck.h"
#include "UppercaseLiteralSuffixCheck.h"

namespace clang {
namespace tidy {
Expand Down Expand Up @@ -103,8 +102,6 @@ class ReadabilityModule : public ClangTidyModule {
"readability-simplify-boolean-expr");
CheckFactories.registerCheck<UniqueptrDeleteReleaseCheck>(
"readability-uniqueptr-delete-release");
CheckFactories.registerCheck<UppercaseLiteralSuffixCheck>(
"readability-uppercase-literal-suffix");
}
};

Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5aa945e

Please sign in to comment.