Index: Makefile =================================================================== --- /dev/null +++ Makefile @@ -0,0 +1,41 @@ +##===- tools/extra/Makefile --------------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +CLANG_LEVEL := ../.. + +include $(CLANG_LEVEL)/../../Makefile.config + +PARALLEL_DIRS := tool-template modularize pp-trace +DIRS := clang-apply-replacements clang-rename clang-tidy clang-query unittests + +include $(CLANG_LEVEL)/Makefile + +### +# Handle the nested test suite. + +ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT)) +$(RecursiveTargets):: + $(Verb) for dir in test; do \ + if [ -f $(PROJ_SRC_DIR)/$${dir}/Makefile ] && [ ! -f $${dir}/Makefile ]; then \ + $(MKDIR) $${dir}; \ + $(CP) $(PROJ_SRC_DIR)/$${dir}/Makefile $${dir}/Makefile; \ + fi \ + done +endif + +test:: + @ $(MAKE) -C test + +report:: + @ $(MAKE) -C test report + +clean:: + @ $(MAKE) -C test clean + +.PHONY: test report clean Index: clang-apply-replacements/Makefile =================================================================== --- /dev/null +++ clang-apply-replacements/Makefile @@ -0,0 +1,15 @@ +##===- clang-apply-replacements/Makefile -------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +CLANG_LEVEL := ../../.. +include $(CLANG_LEVEL)/../../Makefile.config + +DIRS = lib/Tooling tool + +include $(CLANG_LEVEL)/Makefile Index: clang-apply-replacements/lib/Tooling/Makefile =================================================================== --- /dev/null +++ clang-apply-replacements/lib/Tooling/Makefile @@ -0,0 +1,14 @@ +##===- clang-apply-replacements/lib/Tooling/Makefile -------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +CLANG_LEVEL := ../../../../.. +LIBRARYNAME := clangApplyReplacements +include $(CLANG_LEVEL)/../../Makefile.config +include $(CLANG_LEVEL)/Makefile +CPP.Flags += -I$(PROJ_SRC_DIR)/../../include Index: clang-apply-replacements/tool/Makefile =================================================================== --- /dev/null +++ clang-apply-replacements/tool/Makefile @@ -0,0 +1,29 @@ +##===- clang-apply-replacements/tool/Makefile --------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +CLANG_LEVEL := ../../../.. +include $(CLANG_LEVEL)/../../Makefile.config + +TOOLNAME = clang-apply-replacements + +# No plugins, optimize startup time. +TOOL_NO_EXPORTS = 1 + +SOURCES = ClangApplyReplacementsMain.cpp + +LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc mcparser option +USEDLIBS = clangApplyReplacements.a clangFormat.a \ + clangTooling.a clangToolingCore.a clangFrontend.a \ + clangSerialization.a clangDriver.a clangRewriteFrontend.a \ + clangRewrite.a clangParse.a clangSema.a clangAnalysis.a \ + clangAST.a clangASTMatchers.a clangEdit.a clangLex.a clangBasic.a + +include $(CLANG_LEVEL)/Makefile + +CPP.Flags += -I$(PROJ_SRC_DIR)/../include Index: clang-query/Makefile =================================================================== --- /dev/null +++ clang-query/Makefile @@ -0,0 +1,16 @@ +##===- tools/extra/clang-query/Makefile --------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +CLANG_LEVEL := ../../.. +LIBRARYNAME := clangQuery +include $(CLANG_LEVEL)/../../Makefile.config + +DIRS = tool + +include $(CLANG_LEVEL)/Makefile Index: clang-query/tool/Makefile =================================================================== --- /dev/null +++ clang-query/tool/Makefile @@ -0,0 +1,39 @@ +##===- tools/extra/clang-query/tool/Makefile ---------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +CLANG_LEVEL := ../../../.. +include $(CLANG_LEVEL)/../../Makefile.config + +TOOLNAME = clang-query + +# No plugins, optimize startup time. +TOOL_NO_EXPORTS = 1 + +SOURCES = ClangQuery.cpp + +LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc mcparser option +USEDLIBS = clangQuery.a clangDynamicASTMatchers.a clangFormat.a clangTooling.a \ + clangFrontend.a clangSerialization.a clangDriver.a clangRewriteFrontend.a \ + LLVMLineEditor.a clangRewrite.a clangParse.a clangSema.a clangAnalysis.a \ + clangAST.a clangASTMatchers.a clangEdit.a clangLex.a clangBasic.a + +include $(CLANG_LEVEL)/Makefile + +CPP.Flags += -I$(PROJ_SRC_DIR)/.. + +# BUILT_SOURCES gets used as a prereq for many top-level targets. However, at +# the point those targets are defined, $(ObjDir) hasn't been defined and so the +# directory to create becomes // which is not what we want. So instead, +# this .objdir recipe is defined at at point where $(ObjDir) is defined and +# it's specialized to $(ObjDir) to ensure it only works on targets we want it +# to. +$(ObjDir)/%.objdir: + $(Verb) $(MKDIR) $(ObjDir)/$* > /dev/null + $(Verb) $(DOTDIR_TIMESTAMP_COMMAND) > $@ + Index: clang-rename/Makefile =================================================================== --- /dev/null +++ clang-rename/Makefile @@ -0,0 +1,16 @@ +##===- tools/extra/clang-rename/Makefile -------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +CLANG_LEVEL := ../../.. +LIBRARYNAME = clangRename +include $(CLANG_LEVEL)/../../Makefile.config + +DIRS = tool + +include $(CLANG_LEVEL)/Makefile Index: clang-rename/tool/Makefile =================================================================== --- /dev/null +++ clang-rename/tool/Makefile @@ -0,0 +1,13 @@ +CLANG_LEVEL := ../../../.. +TOOLNAME = clang-rename +include $(CLANG_LEVEL)/../../Makefile.config +LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option +USEDLIBS = clangRename.a clangFrontend.a clangSerialization.a clangDriver.a \ + clangTooling.a clangToolingCore.a \ + clangParse.a clangSema.a clangIndex.a \ + clangStaticAnalyzerFrontend.a clangStaticAnalyzerCheckers.a \ + clangStaticAnalyzerCore.a clangAnalysis.a clangRewriteFrontend.a \ + clangRewrite.a clangEdit.a clangAST.a clangLex.a clangBasic.a + +include $(CLANG_LEVEL)/Makefile + Index: clang-tidy/Makefile =================================================================== --- /dev/null +++ clang-tidy/Makefile @@ -0,0 +1,16 @@ +##===- tools/extra/clang-tidy/Makefile ---------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +CLANG_LEVEL := ../../.. +LIBRARYNAME := clangTidy +include $(CLANG_LEVEL)/../../Makefile.config + +DIRS = utils cert cppcoreguidelines readability llvm google misc modernize performance tool + +include $(CLANG_LEVEL)/Makefile Index: clang-tidy/cert/Makefile =================================================================== --- /dev/null +++ clang-tidy/cert/Makefile @@ -0,0 +1,12 @@ +##===- clang-tidy/cert/Makefile ----------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## +CLANG_LEVEL := ../../../.. +LIBRARYNAME := clangTidyCERTModule + +include $(CLANG_LEVEL)/Makefile Index: clang-tidy/cppcoreguidelines/Makefile =================================================================== --- /dev/null +++ clang-tidy/cppcoreguidelines/Makefile @@ -0,0 +1,12 @@ +##===- clang-tidy/cppcoreguidelines/Makefile ----------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## +CLANG_LEVEL := ../../../.. +LIBRARYNAME := clangTidyCppCoreGuidelinesModule + +include $(CLANG_LEVEL)/Makefile Index: clang-tidy/google/Makefile =================================================================== --- /dev/null +++ clang-tidy/google/Makefile @@ -0,0 +1,12 @@ +##===- clang-tidy/google/Makefile --------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## +CLANG_LEVEL := ../../../.. +LIBRARYNAME := clangTidyGoogleModule + +include $(CLANG_LEVEL)/Makefile Index: clang-tidy/llvm/Makefile =================================================================== --- /dev/null +++ clang-tidy/llvm/Makefile @@ -0,0 +1,12 @@ +##===- clang-tidy/llvm/Makefile ----------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## +CLANG_LEVEL := ../../../.. +LIBRARYNAME := clangTidyLLVMModule + +include $(CLANG_LEVEL)/Makefile Index: clang-tidy/misc/AssertSideEffectCheck.cpp =================================================================== --- clang-tidy/misc/AssertSideEffectCheck.cpp +++ clang-tidy/misc/AssertSideEffectCheck.cpp @@ -83,18 +83,11 @@ } void AssertSideEffectCheck::registerMatchers(MatchFinder *Finder) { - auto DescendantWithSideEffect = - hasDescendant(expr(hasSideEffect(CheckFunctionCalls))); - auto ConditionWithSideEffect = hasCondition(DescendantWithSideEffect); + auto ConditionWithSideEffect = + hasCondition(hasDescendant(expr(hasSideEffect(CheckFunctionCalls)))); Finder->addMatcher( - stmt( - anyOf(conditionalOperator(ConditionWithSideEffect), - ifStmt(ConditionWithSideEffect), - unaryOperator(hasOperatorName("!"), - hasUnaryOperand(unaryOperator( - hasOperatorName("!"), - hasUnaryOperand(DescendantWithSideEffect)))))) - .bind("condStmt"), + stmt(anyOf(conditionalOperator(ConditionWithSideEffect), + ifStmt(ConditionWithSideEffect))).bind("condStmt"), this); } Index: clang-tidy/misc/Makefile =================================================================== --- /dev/null +++ clang-tidy/misc/Makefile @@ -0,0 +1,12 @@ +##===- clang-tidy/misc/Makefile ----------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## +CLANG_LEVEL := ../../../.. +LIBRARYNAME := clangTidyMiscModule + +include $(CLANG_LEVEL)/Makefile Index: clang-tidy/misc/VirtualNearMissCheck.cpp =================================================================== --- clang-tidy/misc/VirtualNearMissCheck.cpp +++ clang-tidy/misc/VirtualNearMissCheck.cpp @@ -178,8 +178,7 @@ bool IsPossible = !BaseMD->isImplicit() && !isa(BaseMD) && !isa(BaseMD) && BaseMD->isVirtual() && - !BaseMD->isOverloadedOperator() && - !isa(BaseMD); + !BaseMD->isOverloadedOperator(); PossibleMap[Id] = IsPossible; return IsPossible; } @@ -211,9 +210,8 @@ return; Finder->addMatcher( - cxxMethodDecl( - unless(anyOf(isOverride(), isImplicit(), cxxConstructorDecl(), - cxxDestructorDecl(), cxxConversionDecl()))) + cxxMethodDecl(unless(anyOf(isOverride(), isImplicit(), + cxxConstructorDecl(), cxxDestructorDecl()))) .bind("method"), this); } Index: clang-tidy/modernize/CMakeLists.txt =================================================================== --- clang-tidy/modernize/CMakeLists.txt +++ clang-tidy/modernize/CMakeLists.txt @@ -6,6 +6,7 @@ MakeUniqueCheck.cpp ModernizeTidyModule.cpp PassByValueCheck.cpp + RawStringLiteralCheck.cpp RedundantVoidArgCheck.cpp ReplaceAutoPtrCheck.cpp ShrinkToFitCheck.cpp Index: clang-tidy/modernize/Makefile =================================================================== --- /dev/null +++ clang-tidy/modernize/Makefile @@ -0,0 +1,12 @@ +##===- clang-tidy/modernize/Makefile -----------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## +CLANG_LEVEL := ../../../.. +LIBRARYNAME := clangTidyModernizeModule + +include $(CLANG_LEVEL)/Makefile Index: clang-tidy/modernize/ModernizeTidyModule.cpp =================================================================== --- clang-tidy/modernize/ModernizeTidyModule.cpp +++ clang-tidy/modernize/ModernizeTidyModule.cpp @@ -13,6 +13,7 @@ #include "LoopConvertCheck.h" #include "MakeUniqueCheck.h" #include "PassByValueCheck.h" +#include "RawStringLiteralCheck.h" #include "RedundantVoidArgCheck.h" #include "ReplaceAutoPtrCheck.h" #include "ShrinkToFitCheck.h" @@ -33,6 +34,8 @@ CheckFactories.registerCheck("modernize-loop-convert"); CheckFactories.registerCheck("modernize-make-unique"); CheckFactories.registerCheck("modernize-pass-by-value"); + CheckFactories.registerCheck( + "modernize-raw-string-literal"); CheckFactories.registerCheck( "modernize-redundant-void-arg"); CheckFactories.registerCheck( Index: clang-tidy/modernize/RawStringLiteralCheck.h =================================================================== --- /dev/null +++ clang-tidy/modernize/RawStringLiteralCheck.h @@ -0,0 +1,41 @@ +//===--- RawStringLiteralCheck.h - clang-tidy--------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_RAW_STRING_LITERAL_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_RAW_STRING_LITERAL_H + +#include "../ClangTidy.h" + +namespace clang { +namespace tidy { +namespace modernize { + +/// This check replaces string literals with escaped characters to +/// raw string literals. +/// +/// For the user-facing documentation see: +/// http://clang.llvm.org/extra/clang-tidy/checks/modernize-raw-string-literal.html +class RawStringLiteralCheck : public ClangTidyCheck { +public: + RawStringLiteralCheck(StringRef Name, ClangTidyContext *Context) + : ClangTidyCheck(Name, Context) {} + void registerMatchers(ast_matchers::MatchFinder *Finder) override; + void check(const ast_matchers::MatchFinder::MatchResult &Result) override; + +private: + void replaceWithRawStringLiteral( + const ast_matchers::MatchFinder::MatchResult &Result, + const StringLiteral *Literal); +}; + +} // namespace modernize +} // namespace tidy +} // namespace clang + +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_RAW_STRING_LITERAL_H Index: clang-tidy/modernize/RawStringLiteralCheck.cpp =================================================================== --- /dev/null +++ clang-tidy/modernize/RawStringLiteralCheck.cpp @@ -0,0 +1,132 @@ +//===--- RawStringLiteralCheck.cpp - clang-tidy----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "RawStringLiteralCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Lex/Lexer.h" + +using namespace clang::ast_matchers; + +namespace clang { +namespace tidy { +namespace modernize { + +namespace { + +bool endsWithNewLine(StringRef Text, size_t NewLinePos) { + return NewLinePos == Text.size() - 3; +} + +bool spaceBeforeNewLine(StringRef Text, size_t NewLinePos) { + return NewLinePos > 0 && Text[NewLinePos - 1] == ' '; +} + +bool contains(StringRef HayStack, StringRef Needle) { + return HayStack.find(Needle) != StringRef::npos; +} + +bool containsEscapes(StringRef HayStack, StringRef Escapes) { + for (size_t BackSlash = HayStack.find('\\'); BackSlash != StringRef::npos; + BackSlash = HayStack.find('\\', BackSlash + 2)) { + if (Escapes.find(HayStack[BackSlash + 1]) == StringRef::npos) + return false; + } + + return true; +} + +bool containsEscapedCharacters(const MatchFinder::MatchResult &Result, + const StringLiteral *Literal) { + if (!Literal->isAscii()) + return false; + + StringRef Bytes = Literal->getBytes(); + // Non-printing characters except newline disqualify this literal: + // \007 = \a bell + // \010 = \b backspace + // \011 = \t horizontal tab + // \012 = \n new line + // \013 = \v vertical tab + // \014 = \f form feed + // \015 = \r carriage return + // \177 = delete + if (Bytes.find_first_of("\001\002\003\004\005\006\a" + "\b\t\v\f\r\016\017" + "\020\021\022\023\024\025\026\027" + "\030\031\032\033\034\035\036\037" + "\177") != StringRef::npos) + return false; + + // The NUL character disqualifies this literal. + if (Bytes.find_first_of(StringRef("\000", 1)) != StringRef::npos) + return false; + + CharSourceRange CharRange = Lexer::makeFileCharRange( + CharSourceRange::getTokenRange(Literal->getSourceRange()), + *Result.SourceManager, Result.Context->getLangOpts()); + StringRef Text = Lexer::getSourceText(CharRange, *Result.SourceManager, + Result.Context->getLangOpts()); + + // Already a raw string literal if R comes before ". + if (Text.find('R') < Text.find('"')) + return false; + + const size_t NewLinePos = Text.find(R"(\n)"); + if (NewLinePos != StringRef::npos) + return !endsWithNewLine(Text, NewLinePos) && + !spaceBeforeNewLine(Text, NewLinePos); + + return containsEscapes(Text, R"lit('\"?x01)lit"); +} + +bool containsDelimiter(StringRef Bytes, const std::string &Delimiter) { + return Bytes.find(")" + Delimiter + R"quote(")quote") != StringRef::npos; +} + +std::string asRawStringLiteral(const StringLiteral *Literal) { + const StringRef Bytes = Literal->getBytes(); + std::string Delimiter; + for (int Counter = 0; containsDelimiter(Bytes, Delimiter); ++Counter) { + Delimiter = (Counter == 0) ? "lit" : "lit" + std::to_string(Counter); + } + + return (R"(R")" + Delimiter + "(" + Bytes + ")" + Delimiter + R"(")").str(); +} + +} // namespace + +void RawStringLiteralCheck::registerMatchers(MatchFinder *Finder) { + Finder->addMatcher(stringLiteral().bind("lit"), this); +} + +void RawStringLiteralCheck::check(const MatchFinder::MatchResult &Result) { + // Raw string literals require C++11 or later. + if (!Result.Context->getLangOpts().CPlusPlus11) + return; + + if (const auto *Literal = Result.Nodes.getNodeAs("lit")) { + if (containsEscapedCharacters(Result, Literal)) + replaceWithRawStringLiteral(Result, Literal); + } +} + +void RawStringLiteralCheck::replaceWithRawStringLiteral( + const MatchFinder::MatchResult &Result, const StringLiteral *Literal) { + CharSourceRange CharRange = Lexer::makeFileCharRange( + CharSourceRange::getTokenRange(Literal->getSourceRange()), + *Result.SourceManager, Result.Context->getLangOpts()); + diag(Literal->getLocStart(), + "escaped string literal can be written as a raw string literal") + << FixItHint::CreateReplacement(CharRange, asRawStringLiteral(Literal)); +} + +} // namespace modernize +} // namespace tidy +} // namespace clang Index: clang-tidy/performance/Makefile =================================================================== --- /dev/null +++ clang-tidy/performance/Makefile @@ -0,0 +1,12 @@ +##===- clang-tidy/performance/Makefile ---------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## +CLANG_LEVEL := ../../../.. +LIBRARYNAME := clangTidyPerformanceModule + +include $(CLANG_LEVEL)/Makefile Index: clang-tidy/readability/IdentifierNamingCheck.cpp =================================================================== --- clang-tidy/readability/IdentifierNamingCheck.cpp +++ clang-tidy/readability/IdentifierNamingCheck.cpp @@ -504,7 +504,7 @@ static void addUsage(IdentifierNamingCheck::NamingCheckFailureMap &Failures, const NamedDecl *Decl, SourceRange Range, const SourceManager *SM) { - // Do nothing if the provided range is invalid. + // Do nothin if the provided range is invalid if (Range.getBegin().isInvalid() || Range.getEnd().isInvalid()) return; Index: clang-tidy/readability/Makefile =================================================================== --- /dev/null +++ clang-tidy/readability/Makefile @@ -0,0 +1,12 @@ +##===- clang-tidy/readability/Makefile ---------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## +CLANG_LEVEL := ../../../.. +LIBRARYNAME := clangTidyReadability + +include $(CLANG_LEVEL)/Makefile Index: clang-tidy/tool/Makefile =================================================================== --- /dev/null +++ clang-tidy/tool/Makefile @@ -0,0 +1,49 @@ +##===- clang-tidy/tool/Makefile ----------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +CLANG_LEVEL := ../../../.. + +TOOLNAME = clang-tidy + +# No plugins, optimize startup time. +TOOL_NO_EXPORTS = 1 + +include $(CLANG_LEVEL)/../../Makefile.config +LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option +USEDLIBS = clangTidy.a clangTidyLLVMModule.a clangTidyGoogleModule.a \ + clangTidyMiscModule.a clangTidyModernizeModule.a \ + clangTidyPerformanceModule.a clangTidyReadability.a \ + clangTidyUtils.a clangTidyCERTModule.a clangStaticAnalyzerFrontend.a \ + clangTidyCppCoreGuidelinesModule.a \ + clangStaticAnalyzerCheckers.a clangStaticAnalyzerCore.a \ + clangFormat.a clangASTMatchers.a clangTooling.a clangToolingCore.a \ + clangFrontend.a clangSerialization.a clangDriver.a clangParse.a \ + clangSema.a clangAnalysis.a clangRewriteFrontend.a clangRewrite.a \ + clangEdit.a clangAST.a clangLex.a clangBasic.a + +include $(CLANG_LEVEL)/Makefile + +PROJ_sharedir := $(DESTDIR)$(PROJ_prefix)/share/clang + +FILESLIST := $(notdir $(wildcard $(PROJ_SRC_DIR)/*.py)) + +SRCFILES := $(addprefix $(PROJ_SRC_DIR)/, $(FILESLIST)) +DESTFILES := $(addprefix $(PROJ_sharedir)/, $(FILESLIST)) + +$(PROJ_sharedir): + $(Echo) Making install directory: $@ + $(Verb) $(MKDIR) $@ + +$(DESTFILES): $(SRCFILES) $(PROJ_sharedir) + +$(PROJ_sharedir)/%.py: $(PROJ_SRC_DIR)/%.py + $(Echo) Installing script file: $(notdir $<) + $(Verb) $(ScriptInstall) $< $(PROJ_sharedir) + +install-local:: $(DESTFILES) Index: clang-tidy/utils/Makefile =================================================================== --- /dev/null +++ clang-tidy/utils/Makefile @@ -0,0 +1,12 @@ +##===- clang-tidy/google/Makefile --------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## +CLANG_LEVEL := ../../../.. +LIBRARYNAME := clangTidyUtils + +include $(CLANG_LEVEL)/Makefile Index: docs/Makefile =================================================================== --- /dev/null +++ docs/Makefile @@ -0,0 +1,160 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +all: doxygen html + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + -rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/ExtraClangTools.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/ExtraClangTools.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/ExtraClangTools" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/ExtraClangTools" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +doxygen: + mkdir -p $(BUILDDIR)/html/doxygen + doxygen + Index: docs/clang-tidy/checks/list.rst =================================================================== --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -69,6 +69,7 @@ modernize-loop-convert modernize-make-unique modernize-pass-by-value + modernize-raw-string-literal modernize-redundant-void-arg modernize-replace-auto-ptr modernize-shrink-to-fit Index: docs/clang-tidy/checks/modernize-raw-string-literal.rst =================================================================== --- /dev/null +++ docs/clang-tidy/checks/modernize-raw-string-literal.rst @@ -0,0 +1,56 @@ +.. title:: clang-tidy - modernize-raw-string-literal + +modernize-raw-string-literal +============================ + +This check selectively replaces string literals containing escaped characters +with raw string literals. + +Example: + +.. code-blocK:: c++ + + const char *const Quotes{"embedded \"quotes\""}; + const char *const Paragraph{"Line one.\nLine two.\nLine three.\n"}; + const char *const SingleLine{"Single line.\n"}; + const char *const TrailingSpace{"Look here -> \n"}; + const char *const Tab{"One\tTwo\n"}; + const char *const Bell{"Hello!\a And welcome!"}; + const char *const Path{"C:\\Program Files\\Vendor\\Application.exe"}; + const char *const RegEx{"\\w\\([a-z]\\)"}; + +becomes + +.. code-block:: c++ + + const char *const Quotes{R"(embedded "quotes")"}; + const char *const Paragraph{R"(Line one. + Line two. + Line three. + )"}; + const char *const SingleLine{"Single line.\n"}; + const char *const TrailingSpace{"Look here -> \n"}; + const char *const Tab{"One\tTwo\n"}; + const char *const Bell{"Hello!\a And welcome!"}; + const char *const Path{R"(C:\Program Files\Vendor\Application.exe)"}; + const char *const RegEx{R"(\w\([a-z]\))"}; + +The presence of any of the following escapes can cause the string to be +converted to a raw string literal: ``\\``, ``\'``, ``\"``, ``\?``, +and octal or hexadecimal escapes for printable ASCII characters. + +If an escaped newline is present in the middle a string literal, it is +replaced with a physical newline, unless the newline is preceded by a space. +Trailing whitespace at the end of a source code line is not visible in an +editor. Trailing whitespace is likely to be stripped by editors and other +tools, changing the meaning of the literal. + +A string literal containing only a single escaped newline at the end is a +common way of describing a line of text output. Introducing physical newlines +with raw string literals in this case is likely to impede readability. These +string literals are left unchanged. + +An escaped horizontal tab, form feed, or vertical tab prevents the string +literal from being converted. Unlike a physical newline, the presence of a +horizontal tab, form feed or vertical tab in source code is not visually +obvious. Index: modularize/Makefile =================================================================== --- /dev/null +++ modularize/Makefile @@ -0,0 +1,24 @@ +##===- tools/modularize/Makefile ---------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +CLANG_LEVEL := ../../.. + +TOOLNAME = modularize +NO_INSTALL = 0 + +# No plugins, optimize startup time. +TOOL_NO_EXPORTS = 1 + +LINK_COMPONENTS := mcparser bitreader support mc option TransformUtils +USEDLIBS = clangFrontend.a clangSerialization.a clangDriver.a \ + clangTooling.a clangParse.a clangSema.a clangAnalysis.a \ + clangEdit.a clangAST.a clangLex.a clangBasic.a + +include $(CLANG_LEVEL)/Makefile + Index: pp-trace/Makefile =================================================================== --- /dev/null +++ pp-trace/Makefile @@ -0,0 +1,22 @@ +##===- extra/pp-trace/Makefile --------------------------*- Makefile -*---===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===---------------------------------------------------------------------===## + +CLANG_LEVEL := ../../.. + +TOOLNAME = pp-trace + +# No plugins, optimize startup time. +TOOL_NO_EXPORTS = 1 + +LINK_COMPONENTS := mcparser bitreader support mc option TransformUtils +USEDLIBS = clangFrontend.a clangSerialization.a clangDriver.a \ + clangTooling.a clangParse.a clangSema.a clangAnalysis.a \ + clangEdit.a clangAST.a clangLex.a clangBasic.a + +include $(CLANG_LEVEL)/Makefile Index: test/Makefile =================================================================== --- /dev/null +++ test/Makefile @@ -0,0 +1,73 @@ +##===- tools/extra/test/Makefile ---------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +CLANG_LEVEL := ../../.. +include $(CLANG_LEVEL)/Makefile + +# Test in all immediate subdirectories if unset. +ifdef TESTSUITE +TESTDIRS := $(TESTSUITE:%=$(PROJ_SRC_DIR)/%) +else +TESTDIRS ?= $(PROJ_SRC_DIR) +endif + +# 'lit' wants objdir paths, so it will pick up the lit.site.cfg. +TESTDIRS := $(TESTDIRS:$(PROJ_SRC_DIR)%=$(PROJ_OBJ_DIR)%) + +# Allow EXTRA_TESTDIRS to provide additional test directories. +TESTDIRS += $(EXTRA_TESTDIRS) + +ifndef TESTARGS +ifdef VERBOSE +TESTARGS = -v +else +TESTARGS = -s -v +endif +endif + +# Make sure any extra test suites can find the main site config. +LIT_ARGS := --param clang_site_config=$(PROJ_OBJ_DIR)/lit.site.cfg + +ifdef VG + LIT_ARGS += "--vg" +endif + +all:: lit.site.cfg Unit/lit.site.cfg + @ echo '--- Running the Clang extra tools tests for $(TARGET_TRIPLE) ---' + @ $(PYTHON) $(LLVM_SRC_ROOT)/utils/lit/lit.py \ + $(LIT_ARGS) $(TESTARGS) $(TESTDIRS) + +FORCE: + +lit.site.cfg: FORCE + @echo "Making lit.site.cfg for Clang extra tools..." + @$(ECHOPATH) s=@LLVM_TOOLS_DIR@=$(ToolDir)=g >> lit.tmp + @$(ECHOPATH) s=@LLVM_LIBS_DIR@=$(LibDir)=g >> lit.tmp + @$(ECHOPATH) s=@CLANG_TOOLS_SOURCE_DIR@=$(PROJ_SRC_DIR)/..=g >> lit.tmp + @$(ECHOPATH) s=@CLANG_TOOLS_BINARY_DIR@=$(PROJ_OBJ_DIR)/..=g >> lit.tmp + @$(ECHOPATH) s=@CLANG_TOOLS_DIR@=$(ToolDir)=g >> lit.tmp + @$(ECHOPATH) s=@PYTHON_EXECUTABLE@=$(PYTHON)=g >> lit.tmp + @$(ECHOPATH) s=@TARGET_TRIPLE@=$(TARGET_TRIPLE)=g >> lit.tmp + @sed -f lit.tmp $(PROJ_SRC_DIR)/lit.site.cfg.in > $@ + @-rm -f lit.tmp + +Unit/lit.site.cfg: FORCE + @echo "Making Unit/lit.site.cfg for Clang extra tools..." + @$(MKDIR) $(dir $@) + @$(ECHOPATH) s=@LLVM_LIBS_DIR@=$(LibDir)=g >> unit.tmp + @$(ECHOPATH) s=@CLANG_TOOLS_BINARY_DIR@=$(PROJ_OBJ_DIR)/..=g >> unit.tmp + @$(ECHOPATH) s=@TARGET_TRIPLE@=$(TARGET_TRIPLE)=g >> unit.tmp + @$(ECHOPATH) s=@CLANG_TOOLS_SOURCE_DIR@=$(PROJ_SRC_DIR)/..=g >> unit.tmp + @sed -f unit.tmp $(PROJ_SRC_DIR)/Unit/lit.site.cfg.in > $@ + @-rm -f unit.tmp + +clean:: + @ find . -name Output | xargs rm -fr + +.PHONY: all report clean Index: test/clang-tidy/misc-assert-side-effect.cpp =================================================================== --- test/clang-tidy/misc-assert-side-effect.cpp +++ test/clang-tidy/misc-assert-side-effect.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-assert-side-effect %t -- -config="{CheckOptions: [{key: misc-assert-side-effect.CheckFunctionCalls, value: 1}, {key: misc-assert-side-effect.AssertMacros, value: 'assert,assert2,my_assert,convoluted_assert,msvc_assert'}]}" -- -fexceptions +// RUN: %check_clang_tidy %s misc-assert-side-effect %t -- -config="{CheckOptions: [{key: misc-assert-side-effect.CheckFunctionCalls, value: 1}, {key: misc-assert-side-effect.AssertMacros, value: 'assert,assert2,my_assert,convoluted_assert'}]}" -- -fexceptions //===--- assert definition block ------------------------------------------===// int abort() { return 0; } @@ -35,12 +35,6 @@ #define wrap2(x) wrap1(x) #define convoluted_assert(x) wrap2(x) -#define msvc_assert(expression) (void)( \ - (!!(expression)) || \ - (abort(), 0) \ - ) - - //===----------------------------------------------------------------------===// class MyClass { @@ -107,8 +101,5 @@ assert2(1 == 2 - 1); - msvc_assert(mc2 = mc); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found msvc_assert() with side effect - return 0; } Index: test/clang-tidy/misc-virtual-near-miss.cpp =================================================================== --- test/clang-tidy/misc-virtual-near-miss.cpp +++ test/clang-tidy/misc-virtual-near-miss.cpp @@ -69,7 +69,6 @@ int decaz(const char str[]); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::decaz' has {{.*}} 'Mother::decay' - operator bool(); private: void funk(); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: method 'Child::funk' has {{.*}} 'Father::func' Index: test/clang-tidy/modernize-raw-string-literal.cpp =================================================================== --- /dev/null +++ test/clang-tidy/modernize-raw-string-literal.cpp @@ -0,0 +1,68 @@ +// RUN: %check_clang_tidy %s modernize-raw-string-literal %t + +char const *const BackSlash{"goink\\frob"}; +// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal] +// CHECK-FIXES: {{^}}char const *const BackSlash{R"(goink\frob)"};{{$}} + +char const *const Bell{"goink\\\afrob"}; +char const *const BackSpace{"goink\\\bfrob"}; +char const *const FormFeed{"goink\\\ffrob"}; +char const *const CarraigeReturn{"goink\\\rfrob"}; +char const *const HorizontalTab{"goink\\\tfrob"}; +char const *const VerticalTab{"goink\\\vfrob"}; +char const *const OctalNonPrintable{"\\\003"}; +char const *const HexNonPrintable{"\\\x03"}; +char const *const Delete{"\\\177"}; +char const *const TrailingSpace{"A line \\with space. \n"}; +char const *const TrailingNewLine{"A single \\line.\n"}; +char const *const AlreadyRaw{R"(foobie\\bletch)"}; +char const *const UTF8Literal{u8"foobie\\bletch"}; +char const *const UTF8RawLiteral{u8R"(foobie\\bletch)"}; +char16_t const *const UTF16Literal{u"foobie\\bletch"}; +char16_t const *const UTF16RawLiteral{uR"(foobie\\bletch)"}; +char32_t const *const UTF32Literal{U"foobie\\bletch"}; +char32_t const *const UTF32RawLiteral{UR"(foobie\\bletch)"}; +wchar_t const *const WideLiteral{L"foobie\\bletch"}; +wchar_t const *const WideRawLiteral{LR"(foobie\\bletch)"}; + +char const *const NewLine{"goink\nfrob\n"}; +// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const NewLine{R"(goink{{$}} +// CHECK-FIXES-NEXT: {{^}}frob{{$}} +// CHECK-FIXES-NEXT: {{^}})"};{{$}} + +char const *const SingleQuote{"goink\'frob"}; +// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: {{.*}} can be written as a raw string literal +// CHECK-XFIXES: {{^}}char const *const SingleQuote{R"(goink'frob)"};{{$}} + +char const *const DoubleQuote{"goink\"frob"}; +// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const DoubleQuote{R"(goink"frob)"};{{$}} + +char const *const QuestionMark{"goink\?frob"}; +// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const QuestionMark{R"(goink?frob)"};{{$}} + +char const *const RegEx{"goink\\(one|two\\)\\\\\\?.*\\nfrob"}; +// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const RegEx{R"(goink\(one|two\)\\\?.*\nfrob)"};{{$}} + +char const *const Path{"C:\\Program Files\\Vendor\\Application\\Application.exe"}; +// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const Path{R"(C:\Program Files\Vendor\Application\Application.exe)"};{{$}} + +char const *const ContainsSentinel{"who\\ops)\""}; +// CHECK-MESSAGES: :[[@LINE-1]]:36: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const ContainsSentinel{R"lit(who\ops)")lit"};{{$}} + +char const *const ContainsDelim{"whoops)\")lit\""}; +// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const ContainsDelim{R"lit1(whoops)")lit")lit1"};{{$}} + +char const *const OctalPrintable{"\100\\"}; +// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const OctalPrintable{R"(@\)"};{{$}} + +char const *const HexPrintable{"\x40\\"}; +// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: {{.*}} can be written as a raw string literal +// CHECK-FIXES: {{^}}char const *const HexPrintable{R"(@\)"};{{$}} Index: tool-template/Makefile =================================================================== --- /dev/null +++ tool-template/Makefile @@ -0,0 +1,25 @@ +##===-------- tools/toolTemplate/Makefile ------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +CLANG_LEVEL := ../../.. + +TOOLNAME = tool-template +NO_INSTALL = 1 + +# No plugins, optimize startup time. +TOOL_NO_EXPORTS = 1 + +include $(CLANG_LEVEL)/../../Makefile.config +LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option +USEDLIBS = clangTooling.a clangFrontend.a clangSerialization.a clangDriver.a \ + clangRewriteFrontend.a clangToolingCore.a clangRewrite.a \ + clangParse.a clangSema.a clangAnalysis.a \ + clangAST.a clangASTMatchers.a clangEdit.a clangLex.a clangBasic.a + +include $(CLANG_LEVEL)/Makefile Index: unittests/Makefile =================================================================== --- /dev/null +++ unittests/Makefile @@ -0,0 +1,15 @@ +##===- tools/extra/test/Unit/Makefile ----------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +CLANG_LEVEL := ../../.. +include $(CLANG_LEVEL)/../../Makefile.config + +PARALLEL_DIRS := clang-apply-replacements clang-query clang-tidy clang-rename + +include $(CLANG_LEVEL)/Makefile Index: unittests/clang-apply-replacements/Makefile =================================================================== --- /dev/null +++ unittests/clang-apply-replacements/Makefile @@ -0,0 +1,25 @@ +##===- unittests/clang-apply-replacements/Makefile ---------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +CLANG_LEVEL = ../../../.. +include $(CLANG_LEVEL)/../../Makefile.config + +TESTNAME = ClangApplyReplacementsTests +LINK_COMPONENTS := asmparser bitreader support mc mcparser option \ + TransformUtils +USEDLIBS = clangApplyReplacements.a clangFormat.a clangTooling.a \ + clangToolingCore.a clangFrontend.a \ + clangSerialization.a clangDriver.a clangRewriteFrontend.a \ + clangRewrite.a clangParse.a clangSema.a clangAnalysis.a \ + clangAST.a clangASTMatchers.a clangEdit.a clangLex.a clangBasic.a + +include $(CLANG_LEVEL)/Makefile +MAKEFILE_UNITTEST_NO_INCLUDE_COMMON := 1 +CPP.Flags += -I$(PROJ_SRC_DIR)/../../clang-apply-replacements/include -I$(PROJ_SRC_DIR)/../include +include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest Index: unittests/clang-query/Makefile =================================================================== --- /dev/null +++ unittests/clang-query/Makefile @@ -0,0 +1,24 @@ +##===- unittests/clang-query/Makefile ----------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +CLANG_LEVEL = ../../../.. +include $(CLANG_LEVEL)/../../Makefile.config + +TESTNAME = ClangQuery +LINK_COMPONENTS := asmparser bitreader support MC MCParser option \ + TransformUtils +USEDLIBS = clangQuery.a clangTooling.a clangFrontend.a clangSerialization.a \ + clangDriver.a clangParse.a clangSema.a clangEdit.a clangAnalysis.a \ + clangAST.a clangASTMatchers.a clangDynamicASTMatchers.a clangLex.a \ + clangBasic.a + +include $(CLANG_LEVEL)/Makefile +MAKEFILE_UNITTEST_NO_INCLUDE_COMMON := 1 +CPP.Flags += -I$(PROJ_SRC_DIR)/../../clang-query +include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest Index: unittests/clang-rename/Makefile =================================================================== --- /dev/null +++ unittests/clang-rename/Makefile @@ -0,0 +1,25 @@ +##===- unittests/clang-rename/Makefile ---------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +CLANG_LEVEL = ../../../.. +include $(CLANG_LEVEL)/../../Makefile.config + +TESTNAME = ClangRenameTests +LINK_COMPONENTS := asmparser bitreader support MC MCParser option \ + TransformUtils +USEDLIBS = clangRename.a clangFrontend.a clangSerialization.a clangDriver.a \ + clangTooling.a clangParse.a clangSema.a clangIndex.a \ + clangStaticAnalyzerFrontend.a clangStaticAnalyzerCheckers.a \ + clangStaticAnalyzerCore.a clangAnalysis.a clangRewriteFrontend.a \ + clangRewrite.a clangEdit.a clangAST.a clangLex.a clangBasic.a + +include $(CLANG_LEVEL)/Makefile +MAKEFILE_UNITTEST_NO_INCLUDE_COMMON := 1 +CPP.Flags += -I$(PROJ_SRC_DIR)/../../clang-rename +include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest Index: unittests/clang-tidy/IncludeInserterTest.cpp =================================================================== --- unittests/clang-tidy/IncludeInserterTest.cpp +++ unittests/clang-tidy/IncludeInserterTest.cpp @@ -98,6 +98,7 @@ public: CXXSystemIncludeInserterCheck(StringRef CheckName, ClangTidyContext *Context) : IncludeInserterCheckBase(CheckName, Context) {} + virtual ~CXXSystemIncludeInserterCheck() {} std::vector HeadersToInclude() const override { return {"set"}; } bool IsAngledInclude() const override { return true; } @@ -521,7 +522,7 @@ "insert_includes_test_header.cc")); } -} // anonymous namespace +} // namespace } // namespace tidy } // namespace clang Index: unittests/clang-tidy/Makefile =================================================================== --- /dev/null +++ unittests/clang-tidy/Makefile @@ -0,0 +1,30 @@ +##===- unittests/clang-tidy/Makefile -----------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +CLANG_LEVEL = ../../../.. +include $(CLANG_LEVEL)/../../Makefile.config + +TESTNAME = ClangTidy +LINK_COMPONENTS := asmparser bitreader support MC MCParser option \ + TransformUtils +USEDLIBS = clangTidy.a clangTidyLLVMModule.a clangTidyGoogleModule.a \ + clangTidyMiscModule.a clangTidyReadability.a clangTidy.a \ + clangTidyUtils.a \ + clangStaticAnalyzerFrontend.a clangStaticAnalyzerCheckers.a \ + clangStaticAnalyzerCore.a \ + clangFormat.a clangTooling.a clangToolingCore.a \ + clangFrontend.a clangSerialization.a \ + clangDriver.a clangRewriteFrontend.a clangRewrite.a \ + clangParse.a clangSema.a clangAnalysis.a clangAST.a \ + clangASTMatchers.a clangEdit.a clangLex.a clangBasic.a + +include $(CLANG_LEVEL)/Makefile +MAKEFILE_UNITTEST_NO_INCLUDE_COMMON := 1 +CPP.Flags += -I$(PROJ_SRC_DIR)/../../clang-tidy +include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest