Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete
rmaprath added a comment. Would you / community be open to the idea of hiding the os syscalls behind an API? (like we are doing for pthreads)? I think this is the only way we could get at least some of this functionality working on bare-metal ARM (it should work on arm-linux without much trouble - I think). How much work do you think this refactoring would need? I'm happy to do that after you land the patch. I will see if I can try this out on arm-linux, as soon as I resolve this fedora20 mystery of mine :) Cheers, / Asiri http://reviews.llvm.org/D16948 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete
EricWF added a comment. Ah I figured it out! The test suite has symlinks within it. Git handles them properly but they obviously don't survive the round trip to phabricator and back. So all of the tests that depend on them fail (with is evidently a lot). http://reviews.llvm.org/D16948 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r271253 - [AVX512] Convert masked load builtins to generic masked load intrinsics instead of the x86 specific ones.
Author: ctopper Date: Tue May 31 01:58:07 2016 New Revision: 271253 URL: http://llvm.org/viewvc/llvm-project?rev=271253&view=rev Log: [AVX512] Convert masked load builtins to generic masked load intrinsics instead of the x86 specific ones. This will allow the x86 intrinsics to be removed from the backend. Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/avx512bw-builtins.c cfe/trunk/test/CodeGen/avx512f-builtins.c cfe/trunk/test/CodeGen/avx512vl-builtins.c cfe/trunk/test/CodeGen/avx512vlbw-builtins.c Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=271253&r1=271252&r2=271253&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue May 31 01:58:07 2016 @@ -6309,6 +6309,37 @@ static Value *EmitX86MaskedStore(CodeGen return CGF.Builder.CreateMaskedStore(Ops[1], Ops[0], Align, Ops[2]); } +static Value *EmitX86MaskedLoad(CodeGenFunction &CGF, +SmallVectorImpl &Ops, unsigned Align) { + // Cast the pointer to right type. + Ops[0] = CGF.Builder.CreateBitCast(Ops[0], + llvm::PointerType::getUnqual(Ops[1]->getType())); + + // If the mask is all ones just emit a regular store. + if (const auto *C = dyn_cast(Ops[2])) +if (C->isAllOnesValue()) + return CGF.Builder.CreateAlignedLoad(Ops[0], Align); + + // Convert the mask from an integer type to a vector of i1. + unsigned NumElts = Ops[1]->getType()->getVectorNumElements(); + llvm::VectorType *MaskTy = llvm::VectorType::get(CGF.Builder.getInt1Ty(), + cast(Ops[2]->getType())->getBitWidth()); + Ops[2] = CGF.Builder.CreateBitCast(Ops[2], MaskTy); + + // If we have less than 8 elements, then the starting mask was an i8 and + // we need to extract down to the right number of elements. + if (NumElts < 8) { +int Indices[4]; +for (unsigned i = 0; i != NumElts; ++i) + Indices[i] = i; +Ops[2] = CGF.Builder.CreateShuffleVector(Ops[2], Ops[2], + makeArrayRef(Indices, NumElts), + "extract"); + } + + return CGF.Builder.CreateMaskedLoad(Ops[0], Align, Ops[2], Ops[1]); +} + Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E) { if (BuiltinID == X86::BI__builtin_ms_va_start || @@ -6568,6 +6599,42 @@ Value *CodeGenFunction::EmitX86BuiltinEx getContext().getTypeAlignInChars(E->getArg(1)->getType()).getQuantity(); return EmitX86MaskedStore(*this, Ops, Align); } + case X86::BI__builtin_ia32_loadups128_mask: + case X86::BI__builtin_ia32_loadups256_mask: + case X86::BI__builtin_ia32_loadups512_mask: + case X86::BI__builtin_ia32_loadupd128_mask: + case X86::BI__builtin_ia32_loadupd256_mask: + case X86::BI__builtin_ia32_loadupd512_mask: + case X86::BI__builtin_ia32_loaddquqi128_mask: + case X86::BI__builtin_ia32_loaddquqi256_mask: + case X86::BI__builtin_ia32_loaddquqi512_mask: + case X86::BI__builtin_ia32_loaddquhi128_mask: + case X86::BI__builtin_ia32_loaddquhi256_mask: + case X86::BI__builtin_ia32_loaddquhi512_mask: + case X86::BI__builtin_ia32_loaddqusi128_mask: + case X86::BI__builtin_ia32_loaddqusi256_mask: + case X86::BI__builtin_ia32_loaddqusi512_mask: + case X86::BI__builtin_ia32_loaddqudi128_mask: + case X86::BI__builtin_ia32_loaddqudi256_mask: + case X86::BI__builtin_ia32_loaddqudi512_mask: +return EmitX86MaskedLoad(*this, Ops, 1); + + case X86::BI__builtin_ia32_loadaps128_mask: + case X86::BI__builtin_ia32_loadaps256_mask: + case X86::BI__builtin_ia32_loadaps512_mask: + case X86::BI__builtin_ia32_loadapd128_mask: + case X86::BI__builtin_ia32_loadapd256_mask: + case X86::BI__builtin_ia32_loadapd512_mask: + case X86::BI__builtin_ia32_movdqa32load128_mask: + case X86::BI__builtin_ia32_movdqa32load256_mask: + case X86::BI__builtin_ia32_movdqa32load512_mask: + case X86::BI__builtin_ia32_movdqa64load128_mask: + case X86::BI__builtin_ia32_movdqa64load256_mask: + case X86::BI__builtin_ia32_movdqa64load512_mask: { +unsigned Align = + getContext().getTypeAlignInChars(E->getArg(1)->getType()).getQuantity(); +return EmitX86MaskedLoad(*this, Ops, Align); + } case X86::BI__builtin_ia32_storehps: case X86::BI__builtin_ia32_storelps: { llvm::Type *PtrTy = llvm::PointerType::getUnqual(Int64Ty); Modified: cfe/trunk/test/CodeGen/avx512bw-builtins.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512bw-builtins.c?rev=271253&r1=271252&r2=271253&view=diff == --- cfe/trunk/test/CodeGen/avx512bw-builtins.c (original) +++ cfe/trunk/test/CodeGen/avx512bw-builtins.c Tue May 31 01:58:07 2016 @@ -1325,25
Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete
rmaprath added a comment. In http://reviews.llvm.org/D16948#444010, @EricWF wrote: > Ah I figured it out! The test suite has symlinks within it. Git handles them > properly but they obviously don't survive the round trip to phabricator and > back. So all of the tests that depend on them fail (with is evidently a lot). Perhaps you can put up a tarball somewhere? / Asiri http://reviews.llvm.org/D16948 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete
EricWF added a comment. In http://reviews.llvm.org/D16948#444009, @rmaprath wrote: > Would you / community be open to the idea of hiding the os syscalls behind an > API? (like we are doing for pthreads)? Yes I would be very open to that. Then I could also have test shims in order to test truly exceptional cases. > I think this is the only way we could get at least some of this functionality > working on bare-metal ARM (it should work on arm-linux without much trouble - > I think). How much work do you think this refactoring would need? I'm happy > to do that after you land the patch. It shouldn't be that much work to get `path`, `directory_iterator` and `recursive_directory_iterator` working. They have like 4 system calls in there implementation. The rest of the TS is just a set of free functions. Each uses a separate system call for the most part. However the API is very simple and you can pick and choose which functions you want to support. > I will see if I can try this out on arm-linux, as soon as I resolve this > fedora20 mystery of mine :) > > Cheers, > > / Asiri http://reviews.llvm.org/D16948 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete
EricWF added a comment. The git branch I develop on is public: https://github.com/efcs/libcxx/tree/filesystem-ts You can download or clone from there (and it will always be up to date!). http://reviews.llvm.org/D16948 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete
rmaprath added a comment. In http://reviews.llvm.org/D16948#444013, @EricWF wrote: > The git branch I develop on is public: > https://github.com/efcs/libcxx/tree/filesystem-ts > > You can download or clone from there (and it will always be up to date!). All tests pass! :-) I'll try to find an arm-linux setup soon and run this there as well. / Asiri http://reviews.llvm.org/D16948 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().
djasper added inline comments. Comment at: lib/Format/Format.cpp:1549 @@ -1408,3 +1548,3 @@ // We need to use lambda function here since there are two versions of // `cleanup`. auto Cleanup = [](const FormatStyle &Style, StringRef Code, So, add a copy constructor to Replacement? http://reviews.llvm.org/D20734 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20782: [AVX512] Emit generic masked store intrinsics directly from clang instead of using x86 specific intrinsics.
craig.topper closed this revision. craig.topper added a comment. Commited in r271246. http://reviews.llvm.org/D20782 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20277: [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.
Prazek added a comment. In http://reviews.llvm.org/D20277#436725, @flx wrote: > In http://reviews.llvm.org/D20277#436717, @Prazek wrote: > > > Cool check! Did you think about sugesting std::move for rvalue references > > if they are used once? > > > Thanks! I'm not sure this fits with what a user would expect from a check > named "unnecessary-value-param" since in this case the parameter is not > passed by value. Would a separate check make sense for this? Consider changing the name :) When I was thinking about the check for rvalue references, I wanted to name it "*-rvalue-ref-one-use". If it covers values also, maybe "performance-move-single-used-variable" or "performance-variable-one-use", or "performance-disposable-object" (If I translated it correctly). In my opinion there is no need to have separate check to to this, because the user would like to have both or none. http://reviews.llvm.org/D20277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().
ioeric updated this revision to Diff 59017. ioeric added a comment. - Use std::set_difference in fixCppIncludeInsertions() http://reviews.llvm.org/D20734 Files: include/clang/Format/Format.h lib/Format/Format.cpp unittests/Format/CleanupTest.cpp Index: unittests/Format/CleanupTest.cpp === --- unittests/Format/CleanupTest.cpp +++ unittests/Format/CleanupTest.cpp @@ -281,6 +281,331 @@ EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces)); } +TEST_F(CleanUpReplacementsTest, NoExistingIncludeWithoutDefine) { + std::string Code = "int main() {}"; + std::string Expected = "#include \"a.h\"\n" + "int main() {}"; + Context.createInMemoryFile("fix.cpp", Code); + tooling::Replacements Replaces; + Replaces.insert( + tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"a.h\"")); + format::FormatStyle Style = format::getLLVMStyle(); + auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style); + EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces)); +} + +TEST_F(CleanUpReplacementsTest, NoExistingIncludeWithDefine) { + std::string Code = "#ifndef __A_H__\n" + "#define __A_H__\n" + "class A {};\n" + "#define MMM 123\n" + "#endif"; + std::string Expected = "#ifndef __A_H__\n" + "#define __A_H__\n" + "#include \"b.h\"\n" + "class A {};\n" + "#define MMM 123\n" + "#endif"; + + Context.createInMemoryFile("fix.cpp", Code); + tooling::Replacements Replaces; + Replaces.insert( + tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"b.h\"")); + format::FormatStyle Style = format::getLLVMStyle(); + auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style); + EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces)); +} + +TEST_F(CleanUpReplacementsTest, InsertBeforeCategoryWithLowerPriority) { + std::string Code = "#ifndef __A_H__\n" + "#define __A_H__\n" + "\n" + "\n" + "\n" + "#include \n" + "class A {};\n" + "#define MMM 123\n" + "#endif"; + std::string Expected = "#ifndef __A_H__\n" + "#define __A_H__\n" + "\n" + "\n" + "\n" + "#include \"a.h\"\n" + "#include \n" + "class A {};\n" + "#define MMM 123\n" + "#endif"; + + Context.createInMemoryFile("fix.cpp", Code); + tooling::Replacements Replaces; + Replaces.insert( + tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"a.h\"")); + format::FormatStyle Style = format::getLLVMStyle(); + auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style); + EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces)); +} + +TEST_F(CleanUpReplacementsTest, InsertAfterMainHeader) { + std::string Code = "#include \"fix.h\"\n" + "\n" + "int main() {}"; + std::string Expected = "#include \"fix.h\"\n" + "#include \n" + "\n" + "int main() {}"; + Context.createInMemoryFile("fix.cpp", Code); + tooling::Replacements Replaces; + Replaces.insert(tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include ")); + format::FormatStyle Style = + format::getGoogleStyle(format::FormatStyle::LanguageKind::LK_Cpp); + auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style); + EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces)); +} + +TEST_F(CleanUpReplacementsTest, InsertBeforeSystemHeaderLLVM) { + std::string Code = "#include \n" + "\n" + "int main() {}"; + std::string Expected = "#include \"z.h\"\n" + "#include \n" + "\n" + "int main() {}"; + Context.createInMemoryFile("fix.cpp", Code); + tooling::Replacements Replaces; + Replaces.insert( + tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"z.h\"")); + format::FormatStyle Style = format::getLLVMStyle(); + auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style); + EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces)); +} + +TEST_F(CleanUpReplacementsTest, InsertAfterSystemHeaderGoogle) { + std::string Code = "#include \n" + "\n" + "int main() {}"; + std::string Expected = "#include \n" + "#include \"z.h\"\n" + "\n" + "int main() {}"; + Context.createInMemoryFile("fix.cpp", Code); + tooling::Replac
Re: [PATCH] D20621: [include-fixer] Create a mode in vim integration to show multiple potential headers.
hokein updated this revision to Diff 59018. hokein marked 2 inline comments as done. hokein added a comment. Fix code style. http://reviews.llvm.org/D20621 Files: include-fixer/IncludeFixer.cpp include-fixer/IncludeFixer.h include-fixer/IncludeFixerContext.h include-fixer/tool/ClangIncludeFixer.cpp include-fixer/tool/clang-include-fixer.py test/include-fixer/commandline_options.cpp unittests/include-fixer/IncludeFixerTest.cpp Index: unittests/include-fixer/IncludeFixerTest.cpp === --- unittests/include-fixer/IncludeFixerTest.cpp +++ unittests/include-fixer/IncludeFixerTest.cpp @@ -70,11 +70,16 @@ SymbolIndexMgr->addSymbolIndex( llvm::make_unique(Symbols)); - std::set Headers; - std::vector Replacements; - IncludeFixerActionFactory Factory(*SymbolIndexMgr, Headers, Replacements, -"llvm"); + IncludeFixerContext FixerContext; + IncludeFixerActionFactory Factory(*SymbolIndexMgr, FixerContext, "llvm"); + runOnCode(&Factory, Code, "input.cc", ExtraArgs); + std::vector Replacements; + if (!FixerContext.Headers.empty()) { +Replacements = clang::include_fixer::createInsertHeaderReplacements( +Code, "input.cc", FixerContext.Headers.front(), +FixerContext.FirstIncludeOffset); + } clang::RewriterTestContext Context; clang::FileID ID = Context.createInMemoryFile("input.cc", Code); clang::tooling::applyAllReplacements(Replacements, Context.Rewrite); Index: test/include-fixer/commandline_options.cpp === --- /dev/null +++ test/include-fixer/commandline_options.cpp @@ -0,0 +1,12 @@ +// REQUIRES: shell +// RUN: sed -e 's#//.*$##' %s > %t.cpp +// RUN: clang-include-fixer -db=fixed -input='foo= "foo.h","bar.h"' -output-headers %t.cpp -- | FileCheck %s -check-prefix=CHECK-HEADERS +// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='"foo.h"' %t.cpp | FileCheck %s -check-prefix=CHECK +// +// CHECK-HEADERS: "foo.h" +// CHECK-HEADERS: "bar.h" +// +// CHECK: #include "foo.h" +// CHECK: foo f; + +foo f; Index: include-fixer/tool/clang-include-fixer.py === --- include-fixer/tool/clang-include-fixer.py +++ include-fixer/tool/clang-include-fixer.py @@ -18,7 +18,6 @@ import argparse import difflib import subprocess -import sys import vim # set g:clang_include_fixer_path to the path to clang-include-fixer if it is not @@ -28,6 +27,39 @@ if vim.eval('exists("g:clang_include_fixer_path")') == "1": binary = vim.eval('g:clang_include_fixer_path') +maximum_suggested_headers=3 +if vim.eval('exists("g:clang_include_fixer_maximum_suggested_headers")') == "1": + maximum_suggested_headers = max( + 1, + vim.eval('g:clang_include_fixer_maximum_suggested_headers')) + + +def ShowDialog(message, choices, default_choice_index=0): + to_eval = "confirm('{0}', '{1}', '{2}')".format(message, + choices, + default_choice_index) + return int(vim.eval(to_eval)); + + +def execute(command, text): + p = subprocess.Popen(command, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + stdin=subprocess.PIPE) + return p.communicate(input=text) + + +def InsertHeaderToVimBuffer(header, text): + command = [binary, "-stdin", "-insert-header="+header, + vim.current.buffer.name] + stdout, stderr = execute(command, text) + if stdout: +lines = stdout.splitlines() +sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines) +for op in reversed(sequence.get_opcodes()): + if op[0] is not 'equal': +vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]] + + def main(): parser = argparse.ArgumentParser( description='Vim integration for clang-include-fixer') @@ -41,24 +73,36 @@ buf = vim.current.buffer text = '\n'.join(buf) - # Call clang-include-fixer. - command = [binary, "-stdin", "-db="+args.db, "-input="+args.input, + # Run command to get all headers. + command = [binary, "-stdin", "-output-headers", "-db="+args.db, "-input="+args.input, "-debug", vim.current.buffer.name] - p = subprocess.Popen(command, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, - stdin=subprocess.PIPE) - stdout, stderr = p.communicate(input=text) + stdout, stderr = execute(command, text) + lines = stdout.splitlines() + if len(lines) < 2: +print "No header is included.\n" +return - # If successful, replace buffer contents. - if stderr: -print stderr + # The first line is the symbol name. + symbol = lines[0] + # If there is only one suggested header, insert it directly. + if len(lines) == 2 or maximum_suggested_headers == 1: +InsertHeaderToVimBuffer(lines[1], text) +print "Added
Re: [PATCH] D20382: Add postorder support to RecursiveASTVisitor
klimek added a reviewer: bkramer. klimek added a comment. Generally makes sense; adding d0k for additional thoughts. http://reviews.llvm.org/D20382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20621: [include-fixer] Create a mode in vim integration to show multiple potential headers.
bkramer accepted this revision. bkramer added a comment. This revision is now accepted and ready to land. LG. Can't wait to use it myself :) http://reviews.llvm.org/D20621 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D20804: [include-fixer] collect the number of times a symbols is found in an indexing run and use it for symbols popularity ranking.
ioeric created this revision. ioeric added a reviewer: bkramer. ioeric added subscribers: djasper, hokein, cfe-commits. [include-fixer] collect the number of times a symbols is found in an indexing run and use it for symbols popularity ranking. http://reviews.llvm.org/D20804 Files: include-fixer/find-all-symbols/SymbolInfo.cpp include-fixer/find-all-symbols/SymbolInfo.h include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp test/include-fixer/Inputs/fake_yaml_db.yaml Index: test/include-fixer/Inputs/fake_yaml_db.yaml === --- test/include-fixer/Inputs/fake_yaml_db.yaml +++ test/include-fixer/Inputs/fake_yaml_db.yaml @@ -8,6 +8,7 @@ FilePath:foo.h LineNumber: 1 Type:Class +NumOccurrences: 1 ... --- Name: bar @@ -19,4 +20,5 @@ FilePath:../include/bar.h LineNumber: 1 Type:Class +NumOccurrences: 1 ... Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp === --- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp +++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp @@ -88,10 +88,13 @@ bool Merge(llvm::StringRef MergeDir, llvm::StringRef OutputFile) { std::error_code EC; std::set UniqueSymbols; + std::map NumOccurrences; std::mutex SymbolMutex; auto AddSymbols = [&](ArrayRef Symbols) { // Synchronize set accesses. std::unique_lock LockGuard(SymbolMutex); +for (const auto &Symbol : Symbols) + ++NumOccurrences[Symbol]; UniqueSymbols.insert(Symbols.begin(), Symbols.end()); }; @@ -123,7 +126,12 @@ << '\n'; return false; } - WriteSymbolInfosToStream(OS, UniqueSymbols); + std::set Result; + for (const auto &Symbol : UniqueSymbols) +Result.insert(SymbolInfo(Symbol.getName(), Symbol.getSymbolKind(), + Symbol.getFilePath(), Symbol.getLineNumber(), + Symbol.getContexts(), NumOccurrences[Symbol])); + WriteSymbolInfosToStream(OS, Result); return true; } Index: include-fixer/find-all-symbols/SymbolInfo.h === --- include-fixer/find-all-symbols/SymbolInfo.h +++ include-fixer/find-all-symbols/SymbolInfo.h @@ -51,7 +51,8 @@ SymbolInfo() : Type(SymbolKind::Unknown), LineNumber(-1) {} SymbolInfo(llvm::StringRef Name, SymbolKind Type, llvm::StringRef FilePath, - int LineNumber, const std::vector &Contexts); + int LineNumber, const std::vector &Contexts, + unsigned NumOccurrences = 0); /// \brief Get symbol name. llvm::StringRef getName() const; @@ -68,6 +69,9 @@ /// \brief Get a 1-based line number of the symbol's declaration. int getLineNumber() const; + /// \brief The number of times this symbol was found during an indexing run. + unsigned getNumOccurrences() const; + bool operator<(const SymbolInfo &Symbol) const; bool operator==(const SymbolInfo &Symbol) const; @@ -99,6 +103,10 @@ /// \brief The 1-based line number of of the symbol's declaration. int LineNumber; + + /// \brief The number of times this symbol was found during an indexing + /// run. Populated by the reducer and used to rank results. + unsigned NumOccurrences; }; /// \brief Write SymbolInfos to a stream (YAML format). Index: include-fixer/find-all-symbols/SymbolInfo.cpp === --- include-fixer/find-all-symbols/SymbolInfo.cpp +++ include-fixer/find-all-symbols/SymbolInfo.cpp @@ -33,6 +33,7 @@ io.mapRequired("FilePath", Symbol.FilePath); io.mapRequired("LineNumber", Symbol.LineNumber); io.mapRequired("Type", Symbol.Type); +io.mapRequired("NumOccurrences", Symbol.NumOccurrences); } }; @@ -72,9 +73,10 @@ SymbolInfo::SymbolInfo(llvm::StringRef Name, SymbolKind Type, llvm::StringRef FilePath, int LineNumber, - const std::vector &Contexts) + const std::vector &Contexts, + unsigned NumOccurrences) : Name(Name), Type(Type), FilePath(FilePath), Contexts(Contexts), - LineNumber(LineNumber) {} + LineNumber(LineNumber), NumOccurrences(NumOccurrences) {} llvm::StringRef SymbolInfo::getName() const { return Name; } @@ -88,6 +90,8 @@ int SymbolInfo::getLineNumber() const { return LineNumber; } +unsigned SymbolInfo::getNumOccurrences() const { return NumOccurrences; } + bool SymbolInfo::operator==(const SymbolInfo &Symbol) const { return std::tie(Name, Type, FilePath, LineNumber, Contexts) == std::tie(Symbol.Name, Symbol.Type, Symbol.FilePath, Symbol.LineNumber, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20382: Add postorder support to RecursiveASTVisitor
bkramer added a comment. Having postorder traversal makes sense to me. The thing I'm worried about is how much this will bloat object code. RecursiveASTVisitor is already a major contributor to the size of clang's binary and we've hit issues with it in the past (hitting .obj size limits on Windows for example) can you show numbers of the size of clang before and after this change? Ideally in Release and Debug configurations. If it grows it too much we'll have to find another way of enabling/disabling it. http://reviews.llvm.org/D20382 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20804: [include-fixer] collect the number of times a symbols is found in an indexing run and use it for symbols popularity ranking.
bkramer added inline comments. Comment at: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp:91 @@ -90,2 +90,3 @@ std::set UniqueSymbols; + std::map NumOccurrences; std::mutex SymbolMutex; Can we remove the set now? 2 copies of all SymbolInfos seems unnecessary. http://reviews.llvm.org/D20804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().
djasper added inline comments. Comment at: lib/Format/Format.cpp:1444 @@ +1443,3 @@ + if (!llvm::Regex(IncludeRegexPattern).match(Replace.getReplacementText())) { +llvm::errs() << "Insertions other than header #include insertion are " +"not supported! " This error output doesn't belong here. I think we can just remove it. If you'd prefer to keep it, add it to the loop in fixCppIncludeInsertions(): for (const auto &R : Replaces) { if (isHeaderInsertion(R)) HeaderInsertions.insert(R); else if (R.getOffset() == UINT_MAX) log::errs() << ... } Comment at: lib/Format/Format.cpp:1556 @@ +1555,3 @@ + tooling::Replacements NewReplaces = + (Style.Language != FormatStyle::LanguageKind::LK_Cpp) + ? Replaces I'd move this check into fixCppIncludeInsertions. Comment at: unittests/Format/CleanupTest.cpp:310 @@ +309,3 @@ + + Context.createInMemoryFile("fix.cpp", Code); + tooling::Replacements Replaces; I'd pull out a lot of these environment setup things into abstractions in the test fixture. Maybe all you need is two functions like: insert(Code, Replaces); and insertAndFormat(Code, Replaces); ? Comment at: unittests/Format/CleanupTest.cpp:311 @@ +310,3 @@ + Context.createInMemoryFile("fix.cpp", Code); + tooling::Replacements Replaces; + Replaces.insert( Can you just make this: tooling::Replacements Replaces = { tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"b.h\"")}; ? Comment at: unittests/Format/CleanupTest.cpp:510 @@ +509,3 @@ + Replaces.insert( + tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"a.h\"")); + Replaces.insert( I'd create a function: tooling::Replacement createInsertion(StringRef HeaderName) { return tooling::Replacement("fix.cpp", UINT_MAX, 0, HeaderName); } http://reviews.llvm.org/D20734 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20621: [include-fixer] Create a mode in vim integration to show multiple potential headers.
hokein updated this revision to Diff 59026. hokein added a comment. Update a out-of-date comment. http://reviews.llvm.org/D20621 Files: include-fixer/IncludeFixer.cpp include-fixer/IncludeFixer.h include-fixer/IncludeFixerContext.h include-fixer/tool/ClangIncludeFixer.cpp include-fixer/tool/clang-include-fixer.py test/include-fixer/commandline_options.cpp unittests/include-fixer/IncludeFixerTest.cpp Index: unittests/include-fixer/IncludeFixerTest.cpp === --- unittests/include-fixer/IncludeFixerTest.cpp +++ unittests/include-fixer/IncludeFixerTest.cpp @@ -70,11 +70,16 @@ SymbolIndexMgr->addSymbolIndex( llvm::make_unique(Symbols)); - std::set Headers; - std::vector Replacements; - IncludeFixerActionFactory Factory(*SymbolIndexMgr, Headers, Replacements, -"llvm"); + IncludeFixerContext FixerContext; + IncludeFixerActionFactory Factory(*SymbolIndexMgr, FixerContext, "llvm"); + runOnCode(&Factory, Code, "input.cc", ExtraArgs); + std::vector Replacements; + if (!FixerContext.Headers.empty()) { +Replacements = clang::include_fixer::createInsertHeaderReplacements( +Code, "input.cc", FixerContext.Headers.front(), +FixerContext.FirstIncludeOffset); + } clang::RewriterTestContext Context; clang::FileID ID = Context.createInMemoryFile("input.cc", Code); clang::tooling::applyAllReplacements(Replacements, Context.Rewrite); Index: test/include-fixer/commandline_options.cpp === --- /dev/null +++ test/include-fixer/commandline_options.cpp @@ -0,0 +1,12 @@ +// REQUIRES: shell +// RUN: sed -e 's#//.*$##' %s > %t.cpp +// RUN: clang-include-fixer -db=fixed -input='foo= "foo.h","bar.h"' -output-headers %t.cpp -- | FileCheck %s -check-prefix=CHECK-HEADERS +// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='"foo.h"' %t.cpp | FileCheck %s -check-prefix=CHECK +// +// CHECK-HEADERS: "foo.h" +// CHECK-HEADERS: "bar.h" +// +// CHECK: #include "foo.h" +// CHECK: foo f; + +foo f; Index: include-fixer/tool/clang-include-fixer.py === --- include-fixer/tool/clang-include-fixer.py +++ include-fixer/tool/clang-include-fixer.py @@ -18,7 +18,6 @@ import argparse import difflib import subprocess -import sys import vim # set g:clang_include_fixer_path to the path to clang-include-fixer if it is not @@ -28,6 +27,39 @@ if vim.eval('exists("g:clang_include_fixer_path")') == "1": binary = vim.eval('g:clang_include_fixer_path') +maximum_suggested_headers=3 +if vim.eval('exists("g:clang_include_fixer_maximum_suggested_headers")') == "1": + maximum_suggested_headers = max( + 1, + vim.eval('g:clang_include_fixer_maximum_suggested_headers')) + + +def ShowDialog(message, choices, default_choice_index=0): + to_eval = "confirm('{0}', '{1}', '{2}')".format(message, + choices, + default_choice_index) + return int(vim.eval(to_eval)); + + +def execute(command, text): + p = subprocess.Popen(command, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + stdin=subprocess.PIPE) + return p.communicate(input=text) + + +def InsertHeaderToVimBuffer(header, text): + command = [binary, "-stdin", "-insert-header="+header, + vim.current.buffer.name] + stdout, stderr = execute(command, text) + if stdout: +lines = stdout.splitlines() +sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines) +for op in reversed(sequence.get_opcodes()): + if op[0] is not 'equal': +vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]] + + def main(): parser = argparse.ArgumentParser( description='Vim integration for clang-include-fixer') @@ -41,24 +73,36 @@ buf = vim.current.buffer text = '\n'.join(buf) - # Call clang-include-fixer. - command = [binary, "-stdin", "-db="+args.db, "-input="+args.input, + # Run command to get all headers. + command = [binary, "-stdin", "-output-headers", "-db="+args.db, "-input="+args.input, "-debug", vim.current.buffer.name] - p = subprocess.Popen(command, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, - stdin=subprocess.PIPE) - stdout, stderr = p.communicate(input=text) + stdout, stderr = execute(command, text) + lines = stdout.splitlines() + if len(lines) < 2: +print "No header is included.\n" +return - # If successful, replace buffer contents. - if stderr: -print stderr + # The first line is the symbol name. + symbol = lines[0] + # If there is only one suggested header, insert it directly. + if len(lines) == 2 or maximum_suggested_headers == 1: +InsertHeaderToVimBuffer(lines[1], text) +print "Added #include {0} for {1}.\n".fo
Re: [PATCH] D20621: [include-fixer] Create a mode in vim integration to show multiple potential headers.
klimek added inline comments. Comment at: include-fixer/IncludeFixer.h:74 @@ +73,3 @@ +/// \return Replacements for inserting and sorting headers. +std::vector createInsertHeaderReplacements( +StringRef Code, StringRef FilePath, StringRef Header, This is still missing documentation on what the -1U special case means. http://reviews.llvm.org/D20621 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20804: [include-fixer] collect the number of times a symbols is found in an indexing run and use it for symbols popularity ranking.
ioeric updated this revision to Diff 59027. ioeric added a comment. - Removed a redundant set of symbols during merging. http://reviews.llvm.org/D20804 Files: include-fixer/find-all-symbols/SymbolInfo.cpp include-fixer/find-all-symbols/SymbolInfo.h include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp test/include-fixer/Inputs/fake_yaml_db.yaml Index: test/include-fixer/Inputs/fake_yaml_db.yaml === --- test/include-fixer/Inputs/fake_yaml_db.yaml +++ test/include-fixer/Inputs/fake_yaml_db.yaml @@ -8,6 +8,7 @@ FilePath:foo.h LineNumber: 1 Type:Class +NumOccurrences: 1 ... --- Name: bar @@ -19,4 +20,5 @@ FilePath:../include/bar.h LineNumber: 1 Type:Class +NumOccurrences: 1 ... Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp === --- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp +++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp @@ -87,12 +87,13 @@ bool Merge(llvm::StringRef MergeDir, llvm::StringRef OutputFile) { std::error_code EC; - std::set UniqueSymbols; + std::map SymbolToNumOccurrences; std::mutex SymbolMutex; auto AddSymbols = [&](ArrayRef Symbols) { // Synchronize set accesses. std::unique_lock LockGuard(SymbolMutex); -UniqueSymbols.insert(Symbols.begin(), Symbols.end()); +for (const auto &Symbol : Symbols) + ++SymbolToNumOccurrences[Symbol]; }; // Load all symbol files in MergeDir. @@ -123,7 +124,14 @@ << '\n'; return false; } - WriteSymbolInfosToStream(OS, UniqueSymbols); + std::set Result; + for (const auto &Entry : SymbolToNumOccurrences) { +const auto &Symbol = Entry.first; +Result.insert(SymbolInfo(Symbol.getName(), Symbol.getSymbolKind(), + Symbol.getFilePath(), Symbol.getLineNumber(), + Symbol.getContexts(), Entry.second)); + } + WriteSymbolInfosToStream(OS, Result); return true; } Index: include-fixer/find-all-symbols/SymbolInfo.h === --- include-fixer/find-all-symbols/SymbolInfo.h +++ include-fixer/find-all-symbols/SymbolInfo.h @@ -51,7 +51,8 @@ SymbolInfo() : Type(SymbolKind::Unknown), LineNumber(-1) {} SymbolInfo(llvm::StringRef Name, SymbolKind Type, llvm::StringRef FilePath, - int LineNumber, const std::vector &Contexts); + int LineNumber, const std::vector &Contexts, + unsigned NumOccurrences = 0); /// \brief Get symbol name. llvm::StringRef getName() const; @@ -68,6 +69,9 @@ /// \brief Get a 1-based line number of the symbol's declaration. int getLineNumber() const; + /// \brief The number of times this symbol was found during an indexing run. + unsigned getNumOccurrences() const; + bool operator<(const SymbolInfo &Symbol) const; bool operator==(const SymbolInfo &Symbol) const; @@ -99,6 +103,10 @@ /// \brief The 1-based line number of of the symbol's declaration. int LineNumber; + + /// \brief The number of times this symbol was found during an indexing + /// run. Populated by the reducer and used to rank results. + unsigned NumOccurrences; }; /// \brief Write SymbolInfos to a stream (YAML format). Index: include-fixer/find-all-symbols/SymbolInfo.cpp === --- include-fixer/find-all-symbols/SymbolInfo.cpp +++ include-fixer/find-all-symbols/SymbolInfo.cpp @@ -33,6 +33,7 @@ io.mapRequired("FilePath", Symbol.FilePath); io.mapRequired("LineNumber", Symbol.LineNumber); io.mapRequired("Type", Symbol.Type); +io.mapRequired("NumOccurrences", Symbol.NumOccurrences); } }; @@ -72,9 +73,10 @@ SymbolInfo::SymbolInfo(llvm::StringRef Name, SymbolKind Type, llvm::StringRef FilePath, int LineNumber, - const std::vector &Contexts) + const std::vector &Contexts, + unsigned NumOccurrences) : Name(Name), Type(Type), FilePath(FilePath), Contexts(Contexts), - LineNumber(LineNumber) {} + LineNumber(LineNumber), NumOccurrences(NumOccurrences) {} llvm::StringRef SymbolInfo::getName() const { return Name; } @@ -88,6 +90,8 @@ int SymbolInfo::getLineNumber() const { return LineNumber; } +unsigned SymbolInfo::getNumOccurrences() const { return NumOccurrences; } + bool SymbolInfo::operator==(const SymbolInfo &Symbol) const { return std::tie(Name, Type, FilePath, LineNumber, Contexts) == std::tie(Symbol.Name, Symbol.Type, Symbol.FilePath, Symbol.LineNumber, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20621: [include-fixer] Create a mode in vim integration to show multiple potential headers.
hokein updated this revision to Diff 59028. hokein added a comment. Add -1U comment back. http://reviews.llvm.org/D20621 Files: include-fixer/IncludeFixer.cpp include-fixer/IncludeFixer.h include-fixer/IncludeFixerContext.h include-fixer/tool/ClangIncludeFixer.cpp include-fixer/tool/clang-include-fixer.py test/include-fixer/commandline_options.cpp unittests/include-fixer/IncludeFixerTest.cpp Index: unittests/include-fixer/IncludeFixerTest.cpp === --- unittests/include-fixer/IncludeFixerTest.cpp +++ unittests/include-fixer/IncludeFixerTest.cpp @@ -70,11 +70,16 @@ SymbolIndexMgr->addSymbolIndex( llvm::make_unique(Symbols)); - std::set Headers; - std::vector Replacements; - IncludeFixerActionFactory Factory(*SymbolIndexMgr, Headers, Replacements, -"llvm"); + IncludeFixerContext FixerContext; + IncludeFixerActionFactory Factory(*SymbolIndexMgr, FixerContext, "llvm"); + runOnCode(&Factory, Code, "input.cc", ExtraArgs); + std::vector Replacements; + if (!FixerContext.Headers.empty()) { +Replacements = clang::include_fixer::createInsertHeaderReplacements( +Code, "input.cc", FixerContext.Headers.front(), +FixerContext.FirstIncludeOffset); + } clang::RewriterTestContext Context; clang::FileID ID = Context.createInMemoryFile("input.cc", Code); clang::tooling::applyAllReplacements(Replacements, Context.Rewrite); Index: test/include-fixer/commandline_options.cpp === --- /dev/null +++ test/include-fixer/commandline_options.cpp @@ -0,0 +1,12 @@ +// REQUIRES: shell +// RUN: sed -e 's#//.*$##' %s > %t.cpp +// RUN: clang-include-fixer -db=fixed -input='foo= "foo.h","bar.h"' -output-headers %t.cpp -- | FileCheck %s -check-prefix=CHECK-HEADERS +// RUN: cat %t.cpp | clang-include-fixer -stdin -insert-header='"foo.h"' %t.cpp | FileCheck %s -check-prefix=CHECK +// +// CHECK-HEADERS: "foo.h" +// CHECK-HEADERS: "bar.h" +// +// CHECK: #include "foo.h" +// CHECK: foo f; + +foo f; Index: include-fixer/tool/clang-include-fixer.py === --- include-fixer/tool/clang-include-fixer.py +++ include-fixer/tool/clang-include-fixer.py @@ -18,7 +18,6 @@ import argparse import difflib import subprocess -import sys import vim # set g:clang_include_fixer_path to the path to clang-include-fixer if it is not @@ -28,6 +27,39 @@ if vim.eval('exists("g:clang_include_fixer_path")') == "1": binary = vim.eval('g:clang_include_fixer_path') +maximum_suggested_headers=3 +if vim.eval('exists("g:clang_include_fixer_maximum_suggested_headers")') == "1": + maximum_suggested_headers = max( + 1, + vim.eval('g:clang_include_fixer_maximum_suggested_headers')) + + +def ShowDialog(message, choices, default_choice_index=0): + to_eval = "confirm('{0}', '{1}', '{2}')".format(message, + choices, + default_choice_index) + return int(vim.eval(to_eval)); + + +def execute(command, text): + p = subprocess.Popen(command, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + stdin=subprocess.PIPE) + return p.communicate(input=text) + + +def InsertHeaderToVimBuffer(header, text): + command = [binary, "-stdin", "-insert-header="+header, + vim.current.buffer.name] + stdout, stderr = execute(command, text) + if stdout: +lines = stdout.splitlines() +sequence = difflib.SequenceMatcher(None, vim.current.buffer, lines) +for op in reversed(sequence.get_opcodes()): + if op[0] is not 'equal': +vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]] + + def main(): parser = argparse.ArgumentParser( description='Vim integration for clang-include-fixer') @@ -41,24 +73,36 @@ buf = vim.current.buffer text = '\n'.join(buf) - # Call clang-include-fixer. - command = [binary, "-stdin", "-db="+args.db, "-input="+args.input, + # Run command to get all headers. + command = [binary, "-stdin", "-output-headers", "-db="+args.db, "-input="+args.input, "-debug", vim.current.buffer.name] - p = subprocess.Popen(command, - stdout=subprocess.PIPE, stderr=subprocess.PIPE, - stdin=subprocess.PIPE) - stdout, stderr = p.communicate(input=text) + stdout, stderr = execute(command, text) + lines = stdout.splitlines() + if len(lines) < 2: +print "No header is included.\n" +return - # If successful, replace buffer contents. - if stderr: -print stderr + # The first line is the symbol name. + symbol = lines[0] + # If there is only one suggested header, insert it directly. + if len(lines) == 2 or maximum_suggested_headers == 1: +InsertHeaderToVimBuffer(lines[1], text) +print "Added #include {0} for {1}.\n".format(lin
Re: [PATCH] D20621: [include-fixer] Create a mode in vim integration to show multiple potential headers.
hokein marked an inline comment as done. hokein added a comment. http://reviews.llvm.org/D20621 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20804: [include-fixer] collect the number of times a symbols is found in an indexing run and use it for symbols popularity ranking.
bkramer accepted this revision. bkramer added a comment. This revision is now accepted and ready to land. lg http://reviews.llvm.org/D20804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r271258 - [include-fixer] Create a mode in vim integration to show multiple potential headers.
Author: hokein Date: Tue May 31 04:31:51 2016 New Revision: 271258 URL: http://llvm.org/viewvc/llvm-project?rev=271258&view=rev Log: [include-fixer] Create a mode in vim integration to show multiple potential headers. Summary: Some changes in the patch: * Add two commandline flags in clang-include-fixer. * Introduce a IncludeFixerContext for the queried symbol. * Pull out CreateReplacementsForHeader. Reviewers: bkramer Subscribers: klimek, cfe-commits, ioeric Differential Revision: http://reviews.llvm.org/D20621 Added: clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h clang-tools-extra/trunk/test/include-fixer/commandline_options.cpp Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp clang-tools-extra/trunk/include-fixer/IncludeFixer.h clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=271258&r1=271257&r2=271258&view=diff == --- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original) +++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Tue May 31 04:31:51 2016 @@ -214,7 +214,7 @@ public: /// Get the minimal include for a given path. std::string minimizeInclude(StringRef Include, - clang::SourceManager &SourceManager, + const clang::SourceManager &SourceManager, clang::HeaderSearch &HeaderSearch) { if (!MinimizeIncludePaths) return Include; @@ -236,66 +236,21 @@ public: return IsSystem ? '<' + Suggestion + '>' : '"' + Suggestion + '"'; } - /// Insert all headers before the first #include in \p Code and run - /// clang-format to sort all headers. - /// \return Replacements for inserting and sorting headers. - std::vector - CreateReplacementsForHeaders(StringRef Code, - const std::set &Headers) { -// Create replacements for new headers. -clang::tooling::Replacements Insertions; -if (FirstIncludeOffset == -1U) { - // FIXME: skip header guards. - FirstIncludeOffset = 0; - // If there is no existing #include, then insert an empty line after new - // header block. - if (Code.front() != '\n') -Insertions.insert( -clang::tooling::Replacement(Filename, FirstIncludeOffset, 0, "\n")); -} -// Keep inserting new headers before the first header. -for (StringRef Header : Headers) { - std::string Text = "#include " + Header.str() + "\n"; - Insertions.insert( - clang::tooling::Replacement(Filename, FirstIncludeOffset, 0, Text)); -} -DEBUG({ - llvm::dbgs() << "Header insertions:\n"; - for (const auto &R : Insertions) -llvm::dbgs() << R.toString() << '\n'; -}); - -clang::format::FormatStyle Style = -clang::format::getStyle("file", Filename, FallbackStyle); -clang::tooling::Replacements Replaces = -formatReplacements(Code, Insertions, Style); -// FIXME: remove this when `clang::tooling::Replacements` is implemented as -// `std::vector`. -std::vector Results; -std::copy(Replaces.begin(), Replaces.end(), std::back_inserter(Results)); -return Results; - } - - /// Generate replacements for the suggested includes. - /// \return true if changes will be made, false otherwise. - bool Rewrite(clang::SourceManager &SourceManager, - clang::HeaderSearch &HeaderSearch, - std::set &Headers, - std::vector &Replacements) { + /// Get the include fixer context for the queried symbol. + IncludeFixerContext + getIncludeFixerContext(const clang::SourceManager &SourceManager, + clang::HeaderSearch &HeaderSearch) { +IncludeFixerContext FixerContext; if (SymbolQueryResults.empty()) - return false; + return FixerContext; -// FIXME: Rank the results and pick the best one instead of the first one. -const auto &ToTry = SymbolQueryResults.front(); -Headers.insert(minimizeInclude(ToTry, SourceManager, HeaderSearch)); - -StringRef Code = SourceManager.getBufferData(SourceManager.getMainFileID()); -Replacements = CreateReplacementsForHeaders(Code, Headers); - -// We currently abort after the first inserted include. The more -// includes we have the less safe this becomes due to error recovery -// changing the results. -return true; +FixerContext.SymbolIdentifer = QuerySymbol; +FixerContext.FirstIncludeOffset = FirstIncludeOffset; +for (const auto &Header : SymbolQueryResults) + FixerContext.Headers.push_back( + minimizeInclude(Header
Re: [PATCH] D20621: [include-fixer] Create a mode in vim integration to show multiple potential headers.
klimek accepted this revision. klimek added a reviewer: klimek. klimek added a comment. lg http://reviews.llvm.org/D20621 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20621: [include-fixer] Create a mode in vim integration to show multiple potential headers.
This revision was automatically updated to reflect the committed changes. Closed by commit rL271258: [include-fixer] Create a mode in vim integration to show multiple potential… (authored by hokein). Changed prior to commit: http://reviews.llvm.org/D20621?vs=59028&id=59030#toc Repository: rL LLVM http://reviews.llvm.org/D20621 Files: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp clang-tools-extra/trunk/include-fixer/IncludeFixer.h clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py clang-tools-extra/trunk/test/include-fixer/commandline_options.cpp clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp === --- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp +++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp @@ -70,11 +70,16 @@ SymbolIndexMgr->addSymbolIndex( llvm::make_unique(Symbols)); - std::set Headers; - std::vector Replacements; - IncludeFixerActionFactory Factory(*SymbolIndexMgr, Headers, Replacements, -"llvm"); + IncludeFixerContext FixerContext; + IncludeFixerActionFactory Factory(*SymbolIndexMgr, FixerContext, "llvm"); + runOnCode(&Factory, Code, "input.cc", ExtraArgs); + std::vector Replacements; + if (!FixerContext.Headers.empty()) { +Replacements = clang::include_fixer::createInsertHeaderReplacements( +Code, "input.cc", FixerContext.Headers.front(), +FixerContext.FirstIncludeOffset); + } clang::RewriterTestContext Context; clang::FileID ID = Context.createInMemoryFile("input.cc", Code); clang::tooling::applyAllReplacements(Replacements, Context.Rewrite); Index: clang-tools-extra/trunk/include-fixer/IncludeFixer.h === --- clang-tools-extra/trunk/include-fixer/IncludeFixer.h +++ clang-tools-extra/trunk/include-fixer/IncludeFixer.h @@ -10,7 +10,9 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INCLUDEFIXER_H #define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INCLUDEFIXER_H +#include "IncludeFixerContext.h" #include "SymbolIndexManager.h" +#include "clang/Format/Format.h" #include "clang/Tooling/Core/Replacement.h" #include "clang/Tooling/Tooling.h" #include @@ -28,13 +30,12 @@ class IncludeFixerActionFactory : public clang::tooling::ToolAction { public: /// \param SymbolIndexMgr A source for matching symbols to header files. - /// \param Replacements Storage for the output of the fixer. + /// \param Context A context for the symbol being queried. /// \param StyleName Fallback style for reformatting. /// \param MinimizeIncludePaths whether inserted include paths are optimized. - IncludeFixerActionFactory( - SymbolIndexManager &SymbolIndexMgr, std::set &Headers, - std::vector &Replacements, - StringRef StyleName, bool MinimizeIncludePaths = true); + IncludeFixerActionFactory(SymbolIndexManager &SymbolIndexMgr, +IncludeFixerContext &Context, StringRef StyleName, +bool MinimizeIncludePaths = true); ~IncludeFixerActionFactory() override; @@ -48,11 +49,8 @@ /// The client to use to find cross-references. SymbolIndexManager &SymbolIndexMgr; - /// Headers to be added. - std::set &Headers; - - /// Replacements are written here. - std::vector &Replacements; + /// The context that contains all information about the symbol being queried. + IncludeFixerContext &Context; /// Whether inserted include paths should be optimized. bool MinimizeIncludePaths; @@ -62,6 +60,25 @@ std::string FallbackStyle; }; +/// Create replacements for the header being inserted. The replacements will +/// insert a header before the first #include in \p Code, and sort all headers +/// with the given clang-format style. +/// +/// \param Code The source code. +/// \param FilePath The source file path. +/// \param Header The header being inserted. +/// \param FirstIncludeOffset The insertion point for new include directives. +/// The default value -1U means inserting the header at the first line, and if +/// there is no #include block, it will create a header block by inserting a +/// newline. +/// \param Style clang-format style being used. +/// +/// \return Replacements for inserting and sorting headers. +std::vector createInsertHeaderReplacements( +StringRef Code, StringRef FilePath, StringRef Header, +unsigned FirstIncludeOffset = -1U, +const clang::format::FormatStyle &Style = clang::format::getLLVMStyle()); + } // namespace include_fixer } // namespace clang Index: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp ===
Re: [PATCH] D20621: [include-fixer] Create a mode in vim integration to show multiple potential headers.
hokein added a comment. In http://reviews.llvm.org/D20621#444050, @bkramer wrote: > LG. Can't wait to use it myself :) Currently, the header is only inserted at the first line of the file because we don't output the FirstIncludeOffset to py script. A follow-up patch will come soon. Repository: rL LLVM http://reviews.llvm.org/D20621 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20709: Support ARM subtarget feature +long64
rengolin added a comment. In http://reviews.llvm.org/D20709#443950, @srhines wrote: > Correct. This is only used by RenderScript, and unfortunately can't be done > any differently. We had hoped to just predicate this with our own LangOpt > (the patch that adds the RenderScript LangOpt is coming soon), but > unfortunately, at the point where LangOpts are being parsed, the target > machine already has the size and alignment of long specified (and it can't > change). Hi Stephen, GCC uses -mabi=ilp32 or -mabi=lp64 for AArch64 to change the ABI, you could do the same on Renderscript. If this is how Renderscript *always* operate, than having a "renderscript" ABI would make even more sense. cheers, --renato http://reviews.llvm.org/D20709 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r271261 - [include-fixer] Add missing dependency.
Author: hokein Date: Tue May 31 05:06:12 2016 New Revision: 271261 URL: http://llvm.org/viewvc/llvm-project?rev=271261&view=rev Log: [include-fixer] Add missing dependency. Modified: clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt Modified: clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt?rev=271261&r1=271260&r2=271261&view=diff == --- clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt (original) +++ clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt Tue May 31 05:06:12 2016 @@ -3,6 +3,7 @@ include_directories(${CMAKE_CURRENT_SOUR add_clang_executable(clang-include-fixer ClangIncludeFixer.cpp) target_link_libraries(clang-include-fixer clangBasic + clangFormat clangFrontend clangIncludeFixer clangRewrite ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r271262 - [CommonOptionsParser] Return source paths as const ref.
Author: d0k Date: Tue May 31 05:17:46 2016 New Revision: 271262 URL: http://llvm.org/viewvc/llvm-project?rev=271262&view=rev Log: [CommonOptionsParser] Return source paths as const ref. This saves a superfluous copy and makes managing the lifetime of the returned strings a bit easier. Modified: cfe/trunk/include/clang/Tooling/CommonOptionsParser.h Modified: cfe/trunk/include/clang/Tooling/CommonOptionsParser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/CommonOptionsParser.h?rev=271262&r1=271261&r2=271262&view=diff == --- cfe/trunk/include/clang/Tooling/CommonOptionsParser.h (original) +++ cfe/trunk/include/clang/Tooling/CommonOptionsParser.h Tue May 31 05:17:46 2016 @@ -98,7 +98,7 @@ public: } /// Returns a list of source file paths to process. - std::vector getSourcePathList() { + const std::vector &getSourcePathList() const { return SourcePathList; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().
ioeric added inline comments. Comment at: unittests/Format/CleanupTest.cpp:310 @@ +309,3 @@ + + Context.createInMemoryFile("fix.cpp", Code); + tooling::Replacements Replaces; djasper wrote: > I'd pull out a lot of these environment setup things into abstractions in the > test fixture. Maybe all you need is two functions like: > > insert(Code, Replaces); > > and > > insertAndFormat(Code, Replaces); > > ? I had tried to pull out the environment setup...but it didn't seem to save much code without sacrificing flexibility. In some test cases, we also need to add replacements other than header insertions, and those replacements construction uses `FileID`, so `createInMemoryFile` needs to stay in test functions. `FormatStyle` differs among test cases, so it has to stay. All we save might just be the two lines which could be either cleanup or cleanup+format.\ Any better ideas? http://reviews.llvm.org/D20734 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().
ioeric updated this revision to Diff 59035. ioeric marked 7 inline comments as done. ioeric added a comment. - Addressed commments. http://reviews.llvm.org/D20734 Files: include/clang/Format/Format.h lib/Format/Format.cpp unittests/Format/CleanupTest.cpp Index: unittests/Format/CleanupTest.cpp === --- unittests/Format/CleanupTest.cpp +++ unittests/Format/CleanupTest.cpp @@ -269,18 +269,313 @@ "int x= 0;" "}"; FileID ID = Context.createInMemoryFile("fix.cpp", Code); - tooling::Replacements Replaces; - Replaces.insert(tooling::Replacement(Context.Sources, - Context.getLocation(ID, 3, 3), 6, "")); - Replaces.insert(tooling::Replacement(Context.Sources, - Context.getLocation(ID, 9, 34), 6, "")); + tooling::Replacements Replaces = { + tooling::Replacement(Context.Sources, Context.getLocation(ID, 3, 3), 6, + ""), + tooling::Replacement(Context.Sources, Context.getLocation(ID, 9, 34), 6, + "")}; format::FormatStyle Style = format::getLLVMStyle(); auto FinalReplaces = formatReplacements( Code, cleanupAroundReplacements(Code, Replaces, Style), Style); EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces)); } +TEST_F(CleanUpReplacementsTest, NoExistingIncludeWithoutDefine) { + std::string Code = "int main() {}"; + std::string Expected = "#include \"a.h\"\n" + "int main() {}"; + Context.createInMemoryFile("fix.cpp", Code); + tooling::Replacements Replaces = { + tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"a.h\"")}; + format::FormatStyle Style = format::getLLVMStyle(); + auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style); + EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces)); +} + +TEST_F(CleanUpReplacementsTest, NoExistingIncludeWithDefine) { + std::string Code = "#ifndef __A_H__\n" + "#define __A_H__\n" + "class A {};\n" + "#define MMM 123\n" + "#endif"; + std::string Expected = "#ifndef __A_H__\n" + "#define __A_H__\n" + "#include \"b.h\"\n" + "class A {};\n" + "#define MMM 123\n" + "#endif"; + + Context.createInMemoryFile("fix.cpp", Code); + tooling::Replacements Replaces = { + tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"b.h\"")}; + format::FormatStyle Style = format::getLLVMStyle(); + auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style); + EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces)); +} + +TEST_F(CleanUpReplacementsTest, InsertBeforeCategoryWithLowerPriority) { + std::string Code = "#ifndef __A_H__\n" + "#define __A_H__\n" + "\n" + "\n" + "\n" + "#include \n" + "class A {};\n" + "#define MMM 123\n" + "#endif"; + std::string Expected = "#ifndef __A_H__\n" + "#define __A_H__\n" + "\n" + "\n" + "\n" + "#include \"a.h\"\n" + "#include \n" + "class A {};\n" + "#define MMM 123\n" + "#endif"; + + Context.createInMemoryFile("fix.cpp", Code); + tooling::Replacements Replaces = { + tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"a.h\"")}; + format::FormatStyle Style = format::getLLVMStyle(); + auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style); + EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces)); +} + +TEST_F(CleanUpReplacementsTest, InsertAfterMainHeader) { + std::string Code = "#include \"fix.h\"\n" + "\n" + "int main() {}"; + std::string Expected = "#include \"fix.h\"\n" + "#include \n" + "\n" + "int main() {}"; + Context.createInMemoryFile("fix.cpp", Code); + tooling::Replacements Replaces = { + tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include ")}; + format::FormatStyle Style = + format::getGoogleStyle(format::FormatStyle::LanguageKind::LK_Cpp); + auto NewReplaces = cleanupAroundReplacements(Code, Replaces, Style); + EXPECT_EQ(Expected, applyAllReplacements(Code, NewReplaces)); +} + +TEST_F(CleanUpReplacementsTest, InsertBeforeSystemHeaderLLVM) { + std::string Code = "#include \n" + "\n" + "int main() {}"; + std::string Expected = "#include \"z.h\"\n" + "#include \n" +
Re: [PATCH] D20283: Add ras/noras flag to enable/disable RAS in clang
rogfer01 reclaimed this revision. rogfer01 added a comment. This revision is now accepted and ready to land. Well, seems that Renato reverted the changes, so this still holds. http://reviews.llvm.org/D20283 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20561: Warn when taking address of packed member
rogfer01 added a comment. Ping? Thank you very much http://reviews.llvm.org/D20561 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().
djasper added inline comments. Comment at: unittests/Format/CleanupTest.cpp:310 @@ +309,3 @@ + Context.createInMemoryFile("fix.cpp", Code); + tooling::Replacements Replaces = { + tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"b.h\"")}; Well, the only reason you seem to be using the FileID or "Context" for that matter is to translate between line/col and offset. I'd just pull that functionality out into a separate function (which does it based on the "Code" input) or not at all (hard-coding the offset doesn't seem *that* bad). Comment at: unittests/Format/CleanupTest.cpp:510 @@ +509,3 @@ +TEST_F(CleanUpReplacementsTest, InsertMultipleNewHeadersAndSortGoogle) { + std::string Code = "\nint x;"; + std::string Expected = "#include \"fix.h\"\n" Have you seen this comment? http://reviews.llvm.org/D20734 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D20808: [include-fixer] Code cleanup.
hokein created this revision. hokein added a reviewer: bkramer. hokein added a subscriber: cfe-commits. * Abstract the DB setting code to a function. * Remove the unused FallbackStyle. http://reviews.llvm.org/D20808 Files: include-fixer/IncludeFixer.cpp include-fixer/tool/ClangIncludeFixer.cpp Index: include-fixer/tool/ClangIncludeFixer.cpp === --- include-fixer/tool/ClangIncludeFixer.cpp +++ include-fixer/tool/ClangIncludeFixer.cpp @@ -81,6 +81,59 @@ "headers if there is no clang-format config file found."), cl::init("llvm"), cl::cat(IncludeFixerCategory)); +std::unique_ptr +createSymbolIndexManager(StringRef FilePath) { + auto SymbolIndexMgr = llvm::make_unique(); + switch (DatabaseFormat) { + case fixed: { +// Parse input and fill the database with it. +// =<, header...> +// Multiple symbols can be given, separated by semicolons. +std::map> SymbolsMap; +SmallVector SemicolonSplits; +StringRef(Input).split(SemicolonSplits, ";"); +std::vector Symbols; +for (StringRef Pair : SemicolonSplits) { + auto Split = Pair.split('='); + std::vector Headers; + SmallVector CommaSplits; + Split.second.split(CommaSplits, ","); + for (StringRef Header : CommaSplits) +Symbols.push_back(find_all_symbols::SymbolInfo( +Split.first.trim(), +find_all_symbols::SymbolInfo::SymbolKind::Unknown, Header.trim(), 1, +{})); +} +SymbolIndexMgr->addSymbolIndex( +llvm::make_unique(Symbols)); +break; + } + case yaml: { +llvm::ErrorOr> DB(nullptr); +if (!Input.empty()) { + DB = include_fixer::YamlSymbolIndex::createFromFile(Input); +} else { + // If we don't have any input file, look in the directory of the first + // file and its parents. + SmallString<128> AbsolutePath(tooling::getAbsolutePath(FilePath)); + StringRef Directory = llvm::sys::path::parent_path(AbsolutePath); + DB = include_fixer::YamlSymbolIndex::createFromDirectory( + Directory, "find_all_symbols_db.yaml"); +} + +if (!DB) { + llvm::errs() << "Couldn't find YAML db: " << DB.getError().message() + << '\n'; + return nullptr; +} + +SymbolIndexMgr->addSymbolIndex(std::move(*DB)); +break; + } + } + return SymbolIndexMgr; +} + int includeFixerMain(int argc, const char **argv) { tooling::CommonOptionsParser options(argc, argv, IncludeFixerCategory); tooling::ClangTool tool(options.getCompilations(), @@ -128,55 +181,10 @@ } // Set up data source. - auto SymbolIndexMgr = llvm::make_unique(); - switch (DatabaseFormat) { - case fixed: { -// Parse input and fill the database with it. -// =<, header...> -// Multiple symbols can be given, separated by semicolons. -std::map> SymbolsMap; -SmallVector SemicolonSplits; -StringRef(Input).split(SemicolonSplits, ";"); -std::vector Symbols; -for (StringRef Pair : SemicolonSplits) { - auto Split = Pair.split('='); - std::vector Headers; - SmallVector CommaSplits; - Split.second.split(CommaSplits, ","); - for (StringRef Header : CommaSplits) -Symbols.push_back(find_all_symbols::SymbolInfo( -Split.first.trim(), -find_all_symbols::SymbolInfo::SymbolKind::Unknown, Header.trim(), 1, -{})); -} -SymbolIndexMgr->addSymbolIndex( -llvm::make_unique(Symbols)); -break; - } - case yaml: { -llvm::ErrorOr> DB(nullptr); -if (!Input.empty()) { - DB = include_fixer::YamlSymbolIndex::createFromFile(Input); -} else { - // If we don't have any input file, look in the directory of the first - // file and its parents. - SmallString<128> AbsolutePath( - tooling::getAbsolutePath(options.getSourcePathList().front())); - StringRef Directory = llvm::sys::path::parent_path(AbsolutePath); - DB = include_fixer::YamlSymbolIndex::createFromDirectory( - Directory, "find_all_symbols_db.yaml"); -} - -if (!DB) { - llvm::errs() << "Couldn't find YAML db: " << DB.getError().message() - << '\n'; - return 1; -} - -SymbolIndexMgr->addSymbolIndex(std::move(*DB)); -break; - } - } + std::unique_ptr SymbolIndexMgr = + createSymbolIndexManager(options.getSourcePathList().front()); + if (!SymbolIndexMgr) +return 1; // Now run our tool. include_fixer::IncludeFixerContext Context; Index: include-fixer/IncludeFixer.cpp === --- include-fixer/IncludeFixer.cpp +++ include-fixer/IncludeFixer.cpp @@ -59,9 +59,8 @@ class Action : public clang::ASTFrontendAction, public clang::ExternalSemaSource { public: - explicit Action(SymbolIndexManager &SymbolIndexMgr, StringRef StyleName, - bool MinimizeIncludePaths) -
r271263 - [OPENMP] Update in ReleaseNotes for OpenMP support.
Author: abataev Date: Tue May 31 06:17:08 2016 New Revision: 271263 URL: http://llvm.org/viewvc/llvm-project?rev=271263&view=rev Log: [OPENMP] Update in ReleaseNotes for OpenMP support. Added notes about full support of all non-offloading features of OpenMP 4.5 + info about option -fopenmp-version=[31|40|45] that allows to control supported OpenMP version. Modified: cfe/trunk/docs/ReleaseNotes.rst Modified: cfe/trunk/docs/ReleaseNotes.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=271263&r1=271262&r2=271263&view=diff == --- cfe/trunk/docs/ReleaseNotes.rst (original) +++ cfe/trunk/docs/ReleaseNotes.rst Tue May 31 06:17:08 2016 @@ -158,6 +158,21 @@ OpenCL C Language Changes in Clang ... +OpenMP Support in Clang +-- + +Added support for all non-offloading features from OpenMP 4.5, including using +data members in private clauses of non-static member functions. Additionally, +data members can be used as loop control variables in loop-based directives. + +Currently Clang supports OpenMP 3.1 and all non-offloading features of +OpenMP 4.0/4.5. Offloading features are under development. Clang defines macro +_OPENMP and sets it to OpenMP 3.1 (in accordance with OpenMP standard) by +default. User may change this value using ``-fopenmp-version=[31|40|45]`` option. + +The codegen for OpenMP constructs was significantly improved to produce much +more stable and faster code. + Internal API Changes ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r271265 - [Clang][Intrinsics][avx512] Adding round cvt to clang
Author: mzuckerm Date: Tue May 31 06:27:34 2016 New Revision: 271265 URL: http://llvm.org/viewvc/llvm-project?rev=271265&view=rev Log: [Clang][Intrinsics][avx512] Adding round cvt to clang Differential Revision: http://reviews.llvm.org/D20790 Modified: cfe/trunk/lib/Headers/avx512fintrin.h cfe/trunk/test/CodeGen/avx512f-builtins.c Modified: cfe/trunk/lib/Headers/avx512fintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=271265&r1=271264&r2=271265&view=diff == --- cfe/trunk/lib/Headers/avx512fintrin.h (original) +++ cfe/trunk/lib/Headers/avx512fintrin.h Tue May 31 06:27:34 2016 @@ -3452,11 +3452,37 @@ _mm512_maskz_cvttps_epu32 (__mmask16 __U (__v16sf)_mm512_setzero_ps(), \ (__mmask16)-1, (int)(R)); }) +#define _mm512_mask_cvt_roundepi32_ps( __W, __U, __A, __R) __extension__ ({ \ +__builtin_ia32_cvtdq2ps512_mask ((__v16si)( __A),\ + (__v16sf)( __W),\ + (__mmask16)( __U),( __R));\ +}) + +#define _mm512_maskz_cvt_roundepi32_ps( __U, __A, __R) __extension__ ({ \ +__builtin_ia32_cvtdq2ps512_mask ((__v16si)( __A),\ + (__v16sf)\ + _mm512_setzero_ps (),\ + (__mmask16)( __U),( __R));\ +}) + #define _mm512_cvt_roundepu32_ps(A, R) __extension__ ({ \ (__m512)__builtin_ia32_cvtudq2ps512_mask((__v16si)(__m512i)(A), \ (__v16sf)_mm512_setzero_ps(), \ (__mmask16)-1, (int)(R)); }) +#define _mm512_mask_cvt_roundepu32_ps( __W, __U, __A, __R) __extension__ ({ \ +__builtin_ia32_cvtudq2ps512_mask ((__v16si)( __A),\ + (__v16sf)( __W),\ + (__mmask16)( __U),( __R));\ +}) + +#define _mm512_maskz_cvt_roundepu32_ps( __U, __A, __R) __extension__ ({ \ +__builtin_ia32_cvtudq2ps512_mask ((__v16si)( __A),\ + (__v16sf)\ + _mm512_setzero_ps (),\ + (__mmask16)( __U),( __R));\ +}) + static __inline__ __m512 __DEFAULT_FN_ATTRS _mm512_cvtepu32_ps (__m512i __A) { @@ -3566,6 +3592,16 @@ _mm512_maskz_cvtepu32_pd (__mmask8 __U, (__v8sf)_mm256_setzero_ps(), \ (__mmask8)-1, (int)(R)); }) +#define _mm512_mask_cvt_roundpd_ps(W, U, A, R) __extension__ ({ \ + (__m256)__builtin_ia32_cvtpd2ps512_mask((__v8df)(__m512d)(A), \ + (__v8sf)(W), \ + (__mmask8)(U), (int)(R)); }) + +#define _mm512_maskz_cvt_roundpd_ps(U, A, R) __extension__ ({ \ + (__m256)__builtin_ia32_cvtpd2ps512_mask((__v8df)(__m512d)(A), \ + (__v8sf)_mm256_setzero_ps(), \ + (__mmask8)(U), (int)(R)); }) + static __inline__ __m256 __DEFAULT_FN_ATTRS _mm512_cvtpd_ps (__m512d __A) { @@ -3637,6 +3673,21 @@ _mm512_maskz_cvtph_ps (__mmask16 __U, __ _MM_FROUND_CUR_DIRECTION); } +#define _mm512_cvtt_roundpd_epi32(A, R) __extension__ ({ \ + (__m256i)__builtin_ia32_cvttpd2dq512_mask((__v8df)(__m512d)(A), \ +(__v8si)_mm256_setzero_si256(), \ +(__mmask8)-1, (int)(R)); }) + +#define _mm512_mask_cvtt_roundpd_epi32(W, U, A, R) __extension__ ({ \ + (__m256i)__builtin_ia32_cvttpd2dq512_mask((__v8df)(__m512d)(A), \ +(__v8si)(W), \ +(__mmask8)(U), (int)(R)); }) + +#define _mm512_maskz_cvtt_roundpd_epi32( U, A, R) __extension__ ({ \ + (__m256i)__builtin_ia32_cvttpd2dq512_mask((__v8df)(__m512d)(A), \ +(__v8si)_mm256_setzero_si256(), \ +(__mmask8)(U), (int)(R)); }) + static __inline __m256i __DEFAULT_FN_ATTRS _mm512_cvttpd_epi32(__m512d __a) { @@ -3664,16 +3715,21 @@ _mm512_maskz_cvttpd_epi32 (__mmask8 __U, _MM_FROUND_CUR_DIRECTION); } -#define _mm512_cvtt_roundpd_epi32(A, R) __extension__ ({ \ - (__m256i)__builtin_ia32_cvttpd2dq512_mask((__v8df)(__m512d)(A), \ -(__v8si)_mm256_setzero_si256(), \ -(__mmask8)-1, (int)(R)); }) - #define _mm512_cvtt_roundps_epi32(A, R) __extension__ ({ \ (__m512i)__builtin_ia32_cvttps2dq512_mask((__v16sf)(__m512)(A), \ (__v16si)_mm512_setzero_si512(), \ (__mmask16)-1, (int)(R)); }) +#define _mm512_mask_cvtt_roundps_epi32( W, U, A, R) __extension__ ({ \ + (__m512i)__builtin_ia32_cvttps2dq512_mask((__v16sf)(__m512)(A), \ +(__v16si)(W), \ +
Re: [PATCH] D20790: [Clang][Intrinsics][avx512] Adding round cvt to clang
This revision was automatically updated to reflect the committed changes. Closed by commit rL271265: [Clang][Intrinsics][avx512] Adding round cvt to clang (authored by mzuckerm). Changed prior to commit: http://reviews.llvm.org/D20790?vs=58957&id=59040#toc Repository: rL LLVM http://reviews.llvm.org/D20790 Files: cfe/trunk/lib/Headers/avx512fintrin.h cfe/trunk/test/CodeGen/avx512f-builtins.c Index: cfe/trunk/test/CodeGen/avx512f-builtins.c === --- cfe/trunk/test/CodeGen/avx512f-builtins.c +++ cfe/trunk/test/CodeGen/avx512f-builtins.c @@ -3106,6 +3106,140 @@ // CHECK: @llvm.x86.avx512.cvttss2usi64 return _mm_cvttss_u64(__A); } + +__m512 test_mm512_mask_cvt_roundepi32_ps(__m512 __W, __mmask16 __U, __m512i __A) +{ + // CHECK-LABEL: @test_mm512_mask_cvt_roundepi32_ps + // CHECK: @llvm.x86.avx512.mask.cvtdq2ps.512 + return _mm512_mask_cvt_roundepi32_ps(__W,__U,__A,4); +} + +__m512 test_mm512_maskz_cvt_roundepi32_ps(__mmask16 __U, __m512i __A) +{ + // CHECK-LABEL: @test_mm512_maskz_cvt_roundepi32_ps + // CHECK: @llvm.x86.avx512.mask.cvtdq2ps.512 + return _mm512_maskz_cvt_roundepi32_ps(__U,__A,4); +} + +__m512 test_mm512_mask_cvt_roundepu32_ps(__m512 __W, __mmask16 __U,__m512i __A) +{ + // CHECK-LABEL: @test_mm512_mask_cvt_roundepu32_ps + // CHECK: @llvm.x86.avx512.mask.cvtudq2ps.512 + return _mm512_mask_cvt_roundepu32_ps(__W,__U,__A,4); +} + +__m512 test_mm512_maskz_cvt_roundepu32_ps(__mmask16 __U,__m512i __A) +{ + // CHECK-LABEL: @test_mm512_maskz_cvt_roundepu32_ps + // CHECK: @llvm.x86.avx512.mask.cvtudq2ps.512 + return _mm512_maskz_cvt_roundepu32_ps(__U,__A,4); +} + +__m256 test_mm512_mask_cvt_roundpd_ps(__m256 W, __mmask8 U,__m512d A) +{ + // CHECK-LABEL: @test_mm512_mask_cvt_roundpd_ps + // CHECK: @llvm.x86.avx512.mask.cvtpd2ps.512 + return _mm512_mask_cvt_roundpd_ps(W,U,A,4); +} + +__m256 test_mm512_maskz_cvt_roundpd_ps(__mmask8 U, __m512d A) +{ + // CHECK-LABEL: @test_mm512_maskz_cvt_roundpd_ps + // CHECK: @llvm.x86.avx512.mask.cvtpd2ps.512 + return _mm512_maskz_cvt_roundpd_ps(U,A,4); +} + +__m256i test_mm512_cvtt_roundpd_epi32(__m512d A) +{ + // CHECK-LABEL: @test_mm512_cvtt_roundpd_epi32 + // CHECK: @llvm.x86.avx512.mask.cvttpd2dq.512 + return _mm512_cvtt_roundpd_epi32(A,4); +} + +__m256i test_mm512_mask_cvtt_roundpd_epi32(__m256i W, __mmask8 U, __m512d A) +{ + // CHECK-LABEL: @test_mm512_mask_cvtt_roundpd_epi32 + // CHECK: @llvm.x86.avx512.mask.cvttpd2dq.512 + return _mm512_mask_cvtt_roundpd_epi32(W,U,A,4); +} + +__m256i test_mm512_maskz_cvtt_roundpd_epi32(__mmask8 U, __m512d A) +{ + // CHECK-LABEL: @test_mm512_maskz_cvtt_roundpd_epi32 + // CHECK: @llvm.x86.avx512.mask.cvttpd2dq.512 + return _mm512_maskz_cvtt_roundpd_epi32(U,A,4); +} + +__m512i test_mm512_mask_cvtt_roundps_epi32(__m512i W,__mmask16 U, __m512 A) +{ + // CHECK-LABEL: @test_mm512_mask_cvtt_roundps_epi32 + // CHECK: @llvm.x86.avx512.mask.cvttps2dq.512 + return _mm512_mask_cvtt_roundps_epi32(W,U,A,4); +} + +__m512i test_mm512_maskz_cvtt_roundps_epi32(__mmask16 U, __m512 A) +{ + // CHECK-LABEL: @test_mm512_maskz_cvtt_roundps_epi32 + // CHECK: @llvm.x86.avx512.mask.cvttps2dq.512 + return _mm512_maskz_cvtt_roundps_epi32(U,A,4); +} + +__m512i test_mm512_mask_cvt_roundps_epi32(__m512i __W,__mmask16 __U,__m512 __A) +{ + // CHECK-LABEL: @test_mm512_mask_cvt_roundps_epi32 + // CHECK: @llvm.x86.avx512.mask.cvtps2dq.512 + return _mm512_mask_cvt_roundps_epi32(__W,__U,__A,4); +} + +__m512i test_mm512_maskz_cvt_roundps_epi32(__mmask16 __U, __m512 __A) +{ + // CHECK-LABEL: @test_mm512_maskz_cvt_roundps_epi32 + // CHECK: @llvm.x86.avx512.mask.cvtps2dq.512 + return _mm512_maskz_cvt_roundps_epi32(__U,__A,4); +} + +__m256i test_mm512_mask_cvt_roundpd_epi32(__m256i W,__mmask8 U,__m512d A) +{ + // CHECK-LABEL: @test_mm512_mask_cvt_roundpd_epi32 + // CHECK: @llvm.x86.avx512.mask.cvtpd2dq.512 + return _mm512_mask_cvt_roundpd_epi32(W,U,A,4); +} + +__m256i test_mm512_maskz_cvt_roundpd_epi32(__mmask8 U, __m512d A) +{ + // CHECK-LABEL: @test_mm512_maskz_cvt_roundpd_epi32 + // CHECK: @llvm.x86.avx512.mask.cvtpd2dq.512 + return _mm512_maskz_cvt_roundpd_epi32(U,A,4); +} + +__m512i test_mm512_mask_cvt_roundps_epu32(__m512i __W,__mmask16 __U,__m512 __A) +{ + // CHECK-LABEL: @test_mm512_mask_cvt_roundps_epu32 + // CHECK: @llvm.x86.avx512.mask.cvtps2udq.512 + return _mm512_mask_cvt_roundps_epu32(__W,__U,__A,4); +} + +__m512i test_mm512_maskz_cvt_roundps_epu32(__mmask16 __U,__m512 __A) +{ + // CHECK-LABEL: @test_mm512_maskz_cvt_roundps_epu32 + // CHECK: @llvm.x86.avx512.mask.cvtps2udq.512 + return _mm512_maskz_cvt_roundps_epu32(__U,__A, 4); +} + +__m256i test_mm512_mask_cvt_roundpd_epu32(__m256i W, __mmask8 U, __m512d A) +{ + // CHECK-LABEL: @test_mm512_mask_cvt_roundpd_epu32 + // CHECK: @llvm.x86.avx512.mask.cvtpd2udq.512 + return _mm512_mask_cvt_roundpd_epu32(W,U,A,4); +} + +__m256i test_mm512_maskz_cvt_roundpd_epu32(__mmask8 U, __m51
[clang-tools-extra] r271266 - Make the vim integration output a bit prettier and drop the -debug flag.
Author: d0k Date: Tue May 31 06:28:34 2016 New Revision: 271266 URL: http://llvm.org/viewvc/llvm-project?rev=271266&view=rev Log: Make the vim integration output a bit prettier and drop the -debug flag. Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py?rev=271266&r1=271265&r2=271266&view=diff == --- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py (original) +++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.py Tue May 31 06:28:34 2016 @@ -36,7 +36,7 @@ if vim.eval('exists("g:clang_include_fix def ShowDialog(message, choices, default_choice_index=0): to_eval = "confirm('{0}', '{1}', '{2}')".format(message, - choices, + choices.strip(), default_choice_index) return int(vim.eval(to_eval)); @@ -74,8 +74,8 @@ def main(): text = '\n'.join(buf) # Run command to get all headers. - command = [binary, "-stdin", "-output-headers", "-db="+args.db, "-input="+args.input, "-debug", - vim.current.buffer.name] + command = [binary, "-stdin", "-output-headers", "-db="+args.db, + "-input="+args.input, vim.current.buffer.name] stdout, stderr = execute(command, text) lines = stdout.splitlines() if len(lines) < 2: @@ -93,7 +93,7 @@ def main(): choices_message = "" index = 1; for header in lines[1:1+maximum_suggested_headers]: -choices_message += "&" + str(index) + header + "\n" +choices_message += "&{0} {1}\n".format(index, header) index += 1 select = ShowDialog("choose a header file for {0}.".format(symbol), ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D20809: [include-fixer] Show better messages on unfound symbols.
hokein created this revision. hokein added a reviewer: bkramer. hokein added a subscriber: cfe-commits. Also some misc tweaks. http://reviews.llvm.org/D20809 Files: include-fixer/IncludeFixer.cpp include-fixer/IncludeFixerContext.h include-fixer/tool/ClangIncludeFixer.cpp include-fixer/tool/clang-include-fixer.py Index: include-fixer/tool/clang-include-fixer.py === --- include-fixer/tool/clang-include-fixer.py +++ include-fixer/tool/clang-include-fixer.py @@ -74,12 +74,17 @@ text = '\n'.join(buf) # Run command to get all headers. - command = [binary, "-stdin", "-output-headers", "-db="+args.db, "-input="+args.input, "-debug", - vim.current.buffer.name] + command = [binary, "-stdin", "-output-headers", "-db="+args.db, + "-input="+args.input, vim.current.buffer.name] stdout, stderr = execute(command, text) lines = stdout.splitlines() - if len(lines) < 2: -print "No header is included.\n" + + if len(lines) == 0: +print "The file is fine, no need to add a header.\n" +return; + + if len(lines) == 1: +print "Couldn't find a header for {0}.\n".format(lines[0]) return # The first line is the symbol name. Index: include-fixer/tool/ClangIncludeFixer.cpp === --- include-fixer/tool/ClangIncludeFixer.cpp +++ include-fixer/tool/ClangIncludeFixer.cpp @@ -190,8 +190,10 @@ } if (OutputHeaders) { +if (Context.SymbolIdentifier.empty()) + return 0; // FIXME: Output IncludeFixerContext as YAML. -llvm::outs() << Context.SymbolIdentifer << "\n"; +llvm::outs() << Context.SymbolIdentifier << "\n"; for (const auto &Header : Context.Headers) llvm::outs() << Header << "\n"; return 0; Index: include-fixer/IncludeFixerContext.h === --- include-fixer/IncludeFixerContext.h +++ include-fixer/IncludeFixerContext.h @@ -19,7 +19,7 @@ /// \brief A context for the symbol being queried. struct IncludeFixerContext { /// \brief The symbol name. - std::string SymbolIdentifer; + std::string SymbolIdentifier; /// \brief The headers which have SymbolIdentifier definitions. std::vector Headers; /// \brief The insertion point for new include header. Index: include-fixer/IncludeFixer.cpp === --- include-fixer/IncludeFixer.cpp +++ include-fixer/IncludeFixer.cpp @@ -241,10 +241,7 @@ getIncludeFixerContext(const clang::SourceManager &SourceManager, clang::HeaderSearch &HeaderSearch) { IncludeFixerContext FixerContext; -if (SymbolQueryResults.empty()) - return FixerContext; - -FixerContext.SymbolIdentifer = QuerySymbol; +FixerContext.SymbolIdentifier = QuerySymbol; FixerContext.FirstIncludeOffset = FirstIncludeOffset; for (const auto &Header : SymbolQueryResults) FixerContext.Headers.push_back( Index: include-fixer/tool/clang-include-fixer.py === --- include-fixer/tool/clang-include-fixer.py +++ include-fixer/tool/clang-include-fixer.py @@ -74,12 +74,17 @@ text = '\n'.join(buf) # Run command to get all headers. - command = [binary, "-stdin", "-output-headers", "-db="+args.db, "-input="+args.input, "-debug", - vim.current.buffer.name] + command = [binary, "-stdin", "-output-headers", "-db="+args.db, + "-input="+args.input, vim.current.buffer.name] stdout, stderr = execute(command, text) lines = stdout.splitlines() - if len(lines) < 2: -print "No header is included.\n" + + if len(lines) == 0: +print "The file is fine, no need to add a header.\n" +return; + + if len(lines) == 1: +print "Couldn't find a header for {0}.\n".format(lines[0]) return # The first line is the symbol name. Index: include-fixer/tool/ClangIncludeFixer.cpp === --- include-fixer/tool/ClangIncludeFixer.cpp +++ include-fixer/tool/ClangIncludeFixer.cpp @@ -190,8 +190,10 @@ } if (OutputHeaders) { +if (Context.SymbolIdentifier.empty()) + return 0; // FIXME: Output IncludeFixerContext as YAML. -llvm::outs() << Context.SymbolIdentifer << "\n"; +llvm::outs() << Context.SymbolIdentifier << "\n"; for (const auto &Header : Context.Headers) llvm::outs() << Header << "\n"; return 0; Index: include-fixer/IncludeFixerContext.h === --- include-fixer/IncludeFixerContext.h +++ include-fixer/IncludeFixerContext.h @@ -19,7 +19,7 @@ /// \brief A context for the symbol being queried. struct IncludeFixerContext { /// \brief The symbol name. - std::string SymbolIdentifer; + std::string SymbolIdentifier; /// \brief The headers which have Sy
Re: [PATCH] D20809: [include-fixer] Show better messages on unfound symbols.
hokein updated this revision to Diff 59042. hokein added a comment. Rebase http://reviews.llvm.org/D20809 Files: include-fixer/IncludeFixer.cpp include-fixer/IncludeFixerContext.h include-fixer/tool/ClangIncludeFixer.cpp include-fixer/tool/clang-include-fixer.py Index: include-fixer/tool/clang-include-fixer.py === --- include-fixer/tool/clang-include-fixer.py +++ include-fixer/tool/clang-include-fixer.py @@ -78,8 +78,13 @@ "-input="+args.input, vim.current.buffer.name] stdout, stderr = execute(command, text) lines = stdout.splitlines() - if len(lines) < 2: -print "No header is included.\n" + + if len(lines) == 0: +print "The file is fine, no need to add a header.\n" +return; + + if len(lines) == 1: +print "Couldn't find a header for {0}.\n".format(lines[0]) return # The first line is the symbol name. Index: include-fixer/tool/ClangIncludeFixer.cpp === --- include-fixer/tool/ClangIncludeFixer.cpp +++ include-fixer/tool/ClangIncludeFixer.cpp @@ -190,8 +190,10 @@ } if (OutputHeaders) { +if (Context.SymbolIdentifier.empty()) + return 0; // FIXME: Output IncludeFixerContext as YAML. -llvm::outs() << Context.SymbolIdentifer << "\n"; +llvm::outs() << Context.SymbolIdentifier << "\n"; for (const auto &Header : Context.Headers) llvm::outs() << Header << "\n"; return 0; Index: include-fixer/IncludeFixerContext.h === --- include-fixer/IncludeFixerContext.h +++ include-fixer/IncludeFixerContext.h @@ -19,7 +19,7 @@ /// \brief A context for the symbol being queried. struct IncludeFixerContext { /// \brief The symbol name. - std::string SymbolIdentifer; + std::string SymbolIdentifier; /// \brief The headers which have SymbolIdentifier definitions. std::vector Headers; /// \brief The insertion point for new include header. Index: include-fixer/IncludeFixer.cpp === --- include-fixer/IncludeFixer.cpp +++ include-fixer/IncludeFixer.cpp @@ -241,10 +241,7 @@ getIncludeFixerContext(const clang::SourceManager &SourceManager, clang::HeaderSearch &HeaderSearch) { IncludeFixerContext FixerContext; -if (SymbolQueryResults.empty()) - return FixerContext; - -FixerContext.SymbolIdentifer = QuerySymbol; +FixerContext.SymbolIdentifier = QuerySymbol; FixerContext.FirstIncludeOffset = FirstIncludeOffset; for (const auto &Header : SymbolQueryResults) FixerContext.Headers.push_back( Index: include-fixer/tool/clang-include-fixer.py === --- include-fixer/tool/clang-include-fixer.py +++ include-fixer/tool/clang-include-fixer.py @@ -78,8 +78,13 @@ "-input="+args.input, vim.current.buffer.name] stdout, stderr = execute(command, text) lines = stdout.splitlines() - if len(lines) < 2: -print "No header is included.\n" + + if len(lines) == 0: +print "The file is fine, no need to add a header.\n" +return; + + if len(lines) == 1: +print "Couldn't find a header for {0}.\n".format(lines[0]) return # The first line is the symbol name. Index: include-fixer/tool/ClangIncludeFixer.cpp === --- include-fixer/tool/ClangIncludeFixer.cpp +++ include-fixer/tool/ClangIncludeFixer.cpp @@ -190,8 +190,10 @@ } if (OutputHeaders) { +if (Context.SymbolIdentifier.empty()) + return 0; // FIXME: Output IncludeFixerContext as YAML. -llvm::outs() << Context.SymbolIdentifer << "\n"; +llvm::outs() << Context.SymbolIdentifier << "\n"; for (const auto &Header : Context.Headers) llvm::outs() << Header << "\n"; return 0; Index: include-fixer/IncludeFixerContext.h === --- include-fixer/IncludeFixerContext.h +++ include-fixer/IncludeFixerContext.h @@ -19,7 +19,7 @@ /// \brief A context for the symbol being queried. struct IncludeFixerContext { /// \brief The symbol name. - std::string SymbolIdentifer; + std::string SymbolIdentifier; /// \brief The headers which have SymbolIdentifier definitions. std::vector Headers; /// \brief The insertion point for new include header. Index: include-fixer/IncludeFixer.cpp === --- include-fixer/IncludeFixer.cpp +++ include-fixer/IncludeFixer.cpp @@ -241,10 +241,7 @@ getIncludeFixerContext(const clang::SourceManager &SourceManager, clang::HeaderSearch &HeaderSearch) { IncludeFixerContext FixerContext; -if (SymbolQueryResults.empty()) - return FixerContext; - -FixerContext.SymbolIdentifer = QuerySymbol
Re: [PATCH] D20808: [include-fixer] Code cleanup.
bkramer accepted this revision. bkramer added a comment. This revision is now accepted and ready to land. lg http://reviews.llvm.org/D20808 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().
ioeric added inline comments. Comment at: unittests/Format/CleanupTest.cpp:310 @@ +309,3 @@ + Context.createInMemoryFile("fix.cpp", Code); + tooling::Replacements Replaces = { + tooling::Replacement("fix.cpp", UINT_MAX, 0, "#include \"b.h\"")}; djasper wrote: > Well, the only reason you seem to be using the FileID or "Context" for that > matter is to translate between line/col and offset. I'd just pull that > functionality out into a separate function (which does it based on the "Code" > input) or not at all (hard-coding the offset doesn't seem *that* bad). Ohh, I see! Thanks! Comment at: unittests/Format/CleanupTest.cpp:510 @@ +509,3 @@ +TEST_F(CleanUpReplacementsTest, InsertMultipleNewHeadersAndSortGoogle) { + std::string Code = "\nint x;"; + std::string Expected = "#include \"fix.h\"\n" djasper wrote: > Have you seen this comment? Sorry that I missed this one... http://reviews.llvm.org/D20734 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().
ioeric updated this revision to Diff 59043. ioeric marked 3 inline comments as done. ioeric added a comment. - Addressed reviewer's comments. http://reviews.llvm.org/D20734 Files: include/clang/Format/Format.h lib/Format/Format.cpp unittests/Format/CleanupTest.cpp Index: unittests/Format/CleanupTest.cpp === --- unittests/Format/CleanupTest.cpp +++ unittests/Format/CleanupTest.cpp @@ -243,13 +243,39 @@ class CleanUpReplacementsTest : public ::testing::Test { protected: - tooling::Replacement createReplacement(SourceLocation Start, unsigned Length, - llvm::StringRef ReplacementText) { -return tooling::Replacement(Context.Sources, Start, Length, -ReplacementText); + tooling::Replacement createReplacement(unsigned Offset, unsigned Length, + StringRef Text) { +return tooling::Replacement(FileName, Offset, Length, Text); } - RewriterTestContext Context; + tooling::Replacement createInsertion(StringRef HeaderName) { +return createReplacement(UINT_MAX, 0, HeaderName); + } + + inline std::string apply(StringRef Code, const tooling::Replacements Replaces, + const FormatStyle &Style = getLLVMStyle()) { +return applyAllReplacements( +Code, cleanupAroundReplacements(Code, Replaces, Style)); + } + + inline std::string formatAndApply(StringRef Code, +const tooling::Replacements Replaces, +const FormatStyle &Style = getLLVMStyle()) { +return applyAllReplacements( +Code, +formatReplacements( +Code, cleanupAroundReplacements(Code, Replaces, Style), Style)); + } + + int getOffset(StringRef Code, int Line, int Column) { +RewriterTestContext Context; +FileID ID = Context.createInMemoryFile(FileName, Code); +auto DecomposedLocation = +Context.Sources.getDecomposedLoc(Context.getLocation(ID, Line, Column)); +return DecomposedLocation.second; + } + + const std::string FileName = "fix.cpp"; }; TEST_F(CleanUpReplacementsTest, FixOnlyAffectedCodeAfterReplacements) { @@ -268,17 +294,252 @@ "namespace D { int i; }\n\n" "int x= 0;" "}"; - FileID ID = Context.createInMemoryFile("fix.cpp", Code); - tooling::Replacements Replaces; - Replaces.insert(tooling::Replacement(Context.Sources, - Context.getLocation(ID, 3, 3), 6, "")); - Replaces.insert(tooling::Replacement(Context.Sources, - Context.getLocation(ID, 9, 34), 6, "")); - - format::FormatStyle Style = format::getLLVMStyle(); - auto FinalReplaces = formatReplacements( - Code, cleanupAroundReplacements(Code, Replaces, Style), Style); - EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces)); + tooling::Replacements Replaces = { + createReplacement(getOffset(Code, 3, 3), 6, ""), + createReplacement(getOffset(Code, 9, 34), 6, "")}; + + EXPECT_EQ(Expected, formatAndApply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, NoExistingIncludeWithoutDefine) { + std::string Code = "int main() {}"; + std::string Expected = "#include \"a.h\"\n" + "int main() {}"; + tooling::Replacements Replaces = {createInsertion("#include \"a.h\"")}; + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, NoExistingIncludeWithDefine) { + std::string Code = "#ifndef __A_H__\n" + "#define __A_H__\n" + "class A {};\n" + "#define MMM 123\n" + "#endif"; + std::string Expected = "#ifndef __A_H__\n" + "#define __A_H__\n" + "#include \"b.h\"\n" + "class A {};\n" + "#define MMM 123\n" + "#endif"; + + tooling::Replacements Replaces = {createInsertion("#include \"b.h\"")}; + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, InsertBeforeCategoryWithLowerPriority) { + std::string Code = "#ifndef __A_H__\n" + "#define __A_H__\n" + "\n" + "\n" + "\n" + "#include \n" + "class A {};\n" + "#define MMM 123\n" + "#endif"; + std::string Expected = "#ifndef __A_H__\n" + "#define __A_H__\n" + "\n" + "\n" + "\n" + "#include \"a.h\"\n" + "#include \n" + "class A {};\n" + "#define MMM 123\n" + "#endif"; + +
Re: [PATCH] D20804: [include-fixer] collect the number of times a symbols is found in an indexing run and use it for symbols popularity ranking.
This revision was automatically updated to reflect the committed changes. Closed by commit rL271268: [include-fixer] collect the number of times a symbols is found in an indexing… (authored by ioeric). Changed prior to commit: http://reviews.llvm.org/D20804?vs=59027&id=59045#toc Repository: rL LLVM http://reviews.llvm.org/D20804 Files: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml Index: clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml === --- clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml +++ clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml @@ -8,6 +8,7 @@ FilePath:foo.h LineNumber: 1 Type:Class +NumOccurrences: 1 ... --- Name: bar @@ -19,4 +20,5 @@ FilePath:../include/bar.h LineNumber: 1 Type:Class +NumOccurrences: 1 ... Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp === --- clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp +++ clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp @@ -87,12 +87,13 @@ bool Merge(llvm::StringRef MergeDir, llvm::StringRef OutputFile) { std::error_code EC; - std::set UniqueSymbols; + std::map SymbolToNumOccurrences; std::mutex SymbolMutex; auto AddSymbols = [&](ArrayRef Symbols) { // Synchronize set accesses. std::unique_lock LockGuard(SymbolMutex); -UniqueSymbols.insert(Symbols.begin(), Symbols.end()); +for (const auto &Symbol : Symbols) + ++SymbolToNumOccurrences[Symbol]; }; // Load all symbol files in MergeDir. @@ -123,7 +124,14 @@ << '\n'; return false; } - WriteSymbolInfosToStream(OS, UniqueSymbols); + std::set Result; + for (const auto &Entry : SymbolToNumOccurrences) { +const auto &Symbol = Entry.first; +Result.insert(SymbolInfo(Symbol.getName(), Symbol.getSymbolKind(), + Symbol.getFilePath(), Symbol.getLineNumber(), + Symbol.getContexts(), Entry.second)); + } + WriteSymbolInfosToStream(OS, Result); return true; } Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h === --- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h +++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h @@ -51,7 +51,8 @@ SymbolInfo() : Type(SymbolKind::Unknown), LineNumber(-1) {} SymbolInfo(llvm::StringRef Name, SymbolKind Type, llvm::StringRef FilePath, - int LineNumber, const std::vector &Contexts); + int LineNumber, const std::vector &Contexts, + unsigned NumOccurrences = 0); /// \brief Get symbol name. llvm::StringRef getName() const; @@ -68,6 +69,9 @@ /// \brief Get a 1-based line number of the symbol's declaration. int getLineNumber() const; + /// \brief The number of times this symbol was found during an indexing run. + unsigned getNumOccurrences() const; + bool operator<(const SymbolInfo &Symbol) const; bool operator==(const SymbolInfo &Symbol) const; @@ -99,6 +103,10 @@ /// \brief The 1-based line number of of the symbol's declaration. int LineNumber; + + /// \brief The number of times this symbol was found during an indexing + /// run. Populated by the reducer and used to rank results. + unsigned NumOccurrences; }; /// \brief Write SymbolInfos to a stream (YAML format). Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp === --- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp +++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp @@ -33,6 +33,7 @@ io.mapRequired("FilePath", Symbol.FilePath); io.mapRequired("LineNumber", Symbol.LineNumber); io.mapRequired("Type", Symbol.Type); +io.mapRequired("NumOccurrences", Symbol.NumOccurrences); } }; @@ -72,9 +73,10 @@ SymbolInfo::SymbolInfo(llvm::StringRef Name, SymbolKind Type, llvm::StringRef FilePath, int LineNumber, - const std::vector &Contexts) + const std::vector &Contexts, + unsigned NumOccurrences) : Name(Name), Type(Type), FilePath(FilePath), Contexts(Contexts), - LineNumber(LineNumber) {} + LineNumber(LineNumber), NumOccurrences(NumOccurrences) {} llvm::StringRef SymbolInfo::getName() const { return Name; } @@ -88
[clang-tools-extra] r271268 - [include-fixer] collect the number of times a symbols is found in an indexing run and use it for symbols popularity ranking.
Author: ioeric Date: Tue May 31 07:01:48 2016 New Revision: 271268 URL: http://llvm.org/viewvc/llvm-project?rev=271268&view=rev Log: [include-fixer] collect the number of times a symbols is found in an indexing run and use it for symbols popularity ranking. Summary: [include-fixer] collect the number of times a symbols is found in an indexing run and use it for symbols popularity ranking. Reviewers: bkramer Subscribers: cfe-commits, hokein, djasper Differential Revision: http://reviews.llvm.org/D20804 Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp?rev=271268&r1=271267&r2=271268&view=diff == --- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp (original) +++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp Tue May 31 07:01:48 2016 @@ -33,6 +33,7 @@ template <> struct MappingTraits &Contexts) + const std::vector &Contexts, + unsigned NumOccurrences) : Name(Name), Type(Type), FilePath(FilePath), Contexts(Contexts), - LineNumber(LineNumber) {} + LineNumber(LineNumber), NumOccurrences(NumOccurrences) {} llvm::StringRef SymbolInfo::getName() const { return Name; } @@ -88,6 +90,8 @@ const std::vector & int SymbolInfo::getLineNumber() const { return LineNumber; } +unsigned SymbolInfo::getNumOccurrences() const { return NumOccurrences; } + bool SymbolInfo::operator==(const SymbolInfo &Symbol) const { return std::tie(Name, Type, FilePath, LineNumber, Contexts) == std::tie(Symbol.Name, Symbol.Type, Symbol.FilePath, Symbol.LineNumber, Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h?rev=271268&r1=271267&r2=271268&view=diff == --- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h (original) +++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h Tue May 31 07:01:48 2016 @@ -51,7 +51,8 @@ public: SymbolInfo() : Type(SymbolKind::Unknown), LineNumber(-1) {} SymbolInfo(llvm::StringRef Name, SymbolKind Type, llvm::StringRef FilePath, - int LineNumber, const std::vector &Contexts); + int LineNumber, const std::vector &Contexts, + unsigned NumOccurrences = 0); /// \brief Get symbol name. llvm::StringRef getName() const; @@ -68,6 +69,9 @@ public: /// \brief Get a 1-based line number of the symbol's declaration. int getLineNumber() const; + /// \brief The number of times this symbol was found during an indexing run. + unsigned getNumOccurrences() const; + bool operator<(const SymbolInfo &Symbol) const; bool operator==(const SymbolInfo &Symbol) const; @@ -99,6 +103,10 @@ private: /// \brief The 1-based line number of of the symbol's declaration. int LineNumber; + + /// \brief The number of times this symbol was found during an indexing + /// run. Populated by the reducer and used to rank results. + unsigned NumOccurrences; }; /// \brief Write SymbolInfos to a stream (YAML format). Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp?rev=271268&r1=271267&r2=271268&view=diff == --- clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp (original) +++ clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp Tue May 31 07:01:48 2016 @@ -87,12 +87,13 @@ private: bool Merge(llvm::StringRef MergeDir, llvm::StringRef OutputFile) { std::error_code EC; - std::set UniqueSymbols; + std::map SymbolToNumOccurrences; std::mutex SymbolMutex; auto AddSymbols = [&](ArrayRef Symbols) { // Synchronize set accesses. std::unique_lock LockGuard(SymbolMutex); -UniqueSymbols.insert(Symbols.begin(), Symbols.end()); +for (const auto &Symbol : Symbols) + ++SymbolToNumOccurrences[Symbol]; }; // Load all symbol files in MergeDir. @@ -123,7 +124,14 @@ bool Merge(llvm::StringRef MergeDir, llv << '\n'; return false; } - WriteSymbolInfosToStream(OS, UniqueSymbols); + std::set Result; + for (const auto &En
[libcxxabi] r271267 - [libcxxabi] Introduce a -fno-exceptions libc++abi libary variant
Author: asiri Date: Tue May 31 07:01:32 2016 New Revision: 271267 URL: http://llvm.org/viewvc/llvm-project?rev=271267&view=rev Log: [libcxxabi] Introduce a -fno-exceptions libc++abi libary variant Currently there is only support for a -fno-exceptions libc++ build. This is problematic for functions such as std::terminate() which are defined in libc++abi and using any of those functions throws away most of the benefits of using -fno-exceptions (code-size). This patch introduces a -fno-exceptions libc++abi build to address this issue. This new variant of libc++abi cannot be linked against any with-exceptions code as some symbols necessary for handling exceptions are missing in this library. Differential revision: http://reviews.llvm.org/D20677 Reviewers: EricWF, mclow.lists, bcraig Added: libcxxabi/trunk/src/cxa_noexception.cpp libcxxabi/trunk/test/cxa_bad_cast.pass.cpp libcxxabi/trunk/test/cxa_bad_typeid.pass.cpp libcxxabi/trunk/test/noexception1.pass.cpp libcxxabi/trunk/test/noexception2.pass.cpp libcxxabi/trunk/test/noexception3.pass.cpp libcxxabi/trunk/test/noexception4.pass.cpp - copied, changed from r270816, libcxxabi/trunk/test/uncaught_exceptions.pass.cpp Modified: libcxxabi/trunk/CMakeLists.txt libcxxabi/trunk/src/CMakeLists.txt libcxxabi/trunk/src/cxa_aux_runtime.cpp libcxxabi/trunk/src/cxa_handlers.cpp libcxxabi/trunk/src/cxa_new_delete.cpp libcxxabi/trunk/test/CMakeLists.txt libcxxabi/trunk/test/backtrace_test.pass.cpp libcxxabi/trunk/test/catch_array_01.pass.cpp libcxxabi/trunk/test/catch_array_02.pass.cpp libcxxabi/trunk/test/catch_class_01.pass.cpp libcxxabi/trunk/test/catch_class_02.pass.cpp libcxxabi/trunk/test/catch_class_03.pass.cpp libcxxabi/trunk/test/catch_class_04.pass.cpp libcxxabi/trunk/test/catch_const_pointer_nullptr.pass.cpp libcxxabi/trunk/test/catch_function_01.pass.cpp libcxxabi/trunk/test/catch_function_02.pass.cpp libcxxabi/trunk/test/catch_in_noexcept.pass.cpp libcxxabi/trunk/test/catch_member_data_pointer_01.pass.cpp libcxxabi/trunk/test/catch_member_function_pointer_01.pass.cpp libcxxabi/trunk/test/catch_member_pointer_nullptr.pass.cpp libcxxabi/trunk/test/catch_multi_level_pointer.pass.cpp libcxxabi/trunk/test/catch_pointer_nullptr.pass.cpp libcxxabi/trunk/test/catch_pointer_reference.pass.cpp libcxxabi/trunk/test/catch_ptr.pass.cpp libcxxabi/trunk/test/catch_ptr_02.pass.cpp libcxxabi/trunk/test/incomplete_type.sh.cpp libcxxabi/trunk/test/inherited_exception.pass.cpp libcxxabi/trunk/test/libcxxabi/test/config.py libcxxabi/trunk/test/lit.site.cfg.in libcxxabi/trunk/test/test_aux_runtime.pass.cpp libcxxabi/trunk/test/test_aux_runtime_op_array_new.pass.cpp libcxxabi/trunk/test/test_guard.pass.cpp libcxxabi/trunk/test/test_vector1.pass.cpp libcxxabi/trunk/test/test_vector2.pass.cpp libcxxabi/trunk/test/test_vector3.pass.cpp libcxxabi/trunk/test/uncaught_exceptions.pass.cpp libcxxabi/trunk/test/unwind_01.pass.cpp libcxxabi/trunk/test/unwind_02.pass.cpp libcxxabi/trunk/test/unwind_03.pass.cpp libcxxabi/trunk/test/unwind_04.pass.cpp libcxxabi/trunk/test/unwind_05.pass.cpp libcxxabi/trunk/test/unwind_06.pass.cpp Modified: libcxxabi/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=271267&r1=271266&r2=271267&view=diff == --- libcxxabi/trunk/CMakeLists.txt (original) +++ libcxxabi/trunk/CMakeLists.txt Tue May 31 07:01:32 2016 @@ -108,6 +108,7 @@ endif() #=== # Define options. +option(LIBCXXABI_ENABLE_EXCEPTIONS "Use exceptions." ON) option(LIBCXXABI_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON) option(LIBCXXABI_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) option(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) @@ -242,13 +243,20 @@ if (LIBCXXABI_ENABLE_PEDANTIC) endif() # Get feature flags. -# Exceptions -# Catches C++ exceptions only and tells the compiler to assume that extern C -# functions never throw a C++ exception. append_if(LIBCXXABI_CXX_FLAGS LIBCXXABI_HAS_FSTRICT_ALIASING_FLAG -fstrict-aliasing) -append_if(LIBCXXABI_CXX_FLAGS LIBCXXABI_HAS_EHSC_FLAG -EHsc) -append_if(LIBCXXABI_C_FLAGS LIBCXXABI_HAS_FUNWIND_TABLES -funwind-tables) +# Exceptions +if (LIBCXXABI_ENABLE_EXCEPTIONS) + # Catches C++ exceptions only and tells the compiler to assume that extern C + # functions never throw a C++ exception. + append_if(LIBCXXABI_CXX_FLAGS LIBCXXABI_HAS_EHSC_FLAG -EHsc) + append_if(LIBCXXABI_C_FLAGS LIBCXXABI_HAS_FUNWIND_TABLES -funwind-tables) +else() + add_definitions(-D_LIBCXXABI_NO_EXCEPTIONS) + append_if(LIBCXXABI_CXX_FLAGS LIBCXXABI_HAS_NO_EXCEPTIONS_FLAG -fno-exceptions) + append_if(LIBCXXABI_CXX_F
Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.
This revision was automatically updated to reflect the committed changes. Closed by commit rL271267: [libcxxabi] Introduce a -fno-exceptions libc++abi libary variant (authored by asiri). Changed prior to commit: http://reviews.llvm.org/D20677?vs=59009&id=59044#toc Repository: rL LLVM http://reviews.llvm.org/D20677 Files: libcxxabi/trunk/CMakeLists.txt libcxxabi/trunk/src/CMakeLists.txt libcxxabi/trunk/src/cxa_aux_runtime.cpp libcxxabi/trunk/src/cxa_handlers.cpp libcxxabi/trunk/src/cxa_new_delete.cpp libcxxabi/trunk/src/cxa_noexception.cpp libcxxabi/trunk/test/CMakeLists.txt libcxxabi/trunk/test/backtrace_test.pass.cpp libcxxabi/trunk/test/catch_array_01.pass.cpp libcxxabi/trunk/test/catch_array_02.pass.cpp libcxxabi/trunk/test/catch_class_01.pass.cpp libcxxabi/trunk/test/catch_class_02.pass.cpp libcxxabi/trunk/test/catch_class_03.pass.cpp libcxxabi/trunk/test/catch_class_04.pass.cpp libcxxabi/trunk/test/catch_const_pointer_nullptr.pass.cpp libcxxabi/trunk/test/catch_function_01.pass.cpp libcxxabi/trunk/test/catch_function_02.pass.cpp libcxxabi/trunk/test/catch_in_noexcept.pass.cpp libcxxabi/trunk/test/catch_member_data_pointer_01.pass.cpp libcxxabi/trunk/test/catch_member_function_pointer_01.pass.cpp libcxxabi/trunk/test/catch_member_pointer_nullptr.pass.cpp libcxxabi/trunk/test/catch_multi_level_pointer.pass.cpp libcxxabi/trunk/test/catch_pointer_nullptr.pass.cpp libcxxabi/trunk/test/catch_pointer_reference.pass.cpp libcxxabi/trunk/test/catch_ptr.pass.cpp libcxxabi/trunk/test/catch_ptr_02.pass.cpp libcxxabi/trunk/test/cxa_bad_cast.pass.cpp libcxxabi/trunk/test/cxa_bad_typeid.pass.cpp libcxxabi/trunk/test/incomplete_type.sh.cpp libcxxabi/trunk/test/inherited_exception.pass.cpp libcxxabi/trunk/test/libcxxabi/test/config.py libcxxabi/trunk/test/lit.site.cfg.in libcxxabi/trunk/test/noexception1.pass.cpp libcxxabi/trunk/test/noexception2.pass.cpp libcxxabi/trunk/test/noexception3.pass.cpp libcxxabi/trunk/test/noexception4.pass.cpp libcxxabi/trunk/test/test_aux_runtime.pass.cpp libcxxabi/trunk/test/test_aux_runtime_op_array_new.pass.cpp libcxxabi/trunk/test/test_guard.pass.cpp libcxxabi/trunk/test/test_vector1.pass.cpp libcxxabi/trunk/test/test_vector2.pass.cpp libcxxabi/trunk/test/test_vector3.pass.cpp libcxxabi/trunk/test/uncaught_exceptions.pass.cpp libcxxabi/trunk/test/unwind_01.pass.cpp libcxxabi/trunk/test/unwind_02.pass.cpp libcxxabi/trunk/test/unwind_03.pass.cpp libcxxabi/trunk/test/unwind_04.pass.cpp libcxxabi/trunk/test/unwind_05.pass.cpp libcxxabi/trunk/test/unwind_06.pass.cpp Index: libcxxabi/trunk/test/catch_function_01.pass.cpp === --- libcxxabi/trunk/test/catch_function_01.pass.cpp +++ libcxxabi/trunk/test/catch_function_01.pass.cpp @@ -12,6 +12,7 @@ // GCC incorrectly allows function pointer to be caught by reference. // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69372 // XFAIL: gcc +// UNSUPPORTED: libcxxabi-no-exceptions #include Index: libcxxabi/trunk/test/test_vector3.pass.cpp === --- libcxxabi/trunk/test/test_vector3.pass.cpp +++ libcxxabi/trunk/test/test_vector3.pass.cpp @@ -7,6 +7,8 @@ // //===--===// +// UNSUPPORTED: libcxxabi-no-exceptions + #include "cxxabi.h" #include Index: libcxxabi/trunk/test/test_vector1.pass.cpp === --- libcxxabi/trunk/test/test_vector1.pass.cpp +++ libcxxabi/trunk/test/test_vector1.pass.cpp @@ -47,8 +47,19 @@ int gConstructorThrowTarget; int gDestructorCounter; int gDestructorThrowTarget; -void throw_construct ( void *p ) { if ( gConstructorCounter == gConstructorThrowTarget ) throw 1; ++gConstructorCounter; } -void throw_destruct ( void *p ) { if ( ++gDestructorCounter == gDestructorThrowTarget ) throw 2; } +void throw_construct ( void *p ) { +#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS +if ( gConstructorCounter == gConstructorThrowTarget ) +throw 1; +++gConstructorCounter; +#endif +} +void throw_destruct ( void *p ) { +#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS +if ( ++gDestructorCounter == gDestructorThrowTarget ) +throw 2; +#endif +} #if __cplusplus >= 201103L # define CAN_THROW noexcept(false) @@ -146,6 +157,7 @@ return retVal; } +#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS // Make sure the constructors and destructors are matched int test_exception_in_constructor ( ) { int retVal = 0; @@ -202,7 +214,9 @@ return retVal; } +#endif +#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS // Make sure the constructors and destructors are matched int test_exception_in_destructor ( ) { int retVal = 0; @@ -253,12 +267,15 @@ return retVal; } +#endif int main ( int argc, char *argv [] ) { int retVal = 0; re
Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support
rengolin added a comment. In http://reviews.llvm.org/D18035#440107, @rsmith wrote: > Please try to appropriately apportion the responsibility here; if your > distribution opted into a non-standard ABI for their C++ standard library, > you should point out to them that they made a mistake. I think I have been clear enough on the bug and the list about responsibility... It is clear that the distros screwed that up on their own, and neither GCC not LLVM could do much to work around the complete lack of proper testing before such a big decision. In no way I think this is something we could have done anything to prevent from happening, nor I think that this patch is the best way forward for the future. I only asked this to be reviewed and accepted IFF it's the right (temporary) implementation, so that distros can pull those patches with a bit more confidence. If it makes to 3.8.1, that'd make things a lot easier for *them* (not us). If it doesn't, it wouldn't make it much harder (they can already pull odd patches). But since this has been tested by many people, including active usage in distros, and it doesn't touch anything outside the ABI tag issue, we could have it in (at least on trunk), so that we can test it better ourselves until 3.9 branches. I really don't want to pull this one in just before we branch. Nor just after. Regardless of who screwed up, having a fix would be good to LLVM as well, not just the distros. cheers, --renato http://reviews.llvm.org/D18035 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().
djasper accepted this revision. djasper added a comment. This revision is now accepted and ready to land. A few nitpicks, but otherwise looks good. Comment at: lib/Format/Format.cpp:1287 @@ +1286,3 @@ +int Ret = INT_MAX; +for (unsigned I = 0, E = CategoryRegexs.size(); I != E; ++I) + if (CategoryRegexs[I].match(IncludeName)) { I'd consistently try to use i and e for integers vs. I and E for iterators. Comment at: unittests/Format/CleanupTest.cpp:256 @@ +255,3 @@ + inline std::string apply(StringRef Code, const tooling::Replacements Replaces, + const FormatStyle &Style = getLLVMStyle()) { +return applyAllReplacements( I'd probably make "Style" a class member, defaulting to LLVM Style that you can then overwrite for other styles. Comment at: unittests/Format/CleanupTest.cpp:270 @@ +269,3 @@ + + int getOffset(StringRef Code, int Line, int Column) { +RewriterTestContext Context; I'd consider making "Code" a member variable. But it has pros and cons. Comment at: unittests/Format/CleanupTest.cpp:313 @@ +312,3 @@ +TEST_F(CleanUpReplacementsTest, NoExistingIncludeWithDefine) { + std::string Code = "#ifndef __A_H__\n" + "#define __A_H__\n" Why are you starting and ending the header guards with a double underscore? I think this is actually reserved for built-in identifiers. Maybe just stick with the LLVM naming scheme? http://reviews.llvm.org/D20734 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r271270 - [find-all-symbols] Add a test to make sure merging actually works.
Author: d0k Date: Tue May 31 07:12:19 2016 New Revision: 271270 URL: http://llvm.org/viewvc/llvm-project?rev=271270&view=rev Log: [find-all-symbols] Add a test to make sure merging actually works. Added: clang-tools-extra/trunk/test/include-fixer/Inputs/merge/ clang-tools-extra/trunk/test/include-fixer/Inputs/merge/a.yaml clang-tools-extra/trunk/test/include-fixer/Inputs/merge/b.yaml clang-tools-extra/trunk/test/include-fixer/merge.test Modified: clang-tools-extra/trunk/test/CMakeLists.txt clang-tools-extra/trunk/test/lit.cfg Modified: clang-tools-extra/trunk/test/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/CMakeLists.txt?rev=271270&r1=271269&r2=271270&view=diff == --- clang-tools-extra/trunk/test/CMakeLists.txt (original) +++ clang-tools-extra/trunk/test/CMakeLists.txt Tue May 31 07:12:19 2016 @@ -46,6 +46,7 @@ set(CLANG_TOOLS_TEST_DEPS clang-query clang-rename clang-tidy + find-all-symbols modularize pp-trace Added: clang-tools-extra/trunk/test/include-fixer/Inputs/merge/a.yaml URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/include-fixer/Inputs/merge/a.yaml?rev=271270&view=auto == --- clang-tools-extra/trunk/test/include-fixer/Inputs/merge/a.yaml (added) +++ clang-tools-extra/trunk/test/include-fixer/Inputs/merge/a.yaml Tue May 31 07:12:19 2016 @@ -0,0 +1,20 @@ +--- +Name: foo +Contexts: + - ContextType: Namespace +ContextName: a +FilePath:foo.h +LineNumber: 1 +Type:Class +NumOccurrences: 1 +... +--- +Name: bar +Contexts: + - ContextType: Namespace +ContextName: a +FilePath:../include/bar.h +LineNumber: 1 +Type:Class +NumOccurrences: 1 +... Added: clang-tools-extra/trunk/test/include-fixer/Inputs/merge/b.yaml URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/include-fixer/Inputs/merge/b.yaml?rev=271270&view=auto == --- clang-tools-extra/trunk/test/include-fixer/Inputs/merge/b.yaml (added) +++ clang-tools-extra/trunk/test/include-fixer/Inputs/merge/b.yaml Tue May 31 07:12:19 2016 @@ -0,0 +1,20 @@ +--- +Name: foo +Contexts: + - ContextType: Namespace +ContextName: a +FilePath:foo.h +LineNumber: 1 +Type:Class +NumOccurrences: 1 +... +--- +Name: bar +Contexts: + - ContextType: Namespace +ContextName: a +FilePath:../include/barbar.h +LineNumber: 1 +Type:Class +NumOccurrences: 1 +... Added: clang-tools-extra/trunk/test/include-fixer/merge.test URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/include-fixer/merge.test?rev=271270&view=auto == --- clang-tools-extra/trunk/test/include-fixer/merge.test (added) +++ clang-tools-extra/trunk/test/include-fixer/merge.test Tue May 31 07:12:19 2016 @@ -0,0 +1,34 @@ +# REQUIRES: shell +# RUN: find-all-symbols -merge-dir=%S/Inputs/merge %t.merged +# RUN: sed '/^#/d' %s > %t.golden +# RUN: diff -u %t.golden %t.merged +--- +Name:bar +Contexts: + - ContextType: Namespace +ContextName: a +FilePath:../include/bar.h +LineNumber: 1 +Type:Class +NumOccurrences: 1 +... +--- +Name:bar +Contexts: + - ContextType: Namespace +ContextName: a +FilePath:../include/barbar.h +LineNumber: 1 +Type:Class +NumOccurrences: 1 +... +--- +Name:foo +Contexts: + - ContextType: Namespace +ContextName: a +FilePath:foo.h +LineNumber: 1 +Type:Class +NumOccurrences: 2 +... Modified: clang-tools-extra/trunk/test/lit.cfg URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/lit.cfg?rev=271270&r1=271269&r2=271270&view=diff == --- clang-tools-extra/trunk/test/lit.cfg (original) +++ clang-tools-extra/trunk/test/lit.cfg Tue May 31 07:12:19 2016 @@ -44,7 +44,7 @@ config.test_format = lit.formats.ShTest( # suffixes: A list of file extensions to treat as test files. config.suffixes = ['.c', '.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', - '.modularize', '.module-map-checker'] + '.modularize', '.module-map-checker', '.test'] # Test-time dependencies located in directories called 'Inputs' are excluded # from test suites; there won't be any lit tests within them. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20773: [Sema] Fix incorrect enum token namespace
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM! http://reviews.llvm.org/D20773 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D20810: [Clang][Intrinsics][avx512] Continue Adding round cvt to clang
m_zuckerman created this revision. m_zuckerman added reviewers: AsafBadouh, igorb, delena. m_zuckerman added a subscriber: cfe-commits. http://reviews.llvm.org/D20810 Files: lib/Headers/avx512fintrin.h test/CodeGen/avx512f-builtins.c Index: test/CodeGen/avx512f-builtins.c === --- test/CodeGen/avx512f-builtins.c +++ test/CodeGen/avx512f-builtins.c @@ -3107,6 +3107,71 @@ return _mm_cvttss_u64(__A); } +__m512i test_mm512_cvtt_roundps_epu32(__m512 __A) +{ +// CHECK-LABEL: @test_mm512_cvtt_roundps_epu32 +// CHECK: @llvm.x86.avx512.mask.cvttps2udq.512 +return _mm512_cvtt_roundps_epu32(__A, _MM_FROUND_CUR_DIRECTION); +} + +__m512i test_mm512_mask_cvtt_roundps_epu32(__m512i __W, __mmask16 __U, __m512 __A) +{ +// CHECK-LABEL: @test_mm512_mask_cvtt_roundps_epu32 +// CHECK: @llvm.x86.avx512.mask.cvttps2udq.512 + +return _mm512_mask_cvtt_roundps_epu32(__W, __U, __A, _MM_FROUND_CUR_DIRECTION); +} + +__m512i test_mm512_maskz_cvtt_roundps_epu32( __mmask16 __U, __m512 __A) +{ +// CHECK-LABEL: @test_mm512_maskz_cvtt_roundps_epu32 +// CHECK: @llvm.x86.avx512.mask.cvttps2udq.512 + +return _mm512_maskz_cvtt_roundps_epu32(__U, __A, _MM_FROUND_CUR_DIRECTION); +} + +__m256i test_mm512_cvt_roundps_ph(__m512 __A) +{ +// CHECK-LABEL: @test_mm512_cvt_roundps_ph +// CHECK: @llvm.x86.avx512.mask.vcvtps2ph.512 +return _mm512_cvt_roundps_ph(__A, _MM_FROUND_CUR_DIRECTION); +} + +__m256i test_mm512_mask_cvt_roundps_ph(__m256i __W , __mmask16 __U, __m512 __A) +{ +// CHECK-LABEL: @test_mm512_mask_cvt_roundps_ph +// CHECK: @llvm.x86.avx512.mask.vcvtps2ph.512 +return _mm512_mask_cvt_roundps_ph(__W, __U, __A, _MM_FROUND_CUR_DIRECTION); +} + +__m256i test_mm512_maskz_cvt_roundps_ph(__mmask16 __U, __m512 __A) +{ +// CHECK-LABEL: @test_mm512_maskz_cvt_roundps_ph +// CHECK: @llvm.x86.avx512.mask.vcvtps2ph.512 +return _mm512_maskz_cvt_roundps_ph(__U, __A, _MM_FROUND_CUR_DIRECTION); +} + +__m512 test_mm512_cvt_roundph_ps(__m256i __A) +{ +// CHECK-LABEL: @test_mm512_cvt_roundph_ps +// CHECK: @llvm.x86.avx512.mask.vcvtph2ps.512 +return _mm512_cvt_roundph_ps(__A, _MM_FROUND_CUR_DIRECTION); +} + +__m512 test_mm512_mask_cvt_roundph_ps(__m512 __W, __mmask16 __U, __m256i __A) +{ +// CHECK-LABEL: @test_mm512_mask_cvt_roundph_ps +// CHECK: @llvm.x86.avx512.mask.vcvtph2ps.512 +return _mm512_mask_cvt_roundph_ps(__W, __U, __A, _MM_FROUND_CUR_DIRECTION); +} + +__m512 test_mm512_maskz_cvt_roundph_ps(__mmask16 __U, __m256i __A) +{ +// CHECK-LABEL: @test_mm512_maskz_cvt_roundph_ps +// CHECK: @llvm.x86.avx512.mask.vcvtph2ps.512 +return _mm512_maskz_cvt_roundph_ps(__U, __A, _MM_FROUND_CUR_DIRECTION); +} + __m512 test_mm512_mask_cvt_roundepi32_ps(__m512 __W, __mmask16 __U, __m512i __A) { // CHECK-LABEL: @test_mm512_mask_cvt_roundepi32_ps Index: lib/Headers/avx512fintrin.h === --- lib/Headers/avx512fintrin.h +++ lib/Headers/avx512fintrin.h @@ -3419,6 +3419,27 @@ /* Conversion */ +#define _mm512_cvtt_roundps_epu32( __A, __R) __extension__ ({ \ +__builtin_ia32_cvttps2udq512_mask ((__v16sf)( __A),\ + (__v16si)\ + _mm512_undefined_epi32 (),\ + (__mmask16) -1,( __R));\ +}) + +#define _mm512_mask_cvtt_roundps_epu32( __W, __U, __A, __R) __extension__ ({ \ +__builtin_ia32_cvttps2udq512_mask ((__v16sf)( __A),\ + (__v16si)( __W),\ + (__mmask16)( __U),( __R));\ +}) + +#define _mm512_maskz_cvtt_roundps_epu32( __U, __A, __R) __extension__ ({ \ +__builtin_ia32_cvttps2udq512_mask ((__v16sf)( __A),\ + (__v16si)\ + _mm512_setzero_si512 (),\ + (__mmask16)( __U),( __R));\ +}) + + static __inline __m512i __DEFAULT_FN_ATTRS _mm512_cvttps_epu32(__m512 __A) { @@ -3629,6 +3650,29 @@ _MM_FROUND_CUR_DIRECTION); } +#define _mm512_cvt_roundps_ph( __A, __I) __extension__ ({ \ +__builtin_ia32_vcvtps2ph512_mask ((__v16sf)( __A),\ + ( __I),\ + (__v16hi)\ + _mm256_undefined_si256 (),\ + -1);\ +}) + +#define _mm512_mask_cvt_roundps_ph( __U, __W, __A, __I) __extension__ ({ \ +__builtin_ia32_vcvtps2ph512_mask ((__v16sf)( __A),\ + ( __I),\ + (__v16hi)( __U),\ + (__mmask16)( __W));\ +}) + +#define _mm512_maskz_cvt_roundps_ph( __W, __A, __I) __extension__ ({ \ +__builtin_ia32_vcvtps2ph512_mask ((__v16sf)( __A),\ + ( __I),\ + (__v16hi)\ + _mm256_setzero_si256 (),\ + (__mmask16)( __W));\ +}) + #define _mm512_cvtps_ph(A, I) __extension__ ({ \ (__m256i)__builtin_ia32_vcvtps2ph512_mask((__v16sf)(__m512)(A), (int)(I), \ (__v16hi)_mm256_setzero_si256(), \ @@ -3644,7 +3688,27 @@ (__v16hi)_mm256_setzero_si256(), \
Re: [PATCH] D20561: Warn when taking address of packed member
aaron.ballman added a comment. In http://reviews.llvm.org/D20561#442051, @rogfer01 wrote: > Only warn if the expression is of the form &a.x this way &(a.x) can be used > to silence the warning. I think this is a reasonable idea, but would still like to make sure we have a low false-positive rate by default. Comment at: lib/Sema/SemaExpr.cpp:10519 @@ +10518,3 @@ + // struct may be a problem if the pointer value is dereferenced. + Expr* rhs = OrigOp.get(); + const auto *ME = dyn_cast(rhs); The * binds to the identifier instead of the type; you should run the patch through clang-format (formatting issues are also in the test files). Comment at: lib/Sema/SemaExpr.cpp:10527 @@ +10526,3 @@ +if (RD->hasAttr() || +ME->getMemberDecl()->hasAttr()) { + Diag(OpLoc, diag::warn_taking_address_of_packed_member) Ah, I forgot that the attribute also affected the alignment of the struct itself. Amending my false-positive idea, the following should be fine, shouldn't it?: ``` struct __attribute__((packed)) S { char c; int i; char c2; }; void f(S s) { char *cp = &s.c; char *cp2 = &s.c2; } ``` I think perhaps we should not diagnose if the member's type also has a one-byte alignment (or, for instance, uses alignas(1) to achieve that). What do you think? Comment at: test/SemaCXX/address-packed.cpp:1 @@ +1,2 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +extern void f1(int *); This test should only really test the parts that are different from the C test (such as inheritance). The goal is to have the maximum test coverage with the minimum amount of testing code. http://reviews.llvm.org/D20561 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r271273 - [include-fixer] Code cleanup.
Author: hokein Date: Tue May 31 08:23:00 2016 New Revision: 271273 URL: http://llvm.org/viewvc/llvm-project?rev=271273&view=rev Log: [include-fixer] Code cleanup. Summary: * Abstract the DB setting code to a function. * Remove the unused FallbackStyle. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20808 Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=271273&r1=271272&r2=271273&view=diff == --- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original) +++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Tue May 31 08:23:00 2016 @@ -59,9 +59,8 @@ private: class Action : public clang::ASTFrontendAction, public clang::ExternalSemaSource { public: - explicit Action(SymbolIndexManager &SymbolIndexMgr, StringRef StyleName, - bool MinimizeIncludePaths) - : SymbolIndexMgr(SymbolIndexMgr), FallbackStyle(StyleName), + explicit Action(SymbolIndexManager &SymbolIndexMgr, bool MinimizeIncludePaths) + : SymbolIndexMgr(SymbolIndexMgr), MinimizeIncludePaths(MinimizeIncludePaths) {} std::unique_ptr @@ -288,10 +287,6 @@ private: /// be used as the insertion point for new include directives. unsigned FirstIncludeOffset = -1U; - /// The fallback format style for formatting after insertion if there is no - /// clang-format config file found. - std::string FallbackStyle; - /// The symbol being queried. std::string QuerySymbol; @@ -347,7 +342,7 @@ IncludeFixerActionFactory::IncludeFixerA SymbolIndexManager &SymbolIndexMgr, IncludeFixerContext &Context, StringRef StyleName, bool MinimizeIncludePaths) : SymbolIndexMgr(SymbolIndexMgr), Context(Context), - MinimizeIncludePaths(MinimizeIncludePaths), FallbackStyle(StyleName) {} + MinimizeIncludePaths(MinimizeIncludePaths) {} IncludeFixerActionFactory::~IncludeFixerActionFactory() = default; @@ -373,8 +368,8 @@ bool IncludeFixerActionFactory::runInvoc Compiler.getDiagnostics().setErrorLimit(0); // Run the parser, gather missing includes. - auto ScopedToolAction = llvm::make_unique( - SymbolIndexMgr, FallbackStyle, MinimizeIncludePaths); + auto ScopedToolAction = + llvm::make_unique(SymbolIndexMgr, MinimizeIncludePaths); Compiler.ExecuteAction(*ScopedToolAction); Context = ScopedToolAction->getIncludeFixerContext( Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp?rev=271273&r1=271272&r2=271273&view=diff == --- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp (original) +++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Tue May 31 08:23:00 2016 @@ -81,6 +81,59 @@ cl::opt "headers if there is no clang-format config file found."), cl::init("llvm"), cl::cat(IncludeFixerCategory)); +std::unique_ptr +createSymbolIndexManager(StringRef FilePath) { + auto SymbolIndexMgr = llvm::make_unique(); + switch (DatabaseFormat) { + case fixed: { +// Parse input and fill the database with it. +// =<, header...> +// Multiple symbols can be given, separated by semicolons. +std::map> SymbolsMap; +SmallVector SemicolonSplits; +StringRef(Input).split(SemicolonSplits, ";"); +std::vector Symbols; +for (StringRef Pair : SemicolonSplits) { + auto Split = Pair.split('='); + std::vector Headers; + SmallVector CommaSplits; + Split.second.split(CommaSplits, ","); + for (StringRef Header : CommaSplits) +Symbols.push_back(find_all_symbols::SymbolInfo( +Split.first.trim(), +find_all_symbols::SymbolInfo::SymbolKind::Unknown, Header.trim(), 1, +{})); +} +SymbolIndexMgr->addSymbolIndex( +llvm::make_unique(Symbols)); +break; + } + case yaml: { +llvm::ErrorOr> DB(nullptr); +if (!Input.empty()) { + DB = include_fixer::YamlSymbolIndex::createFromFile(Input); +} else { + // If we don't have any input file, look in the directory of the first + // file and its parents. + SmallString<128> AbsolutePath(tooling::getAbsolutePath(FilePath)); + StringRef Directory = llvm::sys::path::parent_path(AbsolutePath); + DB = include_fixer::YamlSymbolIndex::createFromDirectory( + Directory, "find_all_symbols_db.yaml"); +} + +if (!DB) { + llvm::errs() << "Couldn't find YAML db: " << DB.getError().message() + << '\n'; + return nullptr; +
Re: [PATCH] D20808: [include-fixer] Code cleanup.
This revision was automatically updated to reflect the committed changes. Closed by commit rL271273: [include-fixer] Code cleanup. (authored by hokein). Changed prior to commit: http://reviews.llvm.org/D20808?vs=59038&id=59052#toc Repository: rL LLVM http://reviews.llvm.org/D20808 Files: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Index: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp === --- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp +++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp @@ -59,9 +59,8 @@ class Action : public clang::ASTFrontendAction, public clang::ExternalSemaSource { public: - explicit Action(SymbolIndexManager &SymbolIndexMgr, StringRef StyleName, - bool MinimizeIncludePaths) - : SymbolIndexMgr(SymbolIndexMgr), FallbackStyle(StyleName), + explicit Action(SymbolIndexManager &SymbolIndexMgr, bool MinimizeIncludePaths) + : SymbolIndexMgr(SymbolIndexMgr), MinimizeIncludePaths(MinimizeIncludePaths) {} std::unique_ptr @@ -288,10 +287,6 @@ /// be used as the insertion point for new include directives. unsigned FirstIncludeOffset = -1U; - /// The fallback format style for formatting after insertion if there is no - /// clang-format config file found. - std::string FallbackStyle; - /// The symbol being queried. std::string QuerySymbol; @@ -347,7 +342,7 @@ SymbolIndexManager &SymbolIndexMgr, IncludeFixerContext &Context, StringRef StyleName, bool MinimizeIncludePaths) : SymbolIndexMgr(SymbolIndexMgr), Context(Context), - MinimizeIncludePaths(MinimizeIncludePaths), FallbackStyle(StyleName) {} + MinimizeIncludePaths(MinimizeIncludePaths) {} IncludeFixerActionFactory::~IncludeFixerActionFactory() = default; @@ -373,8 +368,8 @@ Compiler.getDiagnostics().setErrorLimit(0); // Run the parser, gather missing includes. - auto ScopedToolAction = llvm::make_unique( - SymbolIndexMgr, FallbackStyle, MinimizeIncludePaths); + auto ScopedToolAction = + llvm::make_unique(SymbolIndexMgr, MinimizeIncludePaths); Compiler.ExecuteAction(*ScopedToolAction); Context = ScopedToolAction->getIncludeFixerContext( Index: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp === --- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp +++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp @@ -81,6 +81,59 @@ "headers if there is no clang-format config file found."), cl::init("llvm"), cl::cat(IncludeFixerCategory)); +std::unique_ptr +createSymbolIndexManager(StringRef FilePath) { + auto SymbolIndexMgr = llvm::make_unique(); + switch (DatabaseFormat) { + case fixed: { +// Parse input and fill the database with it. +// =<, header...> +// Multiple symbols can be given, separated by semicolons. +std::map> SymbolsMap; +SmallVector SemicolonSplits; +StringRef(Input).split(SemicolonSplits, ";"); +std::vector Symbols; +for (StringRef Pair : SemicolonSplits) { + auto Split = Pair.split('='); + std::vector Headers; + SmallVector CommaSplits; + Split.second.split(CommaSplits, ","); + for (StringRef Header : CommaSplits) +Symbols.push_back(find_all_symbols::SymbolInfo( +Split.first.trim(), +find_all_symbols::SymbolInfo::SymbolKind::Unknown, Header.trim(), 1, +{})); +} +SymbolIndexMgr->addSymbolIndex( +llvm::make_unique(Symbols)); +break; + } + case yaml: { +llvm::ErrorOr> DB(nullptr); +if (!Input.empty()) { + DB = include_fixer::YamlSymbolIndex::createFromFile(Input); +} else { + // If we don't have any input file, look in the directory of the first + // file and its parents. + SmallString<128> AbsolutePath(tooling::getAbsolutePath(FilePath)); + StringRef Directory = llvm::sys::path::parent_path(AbsolutePath); + DB = include_fixer::YamlSymbolIndex::createFromDirectory( + Directory, "find_all_symbols_db.yaml"); +} + +if (!DB) { + llvm::errs() << "Couldn't find YAML db: " << DB.getError().message() + << '\n'; + return nullptr; +} + +SymbolIndexMgr->addSymbolIndex(std::move(*DB)); +break; + } + } + return SymbolIndexMgr; +} + int includeFixerMain(int argc, const char **argv) { tooling::CommonOptionsParser options(argc, argv, IncludeFixerCategory); tooling::ClangTool tool(options.getCompilations(), @@ -128,55 +181,10 @@ } // Set up data source. - auto SymbolIndexMgr = llvm::make_unique(); - switch (DatabaseFormat) { - case fixed: { -// Parse input and fill the database with it. -// =<, header...> -// Multiple symbols can be given, separated by semic
[PATCH] D20811: [analyzer] Model some library functions
NoQ created this revision. NoQ added reviewers: zaks.anna, dcoughlin. NoQ added a subscriber: cfe-commits. Herald added a subscriber: aemerson. I've put together a simple checker that throws no warnings, but models some library functions, which has already helped us to suppress some false positives in other checkers in our runs. For pure functions, i chose the old `evalCall()` approach instead of the body-farm approach because i wanted to produce less state splits. For example, this checker produce a single exploded graph branch for `ispunct()`'s non-zero branch, when its argument is in range ['!', '/'] U [':', '@'] U ['[', '`'] U ['{', '~'] - i'm not sure if there's a way to write this out with if's and produce less than 4 branches. (Do we have any plans on merging branches more aggressively during analysis?) Because these functions are pure, we'd hardly ever want to catch them with`evalCall()` again in another checker. Additionally, this checker's brace-initializers for function specifications are quite short - of course they're limited to very simple cases - the list of these cases can be expanded though. The checker doesn't seem to be noticeably degrading performance. Here's an example of a false positve squashed: {F203} Here `line` is taken to be "", the `line++` statement is executed at least once (by looking at the exploded graph; there's lack of "entering loop body" diagnostic piece because loop condition has complicated CFG, which is why it fails to highlight - a separate issue), and the analyzer fails to realize that isspace('\0') is false. http://reviews.llvm.org/D20811 Files: include/clang/StaticAnalyzer/Checkers/Checkers.td lib/StaticAnalyzer/Checkers/CMakeLists.txt lib/StaticAnalyzer/Checkers/LibraryFunctionsChecker.cpp test/Analysis/library-functions.c Index: test/Analysis/library-functions.c === --- /dev/null +++ test/Analysis/library-functions.c @@ -0,0 +1,109 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=unix.LibraryFunctions,debug.ExprInspection -verify %s + +void clang_analyzer_eval(int); +int glob; + +typedef struct FILE FILE; +int getc(FILE *); +#define EOF -1 +void test_getc(FILE *fp) { + int x; + while ((x = getc(fp)) != EOF) { +clang_analyzer_eval(x > 255); // expected-warning{{FALSE}} +clang_analyzer_eval(x >= 0); // expected-warning{{TRUE}} + } +} + +typedef unsigned long size_t; +typedef signed long ssize_t; +ssize_t write(int, const void *, size_t); +void test_write(int fd, char *buf) { + glob = 1; + ssize_t x = write(fd, buf, 10); + clang_analyzer_eval(glob); // expected-warning{{UNKNOWN}} + if (x >= 0) +clang_analyzer_eval(x <= 10); // expected-warning{{TRUE}} + else +clang_analyzer_eval(x == -1); // expected-warning{{TRUE}} +} + +size_t fread(void *, size_t, size_t, FILE *); +void test_fread(FILE *fp, int *buf) { + size_t x = fread(buf, sizeof(int), 10, fp); + clang_analyzer_eval(x <= 10); // expected-warning{{TRUE}} +} + +ssize_t getline(char **, size_t *, FILE *); +void test_getline(FILE *fp) { + char *line = 0; + size_t n = 0; + ssize_t len; + while ((len = getline(&line, &n, fp)) != -1) { +clang_analyzer_eval(len == 0); // expected-warning{{FALSE}} + } +} + +int isascii(int); +void test_isascii(int x) { + clang_analyzer_eval(isascii(123)); // expected-warning{{TRUE}} + clang_analyzer_eval(isascii(-1)); // expected-warning{{FALSE}} + if (isascii(x)) { +clang_analyzer_eval(x < 128); // expected-warning{{TRUE}} +clang_analyzer_eval(x >= 0); // expected-warning{{TRUE}} + } else { +if (x > 42) + clang_analyzer_eval(x >= 128); // expected-warning{{TRUE}} +else + clang_analyzer_eval(x < 0); // expected-warning{{TRUE}} + } + glob = 1; + isascii('a'); + clang_analyzer_eval(glob); // expected-warning{{TRUE}} +} + +int islower(int); +void test_islower(int x) { + clang_analyzer_eval(islower('x')); // expected-warning{{TRUE}} + clang_analyzer_eval(islower('X')); // expected-warning{{FALSE}} + if (islower(x)) +clang_analyzer_eval(x < 'a'); // expected-warning{{FALSE}} +} + +int getchar(void); +void test_getchar() { + int x = getchar(); + if (x == EOF) +return; + clang_analyzer_eval(x < 0); // expected-warning{{FALSE}} + clang_analyzer_eval(x < 256); // expected-warning{{TRUE}} +} + +int isalpha(int); +void test_isalpha() { + clang_analyzer_eval(isalpha(']')); // expected-warning{{FALSE}} + clang_analyzer_eval(isalpha('Q')); // expected-warning{{TRUE}} + clang_analyzer_eval(isalpha(128)); // expected-warning{{UNKNOWN}} +} + +int isalnum(int); +void test_alnum() { + clang_analyzer_eval(isalnum('1')); // expected-warning{{TRUE}} + clang_analyzer_eval(isalnum(')')); // expected-warning{{FALSE}} +} + +int isblank(int); +void test_isblank() { + clang_analyzer_eval(isblank('\t')); // expected-warning{{TRUE}} + clang_analyzer_eval(isblank(' ')); // expected-warning{{TRUE}} + clang_analyzer_eval(isblan
Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().
ioeric updated this revision to Diff 59053. ioeric marked 3 inline comments as done. ioeric added a comment. - Nits fixed. http://reviews.llvm.org/D20734 Files: include/clang/Format/Format.h lib/Format/Format.cpp unittests/Format/CleanupTest.cpp Index: unittests/Format/CleanupTest.cpp === --- unittests/Format/CleanupTest.cpp +++ unittests/Format/CleanupTest.cpp @@ -243,13 +243,39 @@ class CleanUpReplacementsTest : public ::testing::Test { protected: - tooling::Replacement createReplacement(SourceLocation Start, unsigned Length, - llvm::StringRef ReplacementText) { -return tooling::Replacement(Context.Sources, Start, Length, -ReplacementText); + tooling::Replacement createReplacement(unsigned Offset, unsigned Length, + StringRef Text) { +return tooling::Replacement(FileName, Offset, Length, Text); } - RewriterTestContext Context; + tooling::Replacement createInsertion(StringRef HeaderName) { +return createReplacement(UINT_MAX, 0, HeaderName); + } + + inline std::string apply(StringRef Code, + const tooling::Replacements Replaces) { +return applyAllReplacements( +Code, cleanupAroundReplacements(Code, Replaces, Style)); + } + + inline std::string formatAndApply(StringRef Code, +const tooling::Replacements Replaces) { +return applyAllReplacements( +Code, +formatReplacements( +Code, cleanupAroundReplacements(Code, Replaces, Style), Style)); + } + + int getOffset(StringRef Code, int Line, int Column) { +RewriterTestContext Context; +FileID ID = Context.createInMemoryFile(FileName, Code); +auto DecomposedLocation = +Context.Sources.getDecomposedLoc(Context.getLocation(ID, Line, Column)); +return DecomposedLocation.second; + } + + const std::string FileName = "fix.cpp"; + FormatStyle Style = getLLVMStyle(); }; TEST_F(CleanUpReplacementsTest, FixOnlyAffectedCodeAfterReplacements) { @@ -268,17 +294,247 @@ "namespace D { int i; }\n\n" "int x= 0;" "}"; - FileID ID = Context.createInMemoryFile("fix.cpp", Code); - tooling::Replacements Replaces; - Replaces.insert(tooling::Replacement(Context.Sources, - Context.getLocation(ID, 3, 3), 6, "")); - Replaces.insert(tooling::Replacement(Context.Sources, - Context.getLocation(ID, 9, 34), 6, "")); - - format::FormatStyle Style = format::getLLVMStyle(); - auto FinalReplaces = formatReplacements( - Code, cleanupAroundReplacements(Code, Replaces, Style), Style); - EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces)); + tooling::Replacements Replaces = { + createReplacement(getOffset(Code, 3, 3), 6, ""), + createReplacement(getOffset(Code, 9, 34), 6, "")}; + + EXPECT_EQ(Expected, formatAndApply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, NoExistingIncludeWithoutDefine) { + std::string Code = "int main() {}"; + std::string Expected = "#include \"a.h\"\n" + "int main() {}"; + tooling::Replacements Replaces = {createInsertion("#include \"a.h\"")}; + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, NoExistingIncludeWithDefine) { + std::string Code = "#ifndef A_H\n" + "#define A_H\n" + "class A {};\n" + "#define MMM 123\n" + "#endif"; + std::string Expected = "#ifndef A_H\n" + "#define A_H\n" + "#include \"b.h\"\n" + "class A {};\n" + "#define MMM 123\n" + "#endif"; + + tooling::Replacements Replaces = {createInsertion("#include \"b.h\"")}; + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(CleanUpReplacementsTest, InsertBeforeCategoryWithLowerPriority) { + std::string Code = "#ifndef A_H\n" + "#define A_H\n" + "\n" + "\n" + "\n" + "#include \n" + "class A {};\n" + "#define MMM 123\n" + "#endif"; + std::string Expected = "#ifndef A_H\n" + "#define A_H\n" + "\n" + "\n" + "\n" + "#include \"a.h\"\n" + "#include \n" + "class A {};\n" + "#define MMM 123\n" + "#endif"; + + tooling::Replacements Replaces = {createInsertion("#include \"a.h\"")}; + EXPECT_EQ(Expected, apply(Code, Replaces)); +} + +TEST_F(Cl
Re: [PATCH] D20563: Add load/store co-processor intrinsics
This revision was automatically updated to reflect the committed changes. Closed by commit rL271275: [ARM] Add load/store co-processor intrinsics. (authored by rsingh). Changed prior to commit: http://reviews.llvm.org/D20563?vs=58314&id=59055#toc Repository: rL LLVM http://reviews.llvm.org/D20563 Files: cfe/trunk/include/clang/Basic/BuiltinsARM.def cfe/trunk/test/CodeGen/builtins-arm.c cfe/trunk/test/Sema/builtins-arm.c Index: cfe/trunk/include/clang/Basic/BuiltinsARM.def === --- cfe/trunk/include/clang/Basic/BuiltinsARM.def +++ cfe/trunk/include/clang/Basic/BuiltinsARM.def @@ -48,6 +48,16 @@ BUILTIN(__builtin_arm_vcvtr_d, "fdi", "nc") // Coprocessor +BUILTIN(__builtin_arm_ldc, "vUIiUIivC*", "") +BUILTIN(__builtin_arm_ldcl, "vUIiUIivC*", "") +BUILTIN(__builtin_arm_ldc2, "vUIiUIivC*", "") +BUILTIN(__builtin_arm_ldc2l, "vUIiUIivC*", "") + +BUILTIN(__builtin_arm_stc, "vUIiUIiv*", "") +BUILTIN(__builtin_arm_stcl, "vUIiUIiv*", "") +BUILTIN(__builtin_arm_stc2, "vUIiUIiv*", "") +BUILTIN(__builtin_arm_stc2l, "vUIiUIiv*", "") + BUILTIN(__builtin_arm_mcr, "vUIiUIiUiUIiUIiUIi", "") BUILTIN(__builtin_arm_mcr2, "vUIiUIiUiUIiUIiUIi", "") BUILTIN(__builtin_arm_mrc, "UiUIiUIiUIiUIiUIi", "") Index: cfe/trunk/test/CodeGen/builtins-arm.c === --- cfe/trunk/test/CodeGen/builtins-arm.c +++ cfe/trunk/test/CodeGen/builtins-arm.c @@ -84,6 +84,62 @@ // CHECK: call {{.*}} @llvm.prefetch(i8* %{{.*}}, i32 1, i32 3, i32 0) } +void ldc(const void *i) { + // CHECK: define void @ldc(i8* %i) + // CHECK: call void @llvm.arm.ldc(i32 1, i32 2, i8* %i) + // CHECK-NEXT: ret void + __builtin_arm_ldc(1, 2, i); +} + +void ldcl(const void *i) { + // CHECK: define void @ldcl(i8* %i) + // CHECK: call void @llvm.arm.ldcl(i32 1, i32 2, i8* %i) + // CHECK-NEXT: ret void + __builtin_arm_ldcl(1, 2, i); +} + +void ldc2(const void *i) { + // CHECK: define void @ldc2(i8* %i) + // CHECK: call void @llvm.arm.ldc2(i32 1, i32 2, i8* %i) + // CHECK-NEXT: ret void + __builtin_arm_ldc2(1, 2, i); +} + +void ldc2l(const void *i) { + // CHECK: define void @ldc2l(i8* %i) + // CHECK: call void @llvm.arm.ldc2l(i32 1, i32 2, i8* %i) + // CHECK-NEXT: ret void + __builtin_arm_ldc2l(1, 2, i); +} + +void stc(void *i) { + // CHECK: define void @stc(i8* %i) + // CHECK: call void @llvm.arm.stc(i32 1, i32 2, i8* %i) + // CHECK-NEXT: ret void + __builtin_arm_stc(1, 2, i); +} + +void stcl(void *i) { + // CHECK: define void @stcl(i8* %i) + // CHECK: call void @llvm.arm.stcl(i32 1, i32 2, i8* %i) + // CHECK-NEXT: ret void + __builtin_arm_stcl(1, 2, i); +} + +void stc2(void *i) { + // CHECK: define void @stc2(i8* %i) + // CHECK: call void @llvm.arm.stc2(i32 1, i32 2, i8* %i) + // CHECK-NEXT: ret void + __builtin_arm_stc2(1, 2, i); +} + +void stc2l(void *i) { + // CHECK: define void @stc2l(i8* %i) + // CHECK: call void @llvm.arm.stc2l(i32 1, i32 2, i8* %i) + // CHECK-NEXT: ret void + __builtin_arm_stc2l(1, 2, i); +} + void cdp() { // CHECK: define void @cdp() // CHECK: call void @llvm.arm.cdp(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6) Index: cfe/trunk/test/Sema/builtins-arm.c === --- cfe/trunk/test/Sema/builtins-arm.c +++ cfe/trunk/test/Sema/builtins-arm.c @@ -48,6 +48,38 @@ } void test6(int a, int b, int c) { + __builtin_arm_ldc(1, 2, &a); + __builtin_arm_ldc(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldc' must be a constant integer}} + __builtin_arm_ldc(1, a, &a); // expected-error {{argument to '__builtin_arm_ldc' must be a constant integer}} + + __builtin_arm_ldcl(1, 2, &a); + __builtin_arm_ldcl(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldcl' must be a constant integer}} + __builtin_arm_ldcl(1, a, &a); // expected-error {{argument to '__builtin_arm_ldcl' must be a constant integer}} + + __builtin_arm_ldc2(1, 2, &a); + __builtin_arm_ldc2(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldc2' must be a constant integer}} + __builtin_arm_ldc2(1, a, &a); // expected-error {{argument to '__builtin_arm_ldc2' must be a constant integer}} + + __builtin_arm_ldc2l(1, 2, &a); + __builtin_arm_ldc2l(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldc2l' must be a constant integer}} + __builtin_arm_ldc2l(1, a, &a); // expected-error {{argument to '__builtin_arm_ldc2l' must be a constant integer}} + + __builtin_arm_stc(1, 2, &a); + __builtin_arm_stc(a, 2, &a); // expected-error {{argument to '__builtin_arm_stc' must be a constant integer}} + __builtin_arm_stc(1, a, &a); // expected-error {{argument to '__builtin_arm_stc' must be a constant integer}} + + __builtin_arm_stcl(1, 2, &a); + __builtin_arm_stcl(a, 2, &a); // expected-error {{argument to '__builtin_arm_stcl' must be a constant integer}} + __builtin_arm_stcl(1, a, &a); // expected-error {{argument to '__builtin_arm_s
r271275 - [ARM] Add load/store co-processor intrinsics.
Author: rsingh Date: Tue May 31 08:31:25 2016 New Revision: 271275 URL: http://llvm.org/viewvc/llvm-project?rev=271275&view=rev Log: [ARM] Add load/store co-processor intrinsics. Differential Revision: http://reviews.llvm.org/D20563 Modified: cfe/trunk/include/clang/Basic/BuiltinsARM.def cfe/trunk/test/CodeGen/builtins-arm.c cfe/trunk/test/Sema/builtins-arm.c Modified: cfe/trunk/include/clang/Basic/BuiltinsARM.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsARM.def?rev=271275&r1=271274&r2=271275&view=diff == --- cfe/trunk/include/clang/Basic/BuiltinsARM.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsARM.def Tue May 31 08:31:25 2016 @@ -48,6 +48,16 @@ BUILTIN(__builtin_arm_vcvtr_f, "ffi", "n BUILTIN(__builtin_arm_vcvtr_d, "fdi", "nc") // Coprocessor +BUILTIN(__builtin_arm_ldc, "vUIiUIivC*", "") +BUILTIN(__builtin_arm_ldcl, "vUIiUIivC*", "") +BUILTIN(__builtin_arm_ldc2, "vUIiUIivC*", "") +BUILTIN(__builtin_arm_ldc2l, "vUIiUIivC*", "") + +BUILTIN(__builtin_arm_stc, "vUIiUIiv*", "") +BUILTIN(__builtin_arm_stcl, "vUIiUIiv*", "") +BUILTIN(__builtin_arm_stc2, "vUIiUIiv*", "") +BUILTIN(__builtin_arm_stc2l, "vUIiUIiv*", "") + BUILTIN(__builtin_arm_mcr, "vUIiUIiUiUIiUIiUIi", "") BUILTIN(__builtin_arm_mcr2, "vUIiUIiUiUIiUIiUIi", "") BUILTIN(__builtin_arm_mrc, "UiUIiUIiUIiUIiUIi", "") Modified: cfe/trunk/test/CodeGen/builtins-arm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-arm.c?rev=271275&r1=271274&r2=271275&view=diff == --- cfe/trunk/test/CodeGen/builtins-arm.c (original) +++ cfe/trunk/test/CodeGen/builtins-arm.c Tue May 31 08:31:25 2016 @@ -84,6 +84,62 @@ void prefetch(int i) { // CHECK: call {{.*}} @llvm.prefetch(i8* %{{.*}}, i32 1, i32 3, i32 0) } +void ldc(const void *i) { + // CHECK: define void @ldc(i8* %i) + // CHECK: call void @llvm.arm.ldc(i32 1, i32 2, i8* %i) + // CHECK-NEXT: ret void + __builtin_arm_ldc(1, 2, i); +} + +void ldcl(const void *i) { + // CHECK: define void @ldcl(i8* %i) + // CHECK: call void @llvm.arm.ldcl(i32 1, i32 2, i8* %i) + // CHECK-NEXT: ret void + __builtin_arm_ldcl(1, 2, i); +} + +void ldc2(const void *i) { + // CHECK: define void @ldc2(i8* %i) + // CHECK: call void @llvm.arm.ldc2(i32 1, i32 2, i8* %i) + // CHECK-NEXT: ret void + __builtin_arm_ldc2(1, 2, i); +} + +void ldc2l(const void *i) { + // CHECK: define void @ldc2l(i8* %i) + // CHECK: call void @llvm.arm.ldc2l(i32 1, i32 2, i8* %i) + // CHECK-NEXT: ret void + __builtin_arm_ldc2l(1, 2, i); +} + +void stc(void *i) { + // CHECK: define void @stc(i8* %i) + // CHECK: call void @llvm.arm.stc(i32 1, i32 2, i8* %i) + // CHECK-NEXT: ret void + __builtin_arm_stc(1, 2, i); +} + +void stcl(void *i) { + // CHECK: define void @stcl(i8* %i) + // CHECK: call void @llvm.arm.stcl(i32 1, i32 2, i8* %i) + // CHECK-NEXT: ret void + __builtin_arm_stcl(1, 2, i); +} + +void stc2(void *i) { + // CHECK: define void @stc2(i8* %i) + // CHECK: call void @llvm.arm.stc2(i32 1, i32 2, i8* %i) + // CHECK-NEXT: ret void + __builtin_arm_stc2(1, 2, i); +} + +void stc2l(void *i) { + // CHECK: define void @stc2l(i8* %i) + // CHECK: call void @llvm.arm.stc2l(i32 1, i32 2, i8* %i) + // CHECK-NEXT: ret void + __builtin_arm_stc2l(1, 2, i); +} + void cdp() { // CHECK: define void @cdp() // CHECK: call void @llvm.arm.cdp(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6) Modified: cfe/trunk/test/Sema/builtins-arm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtins-arm.c?rev=271275&r1=271274&r2=271275&view=diff == --- cfe/trunk/test/Sema/builtins-arm.c (original) +++ cfe/trunk/test/Sema/builtins-arm.c Tue May 31 08:31:25 2016 @@ -48,6 +48,38 @@ void test5() { } void test6(int a, int b, int c) { + __builtin_arm_ldc(1, 2, &a); + __builtin_arm_ldc(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldc' must be a constant integer}} + __builtin_arm_ldc(1, a, &a); // expected-error {{argument to '__builtin_arm_ldc' must be a constant integer}} + + __builtin_arm_ldcl(1, 2, &a); + __builtin_arm_ldcl(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldcl' must be a constant integer}} + __builtin_arm_ldcl(1, a, &a); // expected-error {{argument to '__builtin_arm_ldcl' must be a constant integer}} + + __builtin_arm_ldc2(1, 2, &a); + __builtin_arm_ldc2(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldc2' must be a constant integer}} + __builtin_arm_ldc2(1, a, &a); // expected-error {{argument to '__builtin_arm_ldc2' must be a constant integer}} + + __builtin_arm_ldc2l(1, 2, &a); + __builtin_arm_ldc2l(a, 2, &a); // expected-error {{argument to '__builtin_arm_ldc2l' must be a constant integer}} + __builtin_arm_ldc2l(1, a, &a); // expected-error {{argument
Re: [PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().
This revision was automatically updated to reflect the committed changes. Closed by commit rL271276: [clang-format] insert new #includes into correct blocks when cleaning up… (authored by ioeric). Changed prior to commit: http://reviews.llvm.org/D20734?vs=59053&id=59056#toc Repository: rL LLVM http://reviews.llvm.org/D20734 Files: cfe/trunk/include/clang/Format/Format.h cfe/trunk/lib/Format/Format.cpp cfe/trunk/unittests/Format/CleanupTest.cpp Index: cfe/trunk/lib/Format/Format.cpp === --- cfe/trunk/lib/Format/Format.cpp +++ cfe/trunk/lib/Format/Format.cpp @@ -1262,15 +1262,73 @@ result.size(), result)); } +namespace { + +// This class manages priorities of #include categories and calculates +// priorities for headers. +class IncludeCategoryManager { +public: + IncludeCategoryManager(const FormatStyle &Style, StringRef FileName) + : Style(Style), FileName(FileName) { +FileStem = llvm::sys::path::stem(FileName); +for (const auto &Category : Style.IncludeCategories) + CategoryRegexs.emplace_back(Category.Regex); +IsMainFile = FileName.endswith(".c") || FileName.endswith(".cc") || + FileName.endswith(".cpp") || FileName.endswith(".c++") || + FileName.endswith(".cxx") || FileName.endswith(".m") || + FileName.endswith(".mm"); + } + + // Returns the priority of the category which \p IncludeName belongs to. + // If \p CheckMainHeader is true and \p IncludeName is a main header, returns + // 0. Otherwise, returns the priority of the matching category or INT_MAX. + int getIncludePriority(StringRef IncludeName, bool CheckMainHeader) { +int Ret = INT_MAX; +for (unsigned i = 0, e = CategoryRegexs.size(); i != e; ++i) + if (CategoryRegexs[i].match(IncludeName)) { +Ret = Style.IncludeCategories[i].Priority; +break; + } +if (CheckMainHeader && IsMainFile && Ret > 0 && isMainHeader(IncludeName)) + Ret = 0; +return Ret; + } + +private: + bool isMainHeader(StringRef IncludeName) const { +if (!IncludeName.startswith("\"")) + return false; +StringRef HeaderStem = +llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1)); +if (FileStem.startswith(HeaderStem)) { + llvm::Regex MainIncludeRegex( + (HeaderStem + Style.IncludeIsMainRegex).str()); + if (MainIncludeRegex.match(FileStem)) +return true; +} +return false; + } + + const FormatStyle &Style; + bool IsMainFile; + StringRef FileName; + StringRef FileStem; + SmallVector CategoryRegexs; +}; + +const char IncludeRegexPattern[] = +R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))"; + +} // anonymous namespace + tooling::Replacements sortCppIncludes(const FormatStyle &Style, StringRef Code, ArrayRef Ranges, StringRef FileName, tooling::Replacements &Replaces, unsigned *Cursor) { unsigned Prev = 0; unsigned SearchFrom = 0; - llvm::Regex IncludeRegex( - R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))"); + llvm::Regex IncludeRegex(IncludeRegexPattern); SmallVector Matches; SmallVector IncludesInBlock; @@ -1281,19 +1339,9 @@ // // FIXME: Do some sanity checking, e.g. edit distance of the base name, to fix // cases where the first #include is unlikely to be the main header. - bool IsSource = FileName.endswith(".c") || FileName.endswith(".cc") || - FileName.endswith(".cpp") || FileName.endswith(".c++") || - FileName.endswith(".cxx") || FileName.endswith(".m") || - FileName.endswith(".mm"); - StringRef FileStem = llvm::sys::path::stem(FileName); + IncludeCategoryManager Categories(Style, FileName); bool FirstIncludeBlock = true; bool MainIncludeFound = false; - - // Create pre-compiled regular expressions for the #include categories. - SmallVector CategoryRegexs; - for (const auto &Category : Style.IncludeCategories) -CategoryRegexs.emplace_back(Category.Regex); - bool FormattingOff = false; for (;;) { @@ -1310,26 +1358,11 @@ if (!FormattingOff && !Line.endswith("\\")) { if (IncludeRegex.match(Line, &Matches)) { StringRef IncludeName = Matches[2]; -int Category = INT_MAX; -for (unsigned i = 0, e = CategoryRegexs.size(); i != e; ++i) { - if (CategoryRegexs[i].match(IncludeName)) { -Category = Style.IncludeCategories[i].Priority; -break; - } -} -if (IsSource && !MainIncludeFound && Category > 0 && -FirstIncludeBlock && IncludeName.startswith("\"")) { - StringRef HeaderStem = - llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1)); - if (FileStem.starts
r271276 - [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().
Author: ioeric Date: Tue May 31 08:34:20 2016 New Revision: 271276 URL: http://llvm.org/viewvc/llvm-project?rev=271276&view=rev Log: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements(). Summary: When a replacement's offset is set to UINT_MAX or -1U, it is treated as a header insertion replacement by cleanupAroundReplacements(). The new #include directive is then inserted into the correct block. Reviewers: klimek, djasper Subscribers: klimek, cfe-commits, bkramer Differential Revision: http://reviews.llvm.org/D20734 Modified: cfe/trunk/include/clang/Format/Format.h cfe/trunk/lib/Format/Format.cpp cfe/trunk/unittests/Format/CleanupTest.cpp Modified: cfe/trunk/include/clang/Format/Format.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=271276&r1=271275&r2=271276&view=diff == --- cfe/trunk/include/clang/Format/Format.h (original) +++ cfe/trunk/include/clang/Format/Format.h Tue May 31 08:34:20 2016 @@ -773,6 +773,8 @@ tooling::Replacements formatReplacements /// \brief Returns the replacements corresponding to applying \p Replaces and /// cleaning up the code after that. +/// This also inserts a C++ #include directive into the correct block if the +/// replacement corresponding to the header insertion has offset UINT_MAX. tooling::Replacements cleanupAroundReplacements(StringRef Code, const tooling::Replacements &Replaces, const FormatStyle &Style); Modified: cfe/trunk/lib/Format/Format.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=271276&r1=271275&r2=271276&view=diff == --- cfe/trunk/lib/Format/Format.cpp (original) +++ cfe/trunk/lib/Format/Format.cpp Tue May 31 08:34:20 2016 @@ -1262,6 +1262,65 @@ static void sortCppIncludes(const Format result.size(), result)); } +namespace { + +// This class manages priorities of #include categories and calculates +// priorities for headers. +class IncludeCategoryManager { +public: + IncludeCategoryManager(const FormatStyle &Style, StringRef FileName) + : Style(Style), FileName(FileName) { +FileStem = llvm::sys::path::stem(FileName); +for (const auto &Category : Style.IncludeCategories) + CategoryRegexs.emplace_back(Category.Regex); +IsMainFile = FileName.endswith(".c") || FileName.endswith(".cc") || + FileName.endswith(".cpp") || FileName.endswith(".c++") || + FileName.endswith(".cxx") || FileName.endswith(".m") || + FileName.endswith(".mm"); + } + + // Returns the priority of the category which \p IncludeName belongs to. + // If \p CheckMainHeader is true and \p IncludeName is a main header, returns + // 0. Otherwise, returns the priority of the matching category or INT_MAX. + int getIncludePriority(StringRef IncludeName, bool CheckMainHeader) { +int Ret = INT_MAX; +for (unsigned i = 0, e = CategoryRegexs.size(); i != e; ++i) + if (CategoryRegexs[i].match(IncludeName)) { +Ret = Style.IncludeCategories[i].Priority; +break; + } +if (CheckMainHeader && IsMainFile && Ret > 0 && isMainHeader(IncludeName)) + Ret = 0; +return Ret; + } + +private: + bool isMainHeader(StringRef IncludeName) const { +if (!IncludeName.startswith("\"")) + return false; +StringRef HeaderStem = +llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1)); +if (FileStem.startswith(HeaderStem)) { + llvm::Regex MainIncludeRegex( + (HeaderStem + Style.IncludeIsMainRegex).str()); + if (MainIncludeRegex.match(FileStem)) +return true; +} +return false; + } + + const FormatStyle &Style; + bool IsMainFile; + StringRef FileName; + StringRef FileStem; + SmallVector CategoryRegexs; +}; + +const char IncludeRegexPattern[] = +R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))"; + +} // anonymous namespace + tooling::Replacements sortCppIncludes(const FormatStyle &Style, StringRef Code, ArrayRef Ranges, StringRef FileName, @@ -1269,8 +1328,7 @@ tooling::Replacements sortCppIncludes(co unsigned *Cursor) { unsigned Prev = 0; unsigned SearchFrom = 0; - llvm::Regex IncludeRegex( - R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))"); + llvm::Regex IncludeRegex(IncludeRegexPattern); SmallVector Matches; SmallVector IncludesInBlock; @@ -1281,19 +1339,9 @@ tooling::Replacements sortCppIncludes(co // // FIXME: Do some sanity checking, e.g. edit distance of the base name, to fix // cases where the first #include is unlikely to be the main header. - bool IsSource = FileName.endswith(".c"
Re: [PATCH] D20813: [include-fixer] use tooling::Replacements since the order of replacements don't matter anymore.
bkramer accepted this revision. bkramer added a comment. This revision is now accepted and ready to land. nice cleanup http://reviews.llvm.org/D20813 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r271279 - [include-fixer] use tooling::Replacements since the order of replacements don't matter anymore.
Author: ioeric Date: Tue May 31 08:52:59 2016 New Revision: 271279 URL: http://llvm.org/viewvc/llvm-project?rev=271279&view=rev Log: [include-fixer] use tooling::Replacements since the order of replacements don't matter anymore. Summary: [include-fixer] use tooling::Replacements since the order of replacements don't matter anymore. Differential Revision: http://reviews.llvm.org/D20813 Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp clang-tools-extra/trunk/include-fixer/IncludeFixer.h clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=271279&r1=271278&r2=271279&view=diff == --- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original) +++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Tue May 31 08:52:59 2016 @@ -382,12 +382,12 @@ bool IncludeFixerActionFactory::runInvoc return !Compiler.getDiagnostics().hasFatalErrorOccurred(); } -std::vector +tooling::Replacements createInsertHeaderReplacements(StringRef Code, StringRef FilePath, StringRef Header, unsigned FirstIncludeOffset, const clang::format::FormatStyle &Style) { if (Header.empty()) -return {}; +return tooling::Replacements(); // Create replacements for new headers. clang::tooling::Replacements Insertions; if (FirstIncludeOffset == -1U) { @@ -409,13 +409,7 @@ createInsertHeaderReplacements(StringRef llvm::dbgs() << R.toString() << '\n'; }); - clang::tooling::Replacements Replaces = - formatReplacements(Code, Insertions, Style); - // FIXME: remove this when `clang::tooling::Replacements` is implemented as - // `std::vector`. - std::vector Results; - std::copy(Replaces.begin(), Replaces.end(), std::back_inserter(Results)); - return Results; + return formatReplacements(Code, Insertions, Style); } } // namespace include_fixer Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.h?rev=271279&r1=271278&r2=271279&view=diff == --- clang-tools-extra/trunk/include-fixer/IncludeFixer.h (original) +++ clang-tools-extra/trunk/include-fixer/IncludeFixer.h Tue May 31 08:52:59 2016 @@ -74,7 +74,7 @@ private: /// \param Style clang-format style being used. /// /// \return Replacements for inserting and sorting headers. -std::vector createInsertHeaderReplacements( +tooling::Replacements createInsertHeaderReplacements( StringRef Code, StringRef FilePath, StringRef Header, unsigned FirstIncludeOffset = -1U, const clang::format::FormatStyle &Style = clang::format::getLLVMStyle()); Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp?rev=271279&r1=271278&r2=271279&view=diff == --- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp (original) +++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Tue May 31 08:52:59 2016 @@ -169,7 +169,7 @@ int includeFixerMain(int argc, const cha } // FIXME: Insert the header in right FirstIncludeOffset. -std::vector Replacements = +tooling::Replacements Replacements = clang::include_fixer::createInsertHeaderReplacements( Code->getBuffer(), FilePath, InsertHeader, /*FirstIncludeOffset=*/0, InsertStyle); @@ -215,7 +215,7 @@ int includeFixerMain(int argc, const cha } // FIXME: Rank the results and pick the best one instead of the first one. - std::vector Replacements = + tooling::Replacements Replacements = clang::include_fixer::createInsertHeaderReplacements( /*Code=*/Buffer.get()->getBuffer(), FilePath, Context.Headers.front(), Context.FirstIncludeOffset, InsertStyle); @@ -231,9 +231,8 @@ int includeFixerMain(int argc, const cha Diagnostics.setClient(&DiagnosticPrinter, false); if (STDINMode) { -tooling::Replacements Replaces(Replacements.begin(), Replacements.end()); std::string ChangedCode = -tooling::applyAllReplacements(Code->getBuffer(), Replaces); +tooling::applyAllReplacements(Code->getBuffer(), Replacements); llvm::outs() << ChangedCode; return 0; } Modified: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp?rev=271279&r1=271278&r2=271279&view=dif
Re: [PATCH] D20813: [include-fixer] use tooling::Replacements since the order of replacements don't matter anymore.
This revision was automatically updated to reflect the committed changes. Closed by commit rL271279: [include-fixer] use tooling::Replacements since the order of replacements… (authored by ioeric). Changed prior to commit: http://reviews.llvm.org/D20813?vs=59060&id=59061#toc Repository: rL LLVM http://reviews.llvm.org/D20813 Files: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp clang-tools-extra/trunk/include-fixer/IncludeFixer.h clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Index: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp === --- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp +++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp @@ -382,12 +382,12 @@ return !Compiler.getDiagnostics().hasFatalErrorOccurred(); } -std::vector +tooling::Replacements createInsertHeaderReplacements(StringRef Code, StringRef FilePath, StringRef Header, unsigned FirstIncludeOffset, const clang::format::FormatStyle &Style) { if (Header.empty()) -return {}; +return tooling::Replacements(); // Create replacements for new headers. clang::tooling::Replacements Insertions; if (FirstIncludeOffset == -1U) { @@ -409,13 +409,7 @@ llvm::dbgs() << R.toString() << '\n'; }); - clang::tooling::Replacements Replaces = - formatReplacements(Code, Insertions, Style); - // FIXME: remove this when `clang::tooling::Replacements` is implemented as - // `std::vector`. - std::vector Results; - std::copy(Replaces.begin(), Replaces.end(), std::back_inserter(Results)); - return Results; + return formatReplacements(Code, Insertions, Style); } } // namespace include_fixer Index: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp === --- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp +++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp @@ -169,7 +169,7 @@ } // FIXME: Insert the header in right FirstIncludeOffset. -std::vector Replacements = +tooling::Replacements Replacements = clang::include_fixer::createInsertHeaderReplacements( Code->getBuffer(), FilePath, InsertHeader, /*FirstIncludeOffset=*/0, InsertStyle); @@ -215,7 +215,7 @@ } // FIXME: Rank the results and pick the best one instead of the first one. - std::vector Replacements = + tooling::Replacements Replacements = clang::include_fixer::createInsertHeaderReplacements( /*Code=*/Buffer.get()->getBuffer(), FilePath, Context.Headers.front(), Context.FirstIncludeOffset, InsertStyle); @@ -231,9 +231,8 @@ Diagnostics.setClient(&DiagnosticPrinter, false); if (STDINMode) { -tooling::Replacements Replaces(Replacements.begin(), Replacements.end()); std::string ChangedCode = -tooling::applyAllReplacements(Code->getBuffer(), Replaces); +tooling::applyAllReplacements(Code->getBuffer(), Replacements); llvm::outs() << ChangedCode; return 0; } Index: clang-tools-extra/trunk/include-fixer/IncludeFixer.h === --- clang-tools-extra/trunk/include-fixer/IncludeFixer.h +++ clang-tools-extra/trunk/include-fixer/IncludeFixer.h @@ -74,7 +74,7 @@ /// \param Style clang-format style being used. /// /// \return Replacements for inserting and sorting headers. -std::vector createInsertHeaderReplacements( +tooling::Replacements createInsertHeaderReplacements( StringRef Code, StringRef FilePath, StringRef Header, unsigned FirstIncludeOffset = -1U, const clang::format::FormatStyle &Style = clang::format::getLLVMStyle()); Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp === --- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp +++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp @@ -74,12 +74,12 @@ IncludeFixerActionFactory Factory(*SymbolIndexMgr, FixerContext, "llvm"); runOnCode(&Factory, Code, "input.cc", ExtraArgs); - std::vector Replacements; - if (!FixerContext.Headers.empty()) { -Replacements = clang::include_fixer::createInsertHeaderReplacements( -Code, "input.cc", FixerContext.Headers.front(), -FixerContext.FirstIncludeOffset); - } + if (FixerContext.Headers.empty()) +return Code; + tooling::Replacements Replacements = + clang::include_fixer::createInsertHeaderReplacements( + Code, "input.cc", FixerContext.Headers.front(), + FixerContext.FirstIncludeOffset); clang::RewriterTestContext Context; clang::FileID ID = Context.createInMemoryFile("input.cc", Code); clang::tooling::applyAllReplace
[PATCH] D20814: [include-fixer] Rank symbols based on the number of occurrences we found while merging.
bkramer created this revision. bkramer added reviewers: ioeric, djasper. bkramer added a subscriber: cfe-commits. This sorts based on the popularity of the header, not the symbol. If there are mutliple matching symbols in one header we take the maximum popularity for that header and deduplicate. If we know nothing we sort lexicographically based on the header path. http://reviews.llvm.org/D20814 Files: include-fixer/SymbolIndexManager.cpp include-fixer/tool/ClangIncludeFixer.cpp test/include-fixer/Inputs/fake_yaml_db.yaml test/include-fixer/ranking.cpp Index: test/include-fixer/ranking.cpp === --- /dev/null +++ test/include-fixer/ranking.cpp @@ -0,0 +1,6 @@ +// RUN: clang-include-fixer -db=yaml -input=%S/Inputs/fake_yaml_db.yaml -output-headers %s -- | FileCheck %s -implicit-check-not=.h + +// CHECK: "../include/bar.h" +// CHECK-NEXT: "../include/zbar.h" + +bar b; Index: test/include-fixer/Inputs/fake_yaml_db.yaml === --- test/include-fixer/Inputs/fake_yaml_db.yaml +++ test/include-fixer/Inputs/fake_yaml_db.yaml @@ -22,3 +22,24 @@ Type:Class NumOccurrences: 1 ... +Name: bar +Contexts: + - ContextType: Namespace +ContextName: a + - ContextType: Namespace +ContextName: b +FilePath:../include/bar.h +LineNumber: 2 +Type:Class +NumOccurrences: 3 +... +Name: bar +Contexts: + - ContextType: Namespace +ContextName: a + - ContextType: Namespace +ContextName: b +FilePath:../include/zbar.h +LineNumber: 1 +Type:Class +NumOccurrences: 3 Index: include-fixer/tool/ClangIncludeFixer.cpp === --- include-fixer/tool/ClangIncludeFixer.cpp +++ include-fixer/tool/ClangIncludeFixer.cpp @@ -98,11 +98,11 @@ std::vector Headers; SmallVector CommaSplits; Split.second.split(CommaSplits, ","); - for (StringRef Header : CommaSplits) + for (const StringRef &Header : CommaSplits) Symbols.push_back(find_all_symbols::SymbolInfo( Split.first.trim(), find_all_symbols::SymbolInfo::SymbolKind::Unknown, Header.trim(), 1, -{})); +{}, /*NumOccurrences=*/CommaSplits.end() - &Header)); } SymbolIndexMgr->addSymbolIndex( llvm::make_unique(Symbols)); Index: include-fixer/SymbolIndexManager.cpp === --- include-fixer/SymbolIndexManager.cpp +++ include-fixer/SymbolIndexManager.cpp @@ -17,6 +17,37 @@ namespace clang { namespace include_fixer { +using clang::find_all_symbols::SymbolInfo; + +/// Sorts and uniques SymbolInfos based on the popularity info in SymbolInfo. +static void rankByPopularity(std::vector &Symbols) { + // First collect occurrences per header file. + std::map HeaderPopularity; + for (const SymbolInfo &Symbol : Symbols) { +unsigned &Popularity = HeaderPopularity[Symbol.getFilePath()]; +Popularity = std::max(Popularity, Symbol.getNumOccurrences()); + } + + // Sort by the gathered popularities. Use file name as a tie breaker so we can + // deduplicate. + std::sort(Symbols.begin(), Symbols.end(), +[&](const SymbolInfo &A, const SymbolInfo &B) { + auto APop = HeaderPopularity[A.getFilePath()]; + auto BPop = HeaderPopularity[B.getFilePath()]; + if (APop != BPop) +return APop > BPop; + return A.getFilePath() < B.getFilePath(); +}); + + // Deduplicate based on the file name. They will have the same popularity and + // we don't want to suggest the same header twice. + Symbols.erase(std::unique(Symbols.begin(), Symbols.end(), +[](const SymbolInfo &A, const SymbolInfo &B) { + return A.getFilePath() == B.getFilePath(); +}), +Symbols.end()); +} + std::vector SymbolIndexManager::search(llvm::StringRef Identifier) const { // The identifier may be fully qualified, so split it and get all the context @@ -45,6 +76,8 @@ DEBUG(llvm::dbgs() << "Searching " << Names.back() << "... got " << Symbols.size() << " results...\n"); +rankByPopularity(Symbols); + for (const auto &Symbol : Symbols) { // Match the identifier name without qualifier. if (Symbol.getName() == Names.back()) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20798: clang-format: [JS] Sort imported symbols.
djasper added a comment. In general, this is lacking test cases for imports that are wrapped over multiple lines to start with. Should probably add those both for the old and for the new behavior. Comment at: lib/Format/Format.cpp:1229 @@ -1227,9 +1228,3 @@ // the entire block. Otherwise, no replacement is generated. - bool OutOfOrder = false; - for (unsigned i = 1, e = Indices.size(); i != e; ++i) { -if (Indices[i] != i) { - OutOfOrder = true; - break; -} - } - if (!OutOfOrder) + bool InOrder = std::is_sorted(Indices.begin(), Indices.end()); + if (InOrder) I think it's not even worth storing this variable now. Comment at: lib/Format/SortJavaScriptImports.cpp:46 @@ +45,3 @@ + + bool operator==(const JsImportedSymbol &RHS) const { +return Symbol == RHS.Symbol && Alias == RHS.Alias; Maybe add a comment on why you are ignoring 'Range' for comparison. Comment at: lib/Format/SortJavaScriptImports.cpp:168 @@ +167,3 @@ + +if (ReferencesInOrder && SymbolsInOrder) { + return Result; nit: no braces Comment at: lib/Format/SortJavaScriptImports.cpp:232 @@ +231,3 @@ +std::stable_sort(Symbols.begin(), Symbols.end(), + [&](JsImportedSymbol LHS, JsImportedSymbol RHS) { + return LHS.Symbol < RHS.Symbol; I think it's safe to pass the symbols as const reference here. http://reviews.llvm.org/D20798 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r253909 - Make clang_Cursor_getMangling not mangle if the declaration isn't mangled
Burt Wesarg points out on cfe-dev that this commit message doesn't match the patch (nor the description provided in the code review thread that lead to this commit) - this one might be worth reverting and recommitting with a more accurate commit message (I don't usually suggest this for most commits that are missing a commit message, but this one is actively misleading so might be trickier when people are doing archaeology)? On Mon, Nov 23, 2015 at 11:56 AM, Ehsan Akhgari via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: ehsan > Date: Mon Nov 23 13:56:46 2015 > New Revision: 253909 > > URL: http://llvm.org/viewvc/llvm-project?rev=253909&view=rev > Log: > Make clang_Cursor_getMangling not mangle if the declaration isn't mangled > > Right now clang_Cursor_getMangling will attempt to mangle any > declaration, even if the declaration isn't mangled (extern C). This > results in a partially mangled name which isn't useful for much. This > patch makes clang_Cursor_getMangling return an empty string if the > declaration isn't mangled. > > Patch by Michael Wu . > > Added: > cfe/trunk/test/Index/symbol-visibility.c > Modified: > cfe/trunk/include/clang-c/Index.h > cfe/trunk/tools/c-index-test/c-index-test.c > cfe/trunk/tools/libclang/CIndex.cpp > cfe/trunk/tools/libclang/libclang.exports > > Modified: cfe/trunk/include/clang-c/Index.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=253909&r1=253908&r2=253909&view=diff > > == > --- cfe/trunk/include/clang-c/Index.h (original) > +++ cfe/trunk/include/clang-c/Index.h Mon Nov 23 13:56:46 2015 > @@ -2461,6 +2461,32 @@ enum CXLinkageKind { > CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor); > > /** > + * \brief Describe the visibility of the entity referred to by a cursor. > + * > + * This returns the default visibility if not explicitly specified by > + * a visibility attribute. The default visibility may be changed by > + * commandline arguments. > + * > + * \param cursor The cursor to query. > + * > + * \returns The visibility of the cursor. > + */ > +enum CXVisibilityKind { > + /** \brief This value indicates that no visibility information is > available > + * for a provided CXCursor. */ > + CXVisibility_Invalid, > + > + /** \brief Symbol not seen by the linker. */ > + CXVisibility_Hidden, > + /** \brief Symbol seen by the linker but resolves to a symbol inside > this object. */ > + CXVisibility_Protected, > + /** \brief Symbol seen by the linker and acts like a normal symbol. */ > + CXVisibility_Default, > +}; > + > +CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor > cursor); > + > +/** > * \brief Determine the availability of the entity that this cursor > refers to, > * taking the current target platform into account. > * > > Added: cfe/trunk/test/Index/symbol-visibility.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/symbol-visibility.c?rev=253909&view=auto > > == > --- cfe/trunk/test/Index/symbol-visibility.c (added) > +++ cfe/trunk/test/Index/symbol-visibility.c Mon Nov 23 13:56:46 2015 > @@ -0,0 +1,7 @@ > +// RUN: c-index-test -test-print-visibility %s | FileCheck %s > + > +__attribute__ ((visibility ("default"))) void foo1(); > +__attribute__ ((visibility ("hidden"))) void foo2(); > + > +// CHECK: FunctionDecl=foo1:3:47visibility=Default > +// CHECK: FunctionDecl=foo2:4:46visibility=Hidden > > Modified: cfe/trunk/tools/c-index-test/c-index-test.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=253909&r1=253908&r2=253909&view=diff > > == > --- cfe/trunk/tools/c-index-test/c-index-test.c (original) > +++ cfe/trunk/tools/c-index-test/c-index-test.c Mon Nov 23 13:56:46 2015 > @@ -1248,6 +1248,32 @@ static enum CXChildVisitResult PrintLink > } > > > > /**/ > +/* Visibility testing. > */ > > +/**/ > + > +static enum CXChildVisitResult PrintVisibility(CXCursor cursor, CXCursor > p, > + CXClientData d) { > + const char *visibility = 0; > + > + if (clang_isInvalid(clang_getCursorKind(cursor))) > +return CXChildVisit_Recurse; > + > + switch (clang_getCursorVisibility(cursor)) { > +case CXVisibility_Invalid: break; > +case CXVisibility_Hidden: visibility = "Hidden"; break; > +case CXVisibility_Protected: visibility = "Protected"; break; > +case CXVisibility_Default: visibility = "Default"; break; > + } > + > + if (visibility) { > +PrintCursor(cursor, NULL); > +printf("visibility=%s\n", visibility); > + } > + > + re
r271280 - Avoid unused variable warning in release builds.
Author: d0k Date: Tue May 31 09:14:42 2016 New Revision: 271280 URL: http://llvm.org/viewvc/llvm-project?rev=271280&view=rev Log: Avoid unused variable warning in release builds. Modified: cfe/trunk/lib/Format/Format.cpp Modified: cfe/trunk/lib/Format/Format.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=271280&r1=271279&r2=271280&view=diff == --- cfe/trunk/lib/Format/Format.cpp (original) +++ cfe/trunk/lib/Format/Format.cpp Tue May 31 09:14:42 2016 @@ -1528,6 +1528,7 @@ fixCppIncludeInsertions(StringRef Code, bool Matched = IncludeRegex.match(IncludeDirective, &Matches); assert(Matched && "Header insertion replacement must have replacement text " "'#include ...'"); +(void)Matched; auto IncludeName = Matches[2]; int Category = Categories.getIncludePriority(IncludeName, /*CheckMainHeader=*/true); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r271282 - Issues for Oulu
Author: marshall Date: Tue May 31 09:29:38 2016 New Revision: 271282 URL: http://llvm.org/viewvc/llvm-project?rev=271282&view=rev Log: Issues for Oulu Modified: libcxx/trunk/www/upcoming_meeting.html Modified: libcxx/trunk/www/upcoming_meeting.html URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=271282&r1=271281&r2=271282&view=diff == --- libcxx/trunk/www/upcoming_meeting.html (original) +++ libcxx/trunk/www/upcoming_meeting.html Tue May 31 09:29:38 2016 @@ -32,11 +32,11 @@ - libc++ Jacksonville Status + libc++ Oulu Status This is a temporary page; please check the c++1z status http://libcxx.llvm.org/cxx1z_status.html";>here - This page shows the status of the papers and issues that are expected to be adopted in Jacksonville. + This page shows the status of the papers and issues that are expected to be adopted in Oulu. The groups that have contributed papers: @@ -57,73 +57,81 @@ Library Working group Issues Status - http://cplusplus.github.io/LWG/lwg-defects.html#2192";>2192Validity and return type of std::abs(0u) is unclearJacksonville - http://cplusplus.github.io/LWG/lwg-defects.html#2253";>2253[arrays.ts] dynarray should state which container requirements aren't metJacksonvilleNothing to do - http://cplusplus.github.io/LWG/lwg-defects.html#2255";>2255[arrays.ts] dynarray constructor ambiguityJacksonvilleNothing to do - http://cplusplus.github.io/LWG/lwg-defects.html#2276";>2276Missing requirement on std::promise::set_exceptionJacksonville - http://cplusplus.github.io/LWG/lwg-defects.html#2450";>2450(greater|less|greater_equal|less_equal)do not yield a total order for pointersJacksonville - http://cplusplus.github.io/LWG/lwg-defects.html#2520";>2520N4089 broke initializing unique_ptr from a nullptrJacksonville - http://cplusplus.github.io/LWG/lwg-defects.html#2522";>2522[fund.ts.v2] Contradiction in set_default_resource specificationJacksonville - http://cplusplus.github.io/LWG/lwg-defects.html#2523";>2523std::promise synopsis shows two set_value_at_thread_exit()'s for no apparent reasonJacksonvilleComplete - http://cplusplus.github.io/LWG/lwg-defects.html#2537";>2537Constructors for priority_queue taking allocators should call make_heapJacksonville - http://cplusplus.github.io/LWG/lwg-defects.html#2539";>2539[fund.ts.v2] invocation_trait definition definition doesn't work for surrogate call functionsJacksonville - http://cplusplus.github.io/LWG/lwg-defects.html#2545";>2545Simplify wording for bind without explicitly specified return typeJacksonville - http://cplusplus.github.io/LWG/lwg-defects.html#2557";>2557Logical operator traits are broken in the zero-argument caseJacksonvilleComplete - http://cplusplus.github.io/LWG/lwg-defects.html#2558";>2558[fund.ts.v2] Logical operator traits are broken in the zero-argument caseJacksonvilleComplete - http://cplusplus.github.io/LWG/lwg-defects.html#2559";>2559Error in LWG 2234's resolutionJacksonvilleComplete - http://cplusplus.github.io/LWG/lwg-defects.html#2560";>2560is_constructible underspecified when applied to a function typeJacksonvilleBroken in 3.6; See r261653. - http://cplusplus.github.io/LWG/lwg-defects.html#2565";>2565std::function's move constructor should guarantee nothrow for reference_wrappers and function pointersJacksonville - http://cplusplus.github.io/LWG/lwg-defects.html#2566";>2566Requirements on the first template parameter of container adaptorsJacksonville - http://cplusplus.github.io/LWG/lwg-defects.html#2571";>2571§[map.modifiers]/2 imposes nonsensical requirement on insert(InputIterator, InputIterator)JacksonvilleComplete - http://cplusplus.github.io/LWG/lwg-defects.html#2572";>2572The remarks for shared_ptr::operator* should apply to cv-qualified void as wellJacksonvilleComplete - http://cplusplus.github.io/LWG/lwg-defects.html#2574";>2574[fund.ts.v2] std::experimental::function::operator=(F&&) should be constrainedJacksonville - http://cplusplus.github.io/LWG/lwg-defects.html#2575";>2575[fund.ts.v2] experimental::function::assign should be removedJacksonville - http://cplusplus.github.io/LWG/lwg-defects.html#2576";>2576istream_iterator and ostream_iterator should use std::addressofJacksonvillePatch done; needs tests - http://cplusplus.github.io/LWG/lwg-defects.html#2577";>2577{shared,unique}_lock should use std::addressofJacksonville - http://cplusplus.github.io/LWG/lwg-defects.html#2579";>2579Inconsistency wrt Allocators in basic_string assignment vs. basic_string::assignJacksonvillePatch Ready - http://cplusplus.github.io/LWG/lwg-defects.html#2581";>2581Specialization of variable templates should be prohibitedJacksonvilleComplete - http://cplusplu
Re: [PATCH] D20814: [include-fixer] Rank symbols based on the number of occurrences we found while merging.
djasper accepted this revision. This revision is now accepted and ready to land. Comment at: include-fixer/SymbolIndexManager.cpp:25 @@ +24,3 @@ + // First collect occurrences per header file. + std::map HeaderPopularity; + for (const SymbolInfo &Symbol : Symbols) { Maybe use a DenseHashMap? Comment at: include-fixer/tool/ClangIncludeFixer.cpp:101 @@ -100,3 +100,3 @@ Split.second.split(CommaSplits, ","); - for (StringRef Header : CommaSplits) + for (const StringRef &Header : CommaSplits) Symbols.push_back(find_all_symbols::SymbolInfo( Can you please write a regular for loop with index instead? Comment at: include-fixer/tool/ClangIncludeFixer.cpp:105 @@ -104,3 +104,3 @@ find_all_symbols::SymbolInfo::SymbolKind::Unknown, Header.trim(), 1, -{})); +{}, /*NumOccurrences=*/CommaSplits.end() - &Header)); } Add a comment that you are assigning fake occurrences to keep the existing test logic (with the first include being the most preferable). http://reviews.llvm.org/D20814 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20249: [OpenCL] Hierarchical/dynamic parallelism - enqueue kernel in OpenCL 2.0
bader added a comment. Sorry for the delay. Is this code valid: clk_event_t e1, e2, e3; clk_event_t events[] = {e1, e2}; enqueue_kernel(get_default_queue(), 0, get_ndrange(), 2, events, &e3, ...); With this patch clang rejects it with an error: 'illegal call to enqueue_kernel, expected 'clk_event_t *' argument type' C rules allows implicit conversion of to pointer by taking address of the first element of the array. Comment at: lib/Sema/SemaChecking.cpp:154 @@ +153,3 @@ + unsigned NumNonVarArgs) { + const BlockPointerType *BPT = cast(BlockArg->getType()); + unsigned NumBlockParams = Here block type must be canonical too. http://reviews.llvm.org/D20249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r271283 - [include-fixer] Rank symbols based on the number of occurrences we found while merging.
Author: d0k Date: Tue May 31 09:33:28 2016 New Revision: 271283 URL: http://llvm.org/viewvc/llvm-project?rev=271283&view=rev Log: [include-fixer] Rank symbols based on the number of occurrences we found while merging. This sorts based on the popularity of the header, not the symbol. If there are mutliple matching symbols in one header we take the maximum popularity for that header and deduplicate. If we know nothing we sort lexicographically based on the header path. Differential Revision: http://reviews.llvm.org/D20814 Added: clang-tools-extra/trunk/test/include-fixer/ranking.cpp Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp?rev=271283&r1=271282&r2=271283&view=diff == --- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp (original) +++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp Tue May 31 09:33:28 2016 @@ -17,6 +17,37 @@ namespace clang { namespace include_fixer { +using clang::find_all_symbols::SymbolInfo; + +/// Sorts and uniques SymbolInfos based on the popularity info in SymbolInfo. +static void rankByPopularity(std::vector &Symbols) { + // First collect occurrences per header file. + std::map HeaderPopularity; + for (const SymbolInfo &Symbol : Symbols) { +unsigned &Popularity = HeaderPopularity[Symbol.getFilePath()]; +Popularity = std::max(Popularity, Symbol.getNumOccurrences()); + } + + // Sort by the gathered popularities. Use file name as a tie breaker so we can + // deduplicate. + std::sort(Symbols.begin(), Symbols.end(), +[&](const SymbolInfo &A, const SymbolInfo &B) { + auto APop = HeaderPopularity[A.getFilePath()]; + auto BPop = HeaderPopularity[B.getFilePath()]; + if (APop != BPop) +return APop > BPop; + return A.getFilePath() < B.getFilePath(); +}); + + // Deduplicate based on the file name. They will have the same popularity and + // we don't want to suggest the same header twice. + Symbols.erase(std::unique(Symbols.begin(), Symbols.end(), +[](const SymbolInfo &A, const SymbolInfo &B) { + return A.getFilePath() == B.getFilePath(); +}), +Symbols.end()); +} + std::vector SymbolIndexManager::search(llvm::StringRef Identifier) const { // The identifier may be fully qualified, so split it and get all the context @@ -45,6 +76,8 @@ SymbolIndexManager::search(llvm::StringR DEBUG(llvm::dbgs() << "Searching " << Names.back() << "... got " << Symbols.size() << " results...\n"); +rankByPopularity(Symbols); + for (const auto &Symbol : Symbols) { // Match the identifier name without qualifier. if (Symbol.getName() == Names.back()) { Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp?rev=271283&r1=271282&r2=271283&view=diff == --- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp (original) +++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Tue May 31 09:33:28 2016 @@ -98,11 +98,11 @@ createSymbolIndexManager(StringRef FileP std::vector Headers; SmallVector CommaSplits; Split.second.split(CommaSplits, ","); - for (StringRef Header : CommaSplits) + for (size_t I = 0, E = CommaSplits.size(); I != E; ++I) Symbols.push_back(find_all_symbols::SymbolInfo( Split.first.trim(), -find_all_symbols::SymbolInfo::SymbolKind::Unknown, Header.trim(), 1, -{})); +find_all_symbols::SymbolInfo::SymbolKind::Unknown, +CommaSplits[I].trim(), 1, {}, /*NumOccurrences=*/E - I)); } SymbolIndexMgr->addSymbolIndex( llvm::make_unique(Symbols)); Modified: clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml?rev=271283&r1=271282&r2=271283&view=diff == --- clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml (original) +++ clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml Tue May 31 09:33:28 2016 @@ -22,3 +22,24 @@ LineNumber: 1 Type:Class NumOccurrences: 1 ... +Name: bar +Contexts: + - ContextTyp
Re: [PATCH] D20814: [include-fixer] Rank symbols based on the number of occurrences we found while merging.
This revision was automatically updated to reflect the committed changes. Closed by commit rL271283: [include-fixer] Rank symbols based on the number of occurrences we found… (authored by d0k). Changed prior to commit: http://reviews.llvm.org/D20814?vs=59062&id=59065#toc Repository: rL LLVM http://reviews.llvm.org/D20814 Files: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml clang-tools-extra/trunk/test/include-fixer/ranking.cpp Index: clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml === --- clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml +++ clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml @@ -22,3 +22,24 @@ Type:Class NumOccurrences: 1 ... +Name: bar +Contexts: + - ContextType: Namespace +ContextName: a + - ContextType: Namespace +ContextName: b +FilePath:../include/bar.h +LineNumber: 2 +Type:Class +NumOccurrences: 3 +... +Name: bar +Contexts: + - ContextType: Namespace +ContextName: a + - ContextType: Namespace +ContextName: b +FilePath:../include/zbar.h +LineNumber: 1 +Type:Class +NumOccurrences: 3 Index: clang-tools-extra/trunk/test/include-fixer/ranking.cpp === --- clang-tools-extra/trunk/test/include-fixer/ranking.cpp +++ clang-tools-extra/trunk/test/include-fixer/ranking.cpp @@ -0,0 +1,6 @@ +// RUN: clang-include-fixer -db=yaml -input=%S/Inputs/fake_yaml_db.yaml -output-headers %s -- | FileCheck %s -implicit-check-not=.h + +// CHECK: "../include/bar.h" +// CHECK-NEXT: "../include/zbar.h" + +bar b; Index: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp === --- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp +++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp @@ -98,11 +98,11 @@ std::vector Headers; SmallVector CommaSplits; Split.second.split(CommaSplits, ","); - for (StringRef Header : CommaSplits) + for (size_t I = 0, E = CommaSplits.size(); I != E; ++I) Symbols.push_back(find_all_symbols::SymbolInfo( Split.first.trim(), -find_all_symbols::SymbolInfo::SymbolKind::Unknown, Header.trim(), 1, -{})); +find_all_symbols::SymbolInfo::SymbolKind::Unknown, +CommaSplits[I].trim(), 1, {}, /*NumOccurrences=*/E - I)); } SymbolIndexMgr->addSymbolIndex( llvm::make_unique(Symbols)); Index: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp === --- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp +++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp @@ -17,6 +17,37 @@ namespace clang { namespace include_fixer { +using clang::find_all_symbols::SymbolInfo; + +/// Sorts and uniques SymbolInfos based on the popularity info in SymbolInfo. +static void rankByPopularity(std::vector &Symbols) { + // First collect occurrences per header file. + std::map HeaderPopularity; + for (const SymbolInfo &Symbol : Symbols) { +unsigned &Popularity = HeaderPopularity[Symbol.getFilePath()]; +Popularity = std::max(Popularity, Symbol.getNumOccurrences()); + } + + // Sort by the gathered popularities. Use file name as a tie breaker so we can + // deduplicate. + std::sort(Symbols.begin(), Symbols.end(), +[&](const SymbolInfo &A, const SymbolInfo &B) { + auto APop = HeaderPopularity[A.getFilePath()]; + auto BPop = HeaderPopularity[B.getFilePath()]; + if (APop != BPop) +return APop > BPop; + return A.getFilePath() < B.getFilePath(); +}); + + // Deduplicate based on the file name. They will have the same popularity and + // we don't want to suggest the same header twice. + Symbols.erase(std::unique(Symbols.begin(), Symbols.end(), +[](const SymbolInfo &A, const SymbolInfo &B) { + return A.getFilePath() == B.getFilePath(); +}), +Symbols.end()); +} + std::vector SymbolIndexManager::search(llvm::StringRef Identifier) const { // The identifier may be fully qualified, so split it and get all the context @@ -45,6 +76,8 @@ DEBUG(llvm::dbgs() << "Searching " << Names.back() << "... got " << Symbols.size() << " results...\n"); +rankByPopularity(Symbols); + for (const auto &Symbol : Symbols) { // Match the identifier name without qualifier. if (Symbol.getName() == Names.back()) {
[clang-tools-extra] r271284 - [include-fixer] Use a DenseMap, order doesn't matter here.
Author: d0k Date: Tue May 31 09:37:10 2016 New Revision: 271284 URL: http://llvm.org/viewvc/llvm-project?rev=271284&view=rev Log: [include-fixer] Use a DenseMap, order doesn't matter here. Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp?rev=271284&r1=271283&r2=271284&view=diff == --- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp (original) +++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp Tue May 31 09:37:10 2016 @@ -9,6 +9,7 @@ #include "SymbolIndexManager.h" #include "find-all-symbols/SymbolInfo.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Debug.h" @@ -22,7 +23,7 @@ using clang::find_all_symbols::SymbolInf /// Sorts and uniques SymbolInfos based on the popularity info in SymbolInfo. static void rankByPopularity(std::vector &Symbols) { // First collect occurrences per header file. - std::map HeaderPopularity; + llvm::DenseMap HeaderPopularity; for (const SymbolInfo &Symbol : Symbols) { unsigned &Popularity = HeaderPopularity[Symbol.getFilePath()]; Popularity = std::max(Popularity, Symbol.getNumOccurrences()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r271285 - [include-fixer] Inline trivial methods.
Author: d0k Date: Tue May 31 09:40:10 2016 New Revision: 271285 URL: http://llvm.org/viewvc/llvm-project?rev=271285&view=rev Log: [include-fixer] Inline trivial methods. Putting them into the .cpp file is both more verbose and slower than having them in the header. No functional change intended. Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp?rev=271285&r1=271284&r2=271285&view=diff == --- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp (original) +++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp Tue May 31 09:40:10 2016 @@ -78,20 +78,6 @@ SymbolInfo::SymbolInfo(llvm::StringRef N : Name(Name), Type(Type), FilePath(FilePath), Contexts(Contexts), LineNumber(LineNumber), NumOccurrences(NumOccurrences) {} -llvm::StringRef SymbolInfo::getName() const { return Name; } - -SymbolKind SymbolInfo::getSymbolKind() const { return Type; } - -llvm::StringRef SymbolInfo::getFilePath() const { return FilePath; } - -const std::vector &SymbolInfo::getContexts() const { - return Contexts; -} - -int SymbolInfo::getLineNumber() const { return LineNumber; } - -unsigned SymbolInfo::getNumOccurrences() const { return NumOccurrences; } - bool SymbolInfo::operator==(const SymbolInfo &Symbol) const { return std::tie(Name, Type, FilePath, LineNumber, Contexts) == std::tie(Symbol.Name, Symbol.Type, Symbol.FilePath, Symbol.LineNumber, Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h?rev=271285&r1=271284&r2=271285&view=diff == --- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h (original) +++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h Tue May 31 09:40:10 2016 @@ -55,22 +55,24 @@ public: unsigned NumOccurrences = 0); /// \brief Get symbol name. - llvm::StringRef getName() const; + llvm::StringRef getName() const { return Name; } /// \brief Get symbol type. - SymbolKind getSymbolKind() const; + SymbolKind getSymbolKind() const { return Type; } /// \brief Get a relative file path where symbol comes from. - llvm::StringRef getFilePath() const; + llvm::StringRef getFilePath() const { return FilePath; } /// \brief Get symbol contexts. - const std::vector &getContexts() const; + const std::vector &getContexts() const { +return Contexts; + } /// \brief Get a 1-based line number of the symbol's declaration. - int getLineNumber() const; + int getLineNumber() const { return LineNumber; } /// \brief The number of times this symbol was found during an indexing run. - unsigned getNumOccurrences() const; + unsigned getNumOccurrences() const { return NumOccurrences; } bool operator<(const SymbolInfo &Symbol) const; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20561: Warn when taking address of packed member
rogfer01 marked 3 inline comments as done. Comment at: lib/Sema/SemaExpr.cpp:10527 @@ +10526,3 @@ +if (RD->hasAttr() || +ME->getMemberDecl()->hasAttr()) { + Diag(OpLoc, diag::warn_taking_address_of_packed_member) aaron.ballman wrote: > Ah, I forgot that the attribute also affected the alignment of the struct > itself. Amending my false-positive idea, the following should be fine, > shouldn't it?: > ``` > struct __attribute__((packed)) S { > char c; > int i; > char c2; > }; > > void f(S s) { > char *cp = &s.c; > char *cp2 = &s.c2; > } > ``` > I think perhaps we should not diagnose if the member's type also has a > one-byte alignment (or, for instance, uses alignas(1) to achieve that). What > do you think? Yes. I like the idea since the packed attribute has no effect on already 1-aligned data (like char). But note that C++11 does not allow reducing the alignment through `alignas`. http://reviews.llvm.org/D20561 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20816: [include-fixer] use clang-format cleaner to insert header.
bkramer accepted this revision. bkramer added a comment. This revision is now accepted and ready to land. Look at all this annoying preprocessor code going away! I love it. http://reviews.llvm.org/D20816 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r271287 - [include-fixer] use clang-format cleaner to insert header.
Author: ioeric Date: Tue May 31 09:48:45 2016 New Revision: 271287 URL: http://llvm.org/viewvc/llvm-project?rev=271287&view=rev Log: [include-fixer] use clang-format cleaner to insert header. Summary: clang-format's cleanupAroundReplacements() takes care of header insertions. Reviewers: bkramer Subscribers: cfe-commits, hokein Differential Revision: http://reviews.llvm.org/D20816 Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp clang-tools-extra/trunk/include-fixer/IncludeFixer.h clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=271287&r1=271286&r2=271287&view=diff == --- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original) +++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Tue May 31 09:48:45 2016 @@ -28,33 +28,6 @@ namespace { class Action; -class PreprocessorHooks : public clang::PPCallbacks { -public: - explicit PreprocessorHooks(Action *EnclosingPass) - : EnclosingPass(EnclosingPass), TrackedFile(nullptr) {} - - void FileChanged(clang::SourceLocation loc, - clang::PPCallbacks::FileChangeReason reason, - clang::SrcMgr::CharacteristicKind file_type, - clang::FileID prev_fid) override; - - void InclusionDirective(clang::SourceLocation HashLocation, - const clang::Token &IncludeToken, - llvm::StringRef FileName, bool IsAngled, - clang::CharSourceRange FileNameRange, - const clang::FileEntry *IncludeFile, - llvm::StringRef SearchPath, - llvm::StringRef relative_path, - const clang::Module *imported) override; - -private: - /// The current Action. - Action *EnclosingPass; - - /// The current FileEntry. - const clang::FileEntry *TrackedFile; -}; - /// Manages the parse, gathers include suggestions. class Action : public clang::ASTFrontendAction, public clang::ExternalSemaSource { @@ -67,8 +40,6 @@ public: CreateASTConsumer(clang::CompilerInstance &Compiler, StringRef InFile) override { Filename = InFile; -Compiler.getPreprocessor().addPPCallbacks( -llvm::make_unique(this)); return llvm::make_unique(); } @@ -195,22 +166,6 @@ public: StringRef filename() const { return Filename; } - /// Called for each include file we discover is in the file. - /// \param SourceManager the active SourceManager - /// \param canonical_path the canonical path to the include file - /// \param uttered_path the path as it appeared in the program - /// \param IsAngled whether angle brackets were used - /// \param HashLocation the source location of the include's \# - /// \param EndLocation the source location following the include - void NextInclude(clang::SourceManager *SourceManager, - llvm::StringRef canonical_path, llvm::StringRef uttered_path, - bool IsAngled, clang::SourceLocation HashLocation, - clang::SourceLocation EndLocation) { -unsigned Offset = SourceManager->getFileOffset(HashLocation); -if (FirstIncludeOffset == -1U) - FirstIncludeOffset = Offset; - } - /// Get the minimal include for a given path. std::string minimizeInclude(StringRef Include, const clang::SourceManager &SourceManager, @@ -244,7 +199,6 @@ public: return FixerContext; FixerContext.SymbolIdentifer = QuerySymbol; -FixerContext.FirstIncludeOffset = FirstIncludeOffset; for (const auto &Header : SymbolQueryResults) FixerContext.Headers.push_back( minimizeInclude(Header, SourceManager, HeaderSearch)); @@ -252,9 +206,6 @@ public: return FixerContext; } - /// Sets the location at the very top of the file. - void setFileBegin(clang::SourceLocation Location) { FileBegin = Location; } - private: /// Query the database for a given identifier. bool query(StringRef Query, SourceLocation Loc) { @@ -280,13 +231,6 @@ private: /// The absolute path to the file being processed. std::string Filename; - /// The location of the beginning of the tracked file. - clang::SourceLocation FileBegin; - - /// The offset of the last include in the original source file. This will - /// be used as the insertion point for new include directives. - unsigned FirstIncludeOffset = -1U; - /// The symbol being queried. std::string QuerySymbol; @@ -298,44 +242,6 @@ private: bool MinimizeIncludePaths = true; }; -void PreprocessorHooks::Fi
Re: [PATCH] D20816: [include-fixer] use clang-format cleaner to insert header.
This revision was automatically updated to reflect the committed changes. Closed by commit rL271287: [include-fixer] use clang-format cleaner to insert header. (authored by ioeric). Changed prior to commit: http://reviews.llvm.org/D20816?vs=59067&id=59069#toc Repository: rL LLVM http://reviews.llvm.org/D20816 Files: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp clang-tools-extra/trunk/include-fixer/IncludeFixer.h clang-tools-extra/trunk/include-fixer/IncludeFixerContext.h clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Index: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp === --- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp +++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp @@ -78,21 +78,22 @@ return Code; tooling::Replacements Replacements = clang::include_fixer::createInsertHeaderReplacements( - Code, "input.cc", FixerContext.Headers.front(), - FixerContext.FirstIncludeOffset); + Code, "input.cc", FixerContext.Headers.front()); clang::RewriterTestContext Context; clang::FileID ID = Context.createInMemoryFile("input.cc", Code); clang::tooling::applyAllReplacements(Replacements, Context.Rewrite); return Context.getRewrittenText(ID); } TEST(IncludeFixer, Typo) { - EXPECT_EQ("#include \n\nstd::string foo;\n", + EXPECT_EQ("#include \nstd::string foo;\n", runIncludeFixer("std::string foo;\n")); + // FIXME: the current version of include-fixer does not get this test case + // right - header should be inserted before definition. EXPECT_EQ( - "// comment\n#include \"foo.h\"\n#include \nstd::string foo;\n" - "#include \"dir/bar.h\"\n", + "// comment\n#include \"foo.h\"\nstd::string foo;\n" + "#include \"dir/bar.h\"\n#include \n", runIncludeFixer("// comment\n#include \"foo.h\"\nstd::string foo;\n" "#include \"dir/bar.h\"\n")); @@ -106,11 +107,11 @@ // string without "std::" can also be fixed since fixed db results go through // SymbolIndexManager, and SymbolIndexManager matches unqualified identifiers // too. - EXPECT_EQ("#include \n\nstring foo;\n", + EXPECT_EQ("#include \nstring foo;\n", runIncludeFixer("string foo;\n")); // Fully qualified name. - EXPECT_EQ("#include \n\n::std::string foo;\n", + EXPECT_EQ("#include \n::std::string foo;\n", runIncludeFixer("::std::string foo;\n")); // Should not match std::string. EXPECT_EQ("::string foo;\n", runIncludeFixer("::string foo;\n")); @@ -126,24 +127,24 @@ TEST(IncludeFixer, MinimizeInclude) { std::vector IncludePath = {"-Idir/"}; - EXPECT_EQ("#include \"otherdir/qux.h\"\n\na::b::foo bar;\n", + EXPECT_EQ("#include \"otherdir/qux.h\"\na::b::foo bar;\n", runIncludeFixer("a::b::foo bar;\n", IncludePath)); IncludePath = {"-isystemdir"}; - EXPECT_EQ("#include \n\na::b::foo bar;\n", + EXPECT_EQ("#include \na::b::foo bar;\n", runIncludeFixer("a::b::foo bar;\n", IncludePath)); IncludePath = {"-iquotedir"}; - EXPECT_EQ("#include \"otherdir/qux.h\"\n\na::b::foo bar;\n", + EXPECT_EQ("#include \"otherdir/qux.h\"\na::b::foo bar;\n", runIncludeFixer("a::b::foo bar;\n", IncludePath)); IncludePath = {"-Idir", "-Idir/otherdir"}; - EXPECT_EQ("#include \"qux.h\"\n\na::b::foo bar;\n", + EXPECT_EQ("#include \"qux.h\"\na::b::foo bar;\n", runIncludeFixer("a::b::foo bar;\n", IncludePath)); } TEST(IncludeFixer, NestedName) { - EXPECT_EQ("#include \"dir/otherdir/qux.h\"\n\n" + EXPECT_EQ("#include \"dir/otherdir/qux.h\"\n" "int x = a::b::foo(0);\n", runIncludeFixer("int x = a::b::foo(0);\n")); @@ -153,33 +154,35 @@ EXPECT_EQ("#define FOO(x) a::##x\nint x = FOO(b::foo);\n", runIncludeFixer("#define FOO(x) a::##x\nint x = FOO(b::foo);\n")); - EXPECT_EQ("#include \"dir/otherdir/qux.h\"\n\n" -"namespace a {}\nint a = a::b::foo(0);\n", + // The empty namespace is cleaned up by clang-format after include-fixer + // finishes. + EXPECT_EQ("#include \"dir/otherdir/qux.h\"\n" +"\nint a = a::b::foo(0);\n", runIncludeFixer("namespace a {}\nint a = a::b::foo(0);\n")); } TEST(IncludeFixer, MultipleMissingSymbols) { - EXPECT_EQ("#include \n\nstd::string bar;\nstd::sting foo;\n", + EXPECT_EQ("#include \nstd::string bar;\nstd::sting foo;\n", runIncludeFixer("std::string bar;\nstd::sting foo;\n")); } TEST(IncludeFixer, ScopedNamespaceSymbols) { - EXPECT_EQ("#include \"bar.h\"\n\nnamespace a {\nb::bar b;\n}", + EXPECT_EQ("#include \"bar.h\"\nnamespace a {\nb::bar b;\n}", runIncludeFixer("namespace a {\nb::bar b;\n}")); - EXPECT_EQ("#include \"bar.h\"\n\nnamespace A {\na::b::bar b;\n}
Re: [PATCH] D20277: [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.
flx added a comment. In http://reviews.llvm.org/D20277#444023, @Prazek wrote: > In http://reviews.llvm.org/D20277#436725, @flx wrote: > > > In http://reviews.llvm.org/D20277#436717, @Prazek wrote: > > > > > Cool check! Did you think about sugesting std::move for rvalue references > > > if they are used once? > > > > > > Thanks! I'm not sure this fits with what a user would expect from a check > > named "unnecessary-value-param" since in this case the parameter is not > > passed by value. Would a separate check make sense for this? > > > Consider changing the name :) When I was thinking about the check for rvalue > references, I wanted to name it "*-rvalue-ref-one-use". > If it covers values also, maybe "performance-move-single-used-variable" or > "performance-variable-one-use", or "performance-disposable-object" (If I > translated it correctly). > > In my opinion there is no need to have separate check to to this, because the > user would like to have both or none. Renaming the check is a breaking change since it affects user's configurations. I'm working in a code base that doesn't allow r-value references outside of move constructors and assignment, but if you'd like to add handing the r-value reference case, that'd be great! I agree that with this change it make sense to handle r-value references here too. http://reviews.llvm.org/D20277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20798: clang-format: [JS] Sort imported symbols.
mprobst marked 4 inline comments as done. mprobst added a comment. Done regarding the tests. We do have an unrelated issue with formatting `import {x as foo}`, will send a fix later. http://reviews.llvm.org/D20798 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20816: [include-fixer] use clang-format cleaner to insert header.
hokein added inline comments. Comment at: include-fixer/IncludeFixer.cpp:29 @@ -28,3 +28,3 @@ class Action; The forward declaration can be removed too. Repository: rL LLVM http://reviews.llvm.org/D20816 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20798: clang-format: [JS] Sort imported symbols.
mprobst updated this revision to Diff 59070. mprobst added a comment. - multiline tests, review comments http://reviews.llvm.org/D20798 Files: lib/Format/Format.cpp lib/Format/SortJavaScriptImports.cpp unittests/Format/SortImportsTestJS.cpp Index: unittests/Format/SortImportsTestJS.cpp === --- unittests/Format/SortImportsTestJS.cpp +++ unittests/Format/SortImportsTestJS.cpp @@ -67,6 +67,21 @@ "let x = 1;"); } +TEST_F(SortImportsTestJS, WrappedImportStatements) { + verifySort("import {sym1, sym2} from 'a';\n" + "import {sym} from 'b';\n" + "\n" + "1;", + "import\n" + " {sym}\n" + " from 'b';\n" + "import {\n" + " sym1,\n" + " sym2\n" + "} from 'a';\n" + "1;"); +} + TEST_F(SortImportsTestJS, SeparateMainCodeBody) { verifySort("import {sym} from 'a';" "\n" @@ -101,6 +116,18 @@ "import {sym1 as alias1} from 'b';\n"); } +TEST_F(SortImportsTestJS, SortSymbols) { + verifySort("import {sym1, sym2 as a, sym3} from 'b';\n", + "import {sym2 as a, sym1, sym3} from 'b';\n"); + verifySort("import {sym1 /* important! */, /*!*/ sym2 as a} from 'b';\n", + "import {/*!*/ sym2 as a, sym1 /* important! */} from 'b';\n"); + verifySort("import {sym1, sym2} from 'b';\n", "import {\n" +" sym2 \n" +",\n" +" sym1 \n" +"} from 'b';\n"); +} + TEST_F(SortImportsTestJS, GroupImports) { verifySort("import {a} from 'absolute';\n" "\n" Index: lib/Format/SortJavaScriptImports.cpp === --- lib/Format/SortJavaScriptImports.cpp +++ lib/Format/SortJavaScriptImports.cpp @@ -25,6 +25,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Debug.h" +#include #include #define DEBUG_TYPE "format-formatter" @@ -40,6 +41,13 @@ struct JsImportedSymbol { StringRef Symbol; StringRef Alias; + SourceRange Range; + + bool operator==(const JsImportedSymbol &RHS) const { +// Ignore Range for comparison, it is only used to stitch code together, +// but imports at different code locations are still conceptually the same. +return Symbol == RHS.Symbol && Alias == RHS.Alias; + } }; // An ES6 module reference. @@ -139,23 +147,14 @@ [&](unsigned LHSI, unsigned RHSI) { return References[LHSI] < References[RHSI]; }); -// FIXME: Pull this into a common function. -bool OutOfOrder = false; -for (unsigned i = 0, e = Indices.size(); i != e; ++i) { - if (i != Indices[i]) { -OutOfOrder = true; -break; - } -} -if (!OutOfOrder) - return Result; +bool ReferencesInOrder = std::is_sorted(Indices.begin(), Indices.end()); -// Replace all existing import/export statements. std::string ReferencesText; +bool SymbolsInOrder = true; for (unsigned i = 0, e = Indices.size(); i != e; ++i) { JsModuleReference Reference = References[Indices[i]]; - StringRef ReferenceStmt = getSourceText(Reference.Range); - ReferencesText += ReferenceStmt; + if (appendReference(ReferencesText, Reference)) +SymbolsInOrder = false; if (i + 1 < e) { // Insert breaks between imports and exports. ReferencesText += "\n"; @@ -167,6 +166,10 @@ ReferencesText += "\n"; } } + +if (ReferencesInOrder && SymbolsInOrder) + return Result; + // Separate references from the main code body of the file. if (FirstNonImportLine && FirstNonImportLine->First->NewlinesBefore < 2) ReferencesText += "\n"; @@ -211,10 +214,45 @@ } StringRef getSourceText(SourceRange Range) { +return getSourceText(Range.getBegin(), Range.getEnd()); + } + + StringRef getSourceText(SourceLocation Begin, SourceLocation End) { const SourceManager &SM = Env.getSourceManager(); -return FileContents.substr(SM.getFileOffset(Range.getBegin()), - SM.getFileOffset(Range.getEnd()) - - SM.getFileOffset(Range.getBegin())); +return FileContents.substr(SM.getFileOffset(Begin), + SM.getFileOffset(End) - SM.getFileOffset(Begin)); + } + + // Appends ``Reference`` to ``Buffer``, returning true if text within the + // ``Reference`` changed (e.g. symbol order). + bool appendReference(std::string &Buffer, JsModuleReference &Reference) { +// Sort the individual symbols within the import. +// E.g. `import {b, a} from 'x';` -> `import {a, b} from 'x';` +SmallVector Symbols = Re
Re: [PATCH] D20798: clang-format: [JS] Sort imported symbols.
mprobst added a comment. Done regarding the tests. We do have an unrelated issue with formatting `import {x as foo}`, will send a fix later. http://reviews.llvm.org/D20798 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D14326: ASTImporter: expressions, pt.2
a.sidorin added a comment. Ping? http://reviews.llvm.org/D14326 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20277: [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.
sbenza added inline comments. Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:34 @@ -29,1 +33,3 @@ +template bool isSetDifferenceEmpty(const S &S1, const S &S2) { + for (const auto &E : S1) isSubset? Comment at: clang-tidy/utils/Matchers.cpp:16 @@ +15,3 @@ + +ast_matchers::TypeMatcher isConstReference() { + return ast_matchers::referenceType(ast_matchers::pointee( Prefer AST_MATCHER_FUNCTION. That macro will make sure to use a singleton matcher instead, since it has no arguments. Comment at: clang-tidy/utils/Matchers.h:44 @@ +43,3 @@ +// Returns QualType matcher for references to const. +ast_matchers::TypeMatcher isConstReference(); + isReferenceToConst http://reviews.llvm.org/D20277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D20817: clang-format: [JS] no ASI on `import {x as\n y}`.
mprobst created this revision. mprobst added a reviewer: djasper. mprobst added a subscriber: cfe-commits. Herald added a subscriber: klimek. ASI did not handle the ES6 `as` operator correctly. http://reviews.llvm.org/D20817 Files: lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTestJS.cpp Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -1010,6 +1010,9 @@ "} from 'some/module.js';"); verifyFormat("import {X, Y,} from 'some/module.js';"); verifyFormat("import {X as myLocalX, Y as myLocalY} from 'some/module.js';"); + // Ensure Automatic Semicolon Insertion does not break on "as\n". + verifyFormat("import {X as myX} from 'm';", "import {X as\n" + " myX} from 'm';"); verifyFormat("import * as lib from 'some/module.js';"); verifyFormat("var x = {import: 1};\nx.import = 2;"); Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -668,11 +668,11 @@ // FIXME: This returns true for C/C++ keywords like 'struct'. return FormatTok->is(tok::identifier) && (FormatTok->Tok.getIdentifierInfo() == nullptr || - !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, Keywords.kw_async, - Keywords.kw_await, Keywords.kw_yield, - Keywords.kw_finally, Keywords.kw_function, - Keywords.kw_import, Keywords.kw_is, - Keywords.kw_let, Keywords.kw_var, + !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, Keywords.kw_as, + Keywords.kw_async, Keywords.kw_await, + Keywords.kw_yield, Keywords.kw_finally, + Keywords.kw_function, Keywords.kw_import, + Keywords.kw_is, Keywords.kw_let, Keywords.kw_var, Keywords.kw_abstract, Keywords.kw_extends, Keywords.kw_implements, Keywords.kw_instanceof, Keywords.kw_interface, Keywords.kw_throws)); Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -1010,6 +1010,9 @@ "} from 'some/module.js';"); verifyFormat("import {X, Y,} from 'some/module.js';"); verifyFormat("import {X as myLocalX, Y as myLocalY} from 'some/module.js';"); + // Ensure Automatic Semicolon Insertion does not break on "as\n". + verifyFormat("import {X as myX} from 'm';", "import {X as\n" + " myX} from 'm';"); verifyFormat("import * as lib from 'some/module.js';"); verifyFormat("var x = {import: 1};\nx.import = 2;"); Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -668,11 +668,11 @@ // FIXME: This returns true for C/C++ keywords like 'struct'. return FormatTok->is(tok::identifier) && (FormatTok->Tok.getIdentifierInfo() == nullptr || - !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, Keywords.kw_async, - Keywords.kw_await, Keywords.kw_yield, - Keywords.kw_finally, Keywords.kw_function, - Keywords.kw_import, Keywords.kw_is, - Keywords.kw_let, Keywords.kw_var, + !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, Keywords.kw_as, + Keywords.kw_async, Keywords.kw_await, + Keywords.kw_yield, Keywords.kw_finally, + Keywords.kw_function, Keywords.kw_import, + Keywords.kw_is, Keywords.kw_let, Keywords.kw_var, Keywords.kw_abstract, Keywords.kw_extends, Keywords.kw_implements, Keywords.kw_instanceof, Keywords.kw_interface, Keywords.kw_throws)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r271288 - [ASTMatchers] Breaking change of `has` matcher
Author: prazek Date: Tue May 31 10:25:05 2016 New Revision: 271288 URL: http://llvm.org/viewvc/llvm-project?rev=271288&view=rev Log: [ASTMatchers] Breaking change of `has` matcher has matcher can now match to implicit and paren casts http://reviews.llvm.org/D20801 Modified: cfe/trunk/docs/ReleaseNotes.rst cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h cfe/trunk/include/clang/CMakeLists.txt cfe/trunk/unittests/AST/ASTImporterTest.cpp cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Modified: cfe/trunk/docs/ReleaseNotes.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=271288&r1=271287&r2=271288&view=diff == --- cfe/trunk/docs/ReleaseNotes.rst (original) +++ cfe/trunk/docs/ReleaseNotes.rst Tue May 31 10:25:05 2016 @@ -185,11 +185,13 @@ this section should help get you past th AST Matchers -- hasAnyArgument: Matcher no longer ignores parentheses and implicit casts on - the argument before applying the inner matcher. The fix was done to allow for - greater control by the user. In all existing checkers that use this matcher - all instances of code ``hasAnyArgument()`` must be changed to - ``hasAnyArgument(ignoringParenImpCasts())``. +- has and hasAnyArgument: Matchers no longer ignores parentheses and implicit + casts on the argument before applying the inner matcher. The fix was done to + allow for greater control by the user. In all existing checkers that use this + matcher all instances of code ``hasAnyArgument()`` or + ``has()`` must be changed to + ``hasAnyArgument(ignoringParenImpCasts())`` or + ``has(ignoringParenImpCasts())``. ... Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=271288&r1=271287&r2=271288&view=diff == --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original) +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Tue May 31 10:25:05 2016 @@ -2169,6 +2169,10 @@ AST_MATCHER_P(CXXRecordDecl, hasMethod, /// ChildT must be an AST base type. /// /// Usable as: Any Matcher +/// Note that has is direct matcher, so it also matches things like implicit +/// casts and paren casts. If you are matching with expr then you should +/// probably consider using ignoringParenImpCasts like: +/// has(ignoringParenImpCasts(expr())). const internal::ArgumentAdaptingMatcherFunc LLVM_ATTRIBUTE_UNUSED has = {}; Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=271288&r1=271287&r2=271288&view=diff == --- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original) +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Tue May 31 10:25:05 2016 @@ -1165,8 +1165,6 @@ public: /// ChildT must be an AST base type. template class HasMatcher : public WrapperMatcherInterface { - static_assert(IsBaseType::value, -"has only accepts base type matcher"); public: explicit HasMatcher(const Matcher &ChildMatcher) @@ -1174,10 +1172,9 @@ public: bool matches(const T &Node, ASTMatchFinder *Finder, BoundNodesTreeBuilder *Builder) const override { -return Finder->matchesChildOf( -Node, this->InnerMatcher, Builder, -ASTMatchFinder::TK_IgnoreImplicitCastsAndParentheses, -ASTMatchFinder::BK_First); +return Finder->matchesChildOf(Node, this->InnerMatcher, Builder, + ASTMatchFinder::TK_AsIs, + ASTMatchFinder::BK_First); } }; Modified: cfe/trunk/include/clang/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CMakeLists.txt?rev=271288&r1=271287&r2=271288&view=diff == --- cfe/trunk/include/clang/CMakeLists.txt (original) +++ cfe/trunk/include/clang/CMakeLists.txt Tue May 31 10:25:05 2016 @@ -5,3 +5,4 @@ add_subdirectory(Parse) add_subdirectory(Sema) add_subdirectory(Serialization) add_subdirectory(StaticAnalyzer/Checkers) +add_subdirectory(ASTMatchers) Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=271288&r1=271287&r2=271288&view=diff == --- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original) +++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Tue May 31 10:25:05 2016 @@ -225,20 +225,14 @@ TEST(ImportExpr, ImportCXXThisExpr) { TEST(ImportExpr, ImportAtomicExpr) { Matc
[clang-tools-extra] r271289 - [ASTMatchers] Added ignoringParenImpCasts to has matchers
Author: prazek Date: Tue May 31 10:26:56 2016 New Revision: 271289 URL: http://llvm.org/viewvc/llvm-project?rev=271289&view=rev Log: [ASTMatchers] Added ignoringParenImpCasts to has matchers has matcher changed behaviour, and now it matches "as is" and doesn't skip implicit and paren casts http://reviews.llvm.org/D20801 Modified: clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/InaccurateEraseCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/IncorrectRoundings.cpp clang-tools-extra/trunk/clang-tidy/misc/InefficientAlgorithmCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/SizeofContainerCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/SizeofExpressionCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/SuspiciousMissingCommaCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/SuspiciousStringCompareCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/UnusedRAIICheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/UseBoolLiteralsCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.cpp?rev=271289&r1=271288&r2=271289&view=diff == --- clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/cert/ThrownExceptionTypeCheck.cpp Tue May 31 10:26:56 2016 @@ -23,10 +23,10 @@ void ThrownExceptionTypeCheck::registerM return; Finder->addMatcher( - cxxThrowExpr( - has(cxxConstructExpr(hasDeclaration(cxxConstructorDecl( - isCopyConstructor(), unless(isNoThrow() - .bind("expr"))), + cxxThrowExpr(has(ignoringParenImpCasts( + cxxConstructExpr(hasDeclaration(cxxConstructorDecl( + isCopyConstructor(), unless(isNoThrow() + .bind("expr", this); } Modified: clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp?rev=271289&r1=271288&r2=271289&view=diff == --- clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/misc/BoolPointerImplicitConversionCheck.cpp Tue May 31 10:26:56 2016 @@ -47,15 +47,18 @@ void BoolPointerImplicitConversionCheck: auto DeclRef = ignoringParenImpCasts(declRefExpr(to(equalsNode(D; if (!match(findAll( unaryOperator(hasOperatorName("*"), hasUnaryOperand(DeclRef))), - *If, *Result.Context).empty() || + *If, *Result.Context) + .empty() || !match(findAll(arraySubscriptExpr(hasBase(DeclRef))), *If, - *Result.Context).empty() || + *Result.Context) + .empty() || // FIXME: We should still warn if the paremater is implicitly converted to // bool. !match(findAll(callExpr(hasAnyArgument(ignoringParenImpCasts(DeclRef, *If, *Result.Context) .empty() || - !match(findAll(cxxDeleteExpr(has(expr(DeclRef, *If, *Result.Context) + !match(findAll(cxxDeleteExpr(has(ignoringParenImpCasts(expr(DeclRef), + *If, *Result.Context) .empty()) return; Modified: clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp?rev=271289&r1=271288&r2=271289&view=diff == --- clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/misc/DanglingHandleCheck.cpp Tue May 31 10:26:56 2016 @@ -103,15 +103,17 @@ void DanglingHandleCheck::regi
Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete
majnemer added inline comments. Comment at: src/experimental/operations.cpp:529 @@ +528,3 @@ + +if (::utimensat(AT_FDCWD, p.c_str(), tbuf, 0) == -1) { +m_ec = detail::capture_errno(); SUSv4 says: > The utime() function is marked obsolescent. However, `utimes` was made legacy in SUSv3 and removed from legacy in SUSv4 http://pubs.opengroup.org/onlinepubs/9699919799/functions/utimes.html http://reviews.llvm.org/D16948 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r271288 - [ASTMatchers] Breaking change of `has` matcher
This broke the build: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/36968/steps/cmake-configure/logs/stdio On 31 May 2016 at 08:25, Piotr Padlewski via cfe-commits wrote: > Author: prazek > Date: Tue May 31 10:25:05 2016 > New Revision: 271288 > > URL: http://llvm.org/viewvc/llvm-project?rev=271288&view=rev > Log: > [ASTMatchers] Breaking change of `has` matcher > > has matcher can now match to implicit and paren casts > > http://reviews.llvm.org/D20801 > > Modified: > cfe/trunk/docs/ReleaseNotes.rst > cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h > cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h > cfe/trunk/include/clang/CMakeLists.txt > cfe/trunk/unittests/AST/ASTImporterTest.cpp > cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp > > Modified: cfe/trunk/docs/ReleaseNotes.rst > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=271288&r1=271287&r2=271288&view=diff > == > --- cfe/trunk/docs/ReleaseNotes.rst (original) > +++ cfe/trunk/docs/ReleaseNotes.rst Tue May 31 10:25:05 2016 > @@ -185,11 +185,13 @@ this section should help get you past th > AST Matchers > > > -- hasAnyArgument: Matcher no longer ignores parentheses and implicit casts on > - the argument before applying the inner matcher. The fix was done to allow > for > - greater control by the user. In all existing checkers that use this matcher > - all instances of code ``hasAnyArgument()`` must be changed > to > - ``hasAnyArgument(ignoringParenImpCasts())``. > +- has and hasAnyArgument: Matchers no longer ignores parentheses and implicit > + casts on the argument before applying the inner matcher. The fix was done > to > + allow for greater control by the user. In all existing checkers that use > this > + matcher all instances of code ``hasAnyArgument()`` or > + ``has()`` must be changed to > + ``hasAnyArgument(ignoringParenImpCasts())`` or > + ``has(ignoringParenImpCasts())``. > > ... > > > Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=271288&r1=271287&r2=271288&view=diff > == > --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original) > +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Tue May 31 10:25:05 2016 > @@ -2169,6 +2169,10 @@ AST_MATCHER_P(CXXRecordDecl, hasMethod, > /// ChildT must be an AST base type. > /// > /// Usable as: Any Matcher > +/// Note that has is direct matcher, so it also matches things like implicit > +/// casts and paren casts. If you are matching with expr then you should > +/// probably consider using ignoringParenImpCasts like: > +/// has(ignoringParenImpCasts(expr())). > const internal::ArgumentAdaptingMatcherFunc > LLVM_ATTRIBUTE_UNUSED has = {}; > > > Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=271288&r1=271287&r2=271288&view=diff > == > --- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original) > +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Tue May 31 > 10:25:05 2016 > @@ -1165,8 +1165,6 @@ public: > /// ChildT must be an AST base type. > template > class HasMatcher : public WrapperMatcherInterface { > - static_assert(IsBaseType::value, > -"has only accepts base type matcher"); > > public: >explicit HasMatcher(const Matcher &ChildMatcher) > @@ -1174,10 +1172,9 @@ public: > >bool matches(const T &Node, ASTMatchFinder *Finder, > BoundNodesTreeBuilder *Builder) const override { > -return Finder->matchesChildOf( > -Node, this->InnerMatcher, Builder, > -ASTMatchFinder::TK_IgnoreImplicitCastsAndParentheses, > -ASTMatchFinder::BK_First); > +return Finder->matchesChildOf(Node, this->InnerMatcher, Builder, > + ASTMatchFinder::TK_AsIs, > + ASTMatchFinder::BK_First); >} > }; > > > Modified: cfe/trunk/include/clang/CMakeLists.txt > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CMakeLists.txt?rev=271288&r1=271287&r2=271288&view=diff > == > --- cfe/trunk/include/clang/CMakeLists.txt (original) > +++ cfe/trunk/include/clang/CMakeLists.txt Tue May 31 10:25:05 2016 > @@ -5,3 +5,4 @@ add_subdirectory(Parse) > add_subdirectory(Sema) > add_subdirectory(Serialization) > add_subdirectory(StaticAnalyzer/Checkers) > +add_subdirectory(ASTMatchers) > > Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp > URL: > http://llvm.org/viewvc/llvm-project/c
r271291 - Revert r253909 because it was committed with an incorrect message
Author: ehsan Date: Tue May 31 10:39:10 2016 New Revision: 271291 URL: http://llvm.org/viewvc/llvm-project?rev=271291&view=rev Log: Revert r253909 because it was committed with an incorrect message Removed: cfe/trunk/test/Index/symbol-visibility.c Modified: cfe/trunk/include/clang-c/Index.h cfe/trunk/tools/c-index-test/c-index-test.c cfe/trunk/tools/libclang/CIndex.cpp cfe/trunk/tools/libclang/libclang.exports Modified: cfe/trunk/include/clang-c/Index.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=271291&r1=271290&r2=271291&view=diff == --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Tue May 31 10:39:10 2016 @@ -2516,32 +2516,6 @@ enum CXLinkageKind { */ CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor); -enum CXVisibilityKind { - /** \brief This value indicates that no visibility information is available - * for a provided CXCursor. */ - CXVisibility_Invalid, - - /** \brief Symbol not seen by the linker. */ - CXVisibility_Hidden, - /** \brief Symbol seen by the linker but resolves to a symbol inside this object. */ - CXVisibility_Protected, - /** \brief Symbol seen by the linker and acts like a normal symbol. */ - CXVisibility_Default -}; - -/** - * \brief Describe the visibility of the entity referred to by a cursor. - * - * This returns the default visibility if not explicitly specified by - * a visibility attribute. The default visibility may be changed by - * commandline arguments. - * - * \param cursor The cursor to query. - * - * \returns The visibility of the cursor. - */ -CINDEX_LINKAGE enum CXVisibilityKind clang_getCursorVisibility(CXCursor cursor); - /** * \brief Determine the availability of the entity that this cursor refers to, * taking the current target platform into account. Removed: cfe/trunk/test/Index/symbol-visibility.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/symbol-visibility.c?rev=271290&view=auto == --- cfe/trunk/test/Index/symbol-visibility.c (original) +++ cfe/trunk/test/Index/symbol-visibility.c (removed) @@ -1,7 +0,0 @@ -// RUN: c-index-test -test-print-visibility %s | FileCheck %s - -__attribute__ ((visibility ("default"))) void foo1(); -__attribute__ ((visibility ("hidden"))) void foo2(); - -// CHECK: FunctionDecl=foo1:3:47visibility=Default -// CHECK: FunctionDecl=foo2:4:46visibility=Hidden Modified: cfe/trunk/tools/c-index-test/c-index-test.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=271291&r1=271290&r2=271291&view=diff == --- cfe/trunk/tools/c-index-test/c-index-test.c (original) +++ cfe/trunk/tools/c-index-test/c-index-test.c Tue May 31 10:39:10 2016 @@ -1265,32 +1265,6 @@ static enum CXChildVisitResult PrintLink } /**/ -/* Visibility testing. */ -/**/ - -static enum CXChildVisitResult PrintVisibility(CXCursor cursor, CXCursor p, - CXClientData d) { - const char *visibility = 0; - - if (clang_isInvalid(clang_getCursorKind(cursor))) -return CXChildVisit_Recurse; - - switch (clang_getCursorVisibility(cursor)) { -case CXVisibility_Invalid: break; -case CXVisibility_Hidden: visibility = "Hidden"; break; -case CXVisibility_Protected: visibility = "Protected"; break; -case CXVisibility_Default: visibility = "Default"; break; - } - - if (visibility) { -PrintCursor(cursor, NULL); -printf("visibility=%s\n", visibility); - } - - return CXChildVisit_Recurse; -} - -/**/ /* Typekind testing. */ /**/ @@ -4266,7 +4240,6 @@ static void print_usage(void) { " c-index-test -test-inclusion-stack-tu \n"); fprintf(stderr, " c-index-test -test-print-linkage-source {}*\n" -" c-index-test -test-print-visibility {}*\n" " c-index-test -test-print-type {}*\n" " c-index-test -test-print-type-size {}*\n" " c-index-test -test-print-bitwidth {}*\n" @@ -4361,9 +4334,6 @@ int cindextest_main(int argc, const char else if (argc > 2 && strcmp(argv[1], "-test-print-linkage-source") == 0) return perform_test_load_source(argc - 2, argv + 2, "all", PrintLinkage, NULL); - else if (argc > 2 && strcmp(argv[1], "-test-print-visibility") == 0) -return perform_test_lo
Re: [PATCH] D16948: [libcxx] Filesystem TS -- Complete
majnemer added inline comments. Comment at: src/experimental/operations.cpp:128-129 @@ +127,4 @@ +bool stat_equivalent(struct ::stat& st1, struct ::stat& st2) { +return (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino); +} + It is possible for `st_ino` to wrap around while the machine is still running. I'd mix `st_gen` into the comparison if we are running under one of the BSDs or Darwin. Linux has a `FS_IOC_GETVERSION` ioctl but it requires a file descriptor. Maybe such heroics are not worth it. http://reviews.llvm.org/D16948 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r271288 - [ASTMatchers] Breaking change of `has` matcher
Yep, sending fix 2016-05-31 17:45 GMT+02:00 Rafael Espíndola : > This broke the build: > > http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/36968/steps/cmake-configure/logs/stdio > > On 31 May 2016 at 08:25, Piotr Padlewski via cfe-commits > wrote: > > Author: prazek > > Date: Tue May 31 10:25:05 2016 > > New Revision: 271288 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=271288&view=rev > > Log: > > [ASTMatchers] Breaking change of `has` matcher > > > > has matcher can now match to implicit and paren casts > > > > http://reviews.llvm.org/D20801 > > > > Modified: > > cfe/trunk/docs/ReleaseNotes.rst > > cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h > > cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h > > cfe/trunk/include/clang/CMakeLists.txt > > cfe/trunk/unittests/AST/ASTImporterTest.cpp > > cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp > > > > Modified: cfe/trunk/docs/ReleaseNotes.rst > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=271288&r1=271287&r2=271288&view=diff > > > == > > --- cfe/trunk/docs/ReleaseNotes.rst (original) > > +++ cfe/trunk/docs/ReleaseNotes.rst Tue May 31 10:25:05 2016 > > @@ -185,11 +185,13 @@ this section should help get you past th > > AST Matchers > > > > > > -- hasAnyArgument: Matcher no longer ignores parentheses and implicit > casts on > > - the argument before applying the inner matcher. The fix was done to > allow for > > - greater control by the user. In all existing checkers that use this > matcher > > - all instances of code ``hasAnyArgument()`` must be > changed to > > - ``hasAnyArgument(ignoringParenImpCasts())``. > > +- has and hasAnyArgument: Matchers no longer ignores parentheses and > implicit > > + casts on the argument before applying the inner matcher. The fix was > done to > > + allow for greater control by the user. In all existing checkers that > use this > > + matcher all instances of code ``hasAnyArgument()`` or > > + ``has()`` must be changed to > > + ``hasAnyArgument(ignoringParenImpCasts())`` or > > + ``has(ignoringParenImpCasts())``. > > > > ... > > > > > > Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=271288&r1=271287&r2=271288&view=diff > > > == > > --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original) > > +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Tue May 31 > 10:25:05 2016 > > @@ -2169,6 +2169,10 @@ AST_MATCHER_P(CXXRecordDecl, hasMethod, > > /// ChildT must be an AST base type. > > /// > > /// Usable as: Any Matcher > > +/// Note that has is direct matcher, so it also matches things like > implicit > > +/// casts and paren casts. If you are matching with expr then you should > > +/// probably consider using ignoringParenImpCasts like: > > +/// has(ignoringParenImpCasts(expr())). > > const internal::ArgumentAdaptingMatcherFunc > > LLVM_ATTRIBUTE_UNUSED has = {}; > > > > > > Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=271288&r1=271287&r2=271288&view=diff > > > == > > --- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original) > > +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Tue May 31 > 10:25:05 2016 > > @@ -1165,8 +1165,6 @@ public: > > /// ChildT must be an AST base type. > > template > > class HasMatcher : public WrapperMatcherInterface { > > - static_assert(IsBaseType::value, > > -"has only accepts base type matcher"); > > > > public: > >explicit HasMatcher(const Matcher &ChildMatcher) > > @@ -1174,10 +1172,9 @@ public: > > > >bool matches(const T &Node, ASTMatchFinder *Finder, > > BoundNodesTreeBuilder *Builder) const override { > > -return Finder->matchesChildOf( > > -Node, this->InnerMatcher, Builder, > > -ASTMatchFinder::TK_IgnoreImplicitCastsAndParentheses, > > -ASTMatchFinder::BK_First); > > +return Finder->matchesChildOf(Node, this->InnerMatcher, Builder, > > + ASTMatchFinder::TK_AsIs, > > + ASTMatchFinder::BK_First); > >} > > }; > > > > > > Modified: cfe/trunk/include/clang/CMakeLists.txt > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CMakeLists.txt?rev=271288&r1=271287&r2=271288&view=diff > > > == > > --- cfe/trunk/include/clang/CMakeLists.txt (original) > > +++ cfe/trunk/include/clang/CMakeLists.txt Tue May 31 10:25:05 2016 > > @@ -5
Re: r271288 - [ASTMatchers] Breaking change of `has` matcher
dunno why but I can't fetch from upstream Can you push this change? - include/clang/CMakeLists.txt - index 96905c9..feb81f0 100644 @@ -5,4 +5,3 @@ add_subdirectory(Parse) add_subdirectory(Sema) add_subdirectory(Serialization) add_subdirectory(StaticAnalyzer/Checkers) -add_subdirectory(ASTMatchers) 2016-05-31 17:48 GMT+02:00 Piotr Padlewski : > Yep, sending fix > > 2016-05-31 17:45 GMT+02:00 Rafael Espíndola : > >> This broke the build: >> >> http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/36968/steps/cmake-configure/logs/stdio >> >> On 31 May 2016 at 08:25, Piotr Padlewski via cfe-commits >> wrote: >> > Author: prazek >> > Date: Tue May 31 10:25:05 2016 >> > New Revision: 271288 >> > >> > URL: http://llvm.org/viewvc/llvm-project?rev=271288&view=rev >> > Log: >> > [ASTMatchers] Breaking change of `has` matcher >> > >> > has matcher can now match to implicit and paren casts >> > >> > http://reviews.llvm.org/D20801 >> > >> > Modified: >> > cfe/trunk/docs/ReleaseNotes.rst >> > cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h >> > cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h >> > cfe/trunk/include/clang/CMakeLists.txt >> > cfe/trunk/unittests/AST/ASTImporterTest.cpp >> > cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp >> > >> > Modified: cfe/trunk/docs/ReleaseNotes.rst >> > URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=271288&r1=271287&r2=271288&view=diff >> > >> == >> > --- cfe/trunk/docs/ReleaseNotes.rst (original) >> > +++ cfe/trunk/docs/ReleaseNotes.rst Tue May 31 10:25:05 2016 >> > @@ -185,11 +185,13 @@ this section should help get you past th >> > AST Matchers >> > >> > >> > -- hasAnyArgument: Matcher no longer ignores parentheses and implicit >> casts on >> > - the argument before applying the inner matcher. The fix was done to >> allow for >> > - greater control by the user. In all existing checkers that use this >> matcher >> > - all instances of code ``hasAnyArgument()`` must be >> changed to >> > - ``hasAnyArgument(ignoringParenImpCasts())``. >> > +- has and hasAnyArgument: Matchers no longer ignores parentheses and >> implicit >> > + casts on the argument before applying the inner matcher. The fix was >> done to >> > + allow for greater control by the user. In all existing checkers that >> use this >> > + matcher all instances of code ``hasAnyArgument()`` or >> > + ``has()`` must be changed to >> > + ``hasAnyArgument(ignoringParenImpCasts())`` or >> > + ``has(ignoringParenImpCasts())``. >> > >> > ... >> > >> > >> > Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h >> > URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=271288&r1=271287&r2=271288&view=diff >> > >> == >> > --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original) >> > +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Tue May 31 >> 10:25:05 2016 >> > @@ -2169,6 +2169,10 @@ AST_MATCHER_P(CXXRecordDecl, hasMethod, >> > /// ChildT must be an AST base type. >> > /// >> > /// Usable as: Any Matcher >> > +/// Note that has is direct matcher, so it also matches things like >> implicit >> > +/// casts and paren casts. If you are matching with expr then you >> should >> > +/// probably consider using ignoringParenImpCasts like: >> > +/// has(ignoringParenImpCasts(expr())). >> > const internal::ArgumentAdaptingMatcherFunc >> > LLVM_ATTRIBUTE_UNUSED has = {}; >> > >> > >> > Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h >> > URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=271288&r1=271287&r2=271288&view=diff >> > >> == >> > --- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original) >> > +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Tue May >> 31 10:25:05 2016 >> > @@ -1165,8 +1165,6 @@ public: >> > /// ChildT must be an AST base type. >> > template >> > class HasMatcher : public WrapperMatcherInterface { >> > - static_assert(IsBaseType::value, >> > -"has only accepts base type matcher"); >> > >> > public: >> >explicit HasMatcher(const Matcher &ChildMatcher) >> > @@ -1174,10 +1172,9 @@ public: >> > >> >bool matches(const T &Node, ASTMatchFinder *Finder, >> > BoundNodesTreeBuilder *Builder) const override { >> > -return Finder->matchesChildOf( >> > -Node, this->InnerMatcher, Builder, >> > -ASTMatchFinder::TK_IgnoreImplicitCastsAndParentheses, >> > -ASTMatchFinder::BK_First); >> > +return Finder->matchesChildOf(Node, this->InnerMatcher, Builder, >> > + ASTM
Re: [PATCH] D20744: [OpenCL] Disable warning about core features by default
jvesely updated this revision to Diff 59079. jvesely added a comment. fixup additional tests that checked for the warning Repository: rL LLVM http://reviews.llvm.org/D20744 Files: include/clang/Basic/DiagnosticParseKinds.td test/Parser/opencl-atomics-cl20.cl test/SemaOpenCL/extension-version.cl test/SemaOpenCL/invalid-logical-ops-1.2.cl Index: test/SemaOpenCL/invalid-logical-ops-1.2.cl === --- test/SemaOpenCL/invalid-logical-ops-1.2.cl +++ test/SemaOpenCL/invalid-logical-ops-1.2.cl @@ -1,6 +1,6 @@ // RUN: %clang_cc1 %s -verify -cl-std=CL1.2 -triple x86_64-unknown-linux-gnu -#pragma OPENCL EXTENSION cl_khr_fp64 : enable // expected-warning{{OpenCL extension 'cl_khr_fp64' is core feature or supported optional core feature - ignoring}} +#pragma OPENCL EXTENSION cl_khr_fp64 : enable typedef __attribute__((ext_vector_type(4))) float float4; typedef __attribute__((ext_vector_type(4))) double double4; Index: test/SemaOpenCL/extension-version.cl === --- test/SemaOpenCL/extension-version.cl +++ test/SemaOpenCL/extension-version.cl @@ -2,8 +2,12 @@ // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown +// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES +// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES +// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES +// RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES -#if __OPENCL_C_VERSION__ >= 200 +#if __OPENCL_C_VERSION__ >= 200 && ! defined TEST_CORE_FEATURES // expected-no-diagnostics #endif @@ -38,57 +42,76 @@ #endif #pragma OPENCL EXTENSION cl_khr_icd: enable -// COre features in CL 1.1 -#if (__OPENCL_C_VERSION__ < 110) +// Core features in CL 1.1 #ifndef cl_khr_byte_addressable_store #error "Missing cl_khr_byte_addressable_store define" #endif #pragma OPENCL EXTENSION cl_khr_byte_addressable_store: enable +#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES +// expected-warning@-2{{OpenCL extension 'cl_khr_byte_addressable_store' is core feature or supported optional core feature - ignoring}} +#endif #ifndef cl_khr_global_int32_base_atomics #error "Missing cl_khr_global_int32_base_atomics define" #endif #pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics: enable +#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES +// expected-warning@-2{{OpenCL extension 'cl_khr_global_int32_base_atomics' is core feature or supported optional core feature - ignoring}} +#endif #ifndef cl_khr_global_int32_extended_atomics #error "Missing cl_khr_global_int32_extended_atomics define" #endif #pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics: enable +#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES +// expected-warning@-2{{OpenCL extension 'cl_khr_global_int32_extended_atomics' is core feature or supported optional core feature - ignoring}} +#endif #ifndef cl_khr_local_int32_base_atomics #error "Missing cl_khr_local_int32_base_atomics define" #endif #pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics: enable +#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES +// expected-warning@-2{{OpenCL extension 'cl_khr_local_int32_base_atomics' is core feature or supported optional core feature - ignoring}} +#endif #ifndef cl_khr_local_int32_extended_atomics #error "Missing cl_khr_local_int32_extended_atomics define" #endif #pragma OPENCL EXTENSION cl_khr_local_int32_extended_atomics: enable +#if (__OPENCL_C_VERSION__ >= 110) && defined TEST_CORE_FEATURES +// expected-warning@-2{{OpenCL extension 'cl_khr_local_int32_extended_atomics' is core feature or supported optional core feature - ignoring}} +#endif +#if (__OPENCL_C_VERSION__ < 110) +// Deprecated abvoe 1.0 #ifndef cl_khr_select_fprounding_mode #error "Missing cl_khr_select_fp_rounding_mode define" #endif #pragma OPENCL EXTENSION cl_khr_select_fprounding_mode: enable - #endif + // Core feature in CL 1.2 -#if (__OPENCL_C_VERSION__ < 120) #ifndef cl_khr_fp64 #error "Missing cl_khr_fp64 define" #endif #pragma OPENCL EXTENSION cl_khr_fp64: enable +#if (__OPENCL_C_VERSION__ >= 120) && defined TEST_CORE_FEATURES +// expected-warning@-2{{OpenCL extension 'cl_khr_fp64' is core feature or supported optional core feature - ignoring}} #endif //Core feature in CL 2.0 -#if (__OPENCL_C_VERSION__ < 200) #ifndef cl_khr_3d_image_writes #error "Missing cl_khr_3d_image_writes define" #endif #pragma OPENCL EXTENSION
Re: [PATCH] D20388: AMDGPU: Fix supported CL features
jvesely updated the summary for this revision. jvesely updated this revision to Diff 59080. jvesely added a comment. add has_fp64 macro Repository: rL LLVM http://reviews.llvm.org/D20388 Files: lib/Basic/Targets.cpp test/Misc/amdgcn.languageOptsOpenCL.cl test/Misc/r600.languageOptsOpenCL.cl Index: test/Misc/r600.languageOptsOpenCL.cl === --- /dev/null +++ test/Misc/r600.languageOptsOpenCL.cl @@ -0,0 +1,51 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple r600-unknown-unknown -target-cpu cayman +// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple r600-unknown-unknown -target-cpu cypress +// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple r600-unknown-unknown -target-cpu turks +// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple r600-unknown-unknown -target-cpu cayman +// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple r600-unknown-unknown -target-cpu cypress +// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple r600-unknown-unknown -target-cpu turks +// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple r600-unknown-unknown -target-cpu cayman +// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple r600-unknown-unknown -target-cpu cypress +// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple r600-unknown-unknown -target-cpu turks +// expected-no-diagnostics + +#ifndef cl_clang_storage_class_specifiers +#error "Missing cl_clang_storage_class_specifiers define" +#endif +#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable + +#if (__OPENCL_C_VERSION__ < 120) && (defined __HAS_FP64__) +#ifndef cl_khr_fp64 +#error "Missing cl_khr_fp64 define" +#endif +#pragma OPENCL EXTENSION cl_khr_fp64: enable +#endif + +#if (__OPENCL_C_VERSION__ == 100) +#ifndef cl_khr_byte_addressable_store +#error "Missing cl_khr_byte_addressable_store define" +#endif +#pragma OPENCL EXTENSION cl_khr_byte_addressable_store: enable + +#ifndef cl_khr_global_int32_base_atomics +#error "Missing cl_khr_global_int32_base_atomics define" +#endif +#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics: enable + +#ifndef cl_khr_global_int32_extended_atomics +#error "Missing cl_khr_global_int32_extended_atomics define" +#endif +#pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics: enable + +#ifndef cl_khr_local_int32_base_atomics +#error "Missing cl_khr_local_int32_base_atomics define" +#endif +#pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics: enable + +#ifndef cl_khr_local_int32_extended_atomics +#error "Missing cl_khr_local_int32_extended_atomics define" +#endif +#pragma OPENCL EXTENSION cl_khr_local_int32_extended_atomics: enable + +#endif Index: test/Misc/amdgcn.languageOptsOpenCL.cl === --- /dev/null +++ test/Misc/amdgcn.languageOptsOpenCL.cl @@ -0,0 +1,61 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -x cl -cl-std=CL %s -verify -triple amdgcn-unknown-unknown +// RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple amdgcn-unknown-unknown +// RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple amdgcn-unknown-unknown +// expected-no-diagnostics + +#ifndef cl_clang_storage_class_specifiers +#error "Missing cl_clang_storage_class_specifiers define" +#endif +#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers: enable + +#ifndef cl_khr_fp64 +#error "Missing cl_khr_fp64 define" +#endif + +#ifndef cl_khr_3d_image_writes +#error "Missing cl_khr_3d_image_writes define" +#endif + +#if (__OPENCL_C_VERSION__ < 120) +#pragma OPENCL EXTENSION cl_khr_fp64: enable +#pragma OPENCL EXTENSION cl_khr_3d_image_writes: enable +#endif + +#ifndef cl_khr_byte_addressable_store +#error "Missing cl_khr_byte_addressable_store define" +#endif + +#ifndef cl_khr_global_int32_base_atomics +#error "Missing cl_khr_global_int32_base_atomics define" +#endif + +#ifndef cl_khr_global_int32_extended_atomics +#error "Missing cl_khr_global_int32_extended_atomics define" +#endif + +#ifndef cl_khr_local_int32_base_atomics +#error "Missing cl_khr_local_int32_base_atomics define" +#endif + +#ifndef cl_khr_local_int32_extended_atomics +#error "Missing cl_khr_local_int32_extended_atomics define" +#endif + +#if (__OPENCL_C_VERSION__ == 100) +#pragma OPENCL EXTENSION cl_khr_byte_addressable_store: enable +#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics: enable +#pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics: enable +#pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics: enable +#pragma OPENCL EXTENSION cl_khr_local_int32_extended_atomics: enable +#endif + +#ifndef cl_khr_int64_base_atomics +#error "Missing cl_khr_int64_base_atomics define" +#endif +#pragma OPENCL EXTENSION cl_khr_int64_base_atomics: enable + +#ifndef cl_khr_int64_extended_atomics +#error "Missing cl_khr_int64_extended_atomics define" +#endif +#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics: enable Index: lib/Ba