r323615 - [git-clang-format] Process CUDA files
Author: hahnfeld Date: Sun Jan 28 02:11:25 2018 New Revision: 323615 URL: http://llvm.org/viewvc/llvm-project?rev=323615&view=rev Log: [git-clang-format] Process CUDA files Clang supports compiling CUDA source files for some time, format them by default as well. Differential Revision: https://reviews.llvm.org/D42589 Modified: cfe/trunk/tools/clang-format/git-clang-format Modified: cfe/trunk/tools/clang-format/git-clang-format URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/git-clang-format?rev=323615&r1=323614&r2=323615&view=diff == --- cfe/trunk/tools/clang-format/git-clang-format (original) +++ cfe/trunk/tools/clang-format/git-clang-format Sun Jan 28 02:11:25 2018 @@ -79,6 +79,7 @@ def main(): 'm', # ObjC 'mm', # ObjC++ 'cc', 'cp', 'cpp', 'c++', 'cxx', 'hpp', # C++ + 'cu', # CUDA # Other languages that clang-format supports 'proto', 'protodevel', # Protocol Buffers 'java', # Java ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42589: [git-clang-format] Process CUDA files
This revision was automatically updated to reflect the committed changes. Closed by commit rL323615: [git-clang-format] Process CUDA files (authored by Hahnfeld, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D42589?vs=131625&id=131701#toc Repository: rL LLVM https://reviews.llvm.org/D42589 Files: cfe/trunk/tools/clang-format/git-clang-format Index: cfe/trunk/tools/clang-format/git-clang-format === --- cfe/trunk/tools/clang-format/git-clang-format +++ cfe/trunk/tools/clang-format/git-clang-format @@ -79,6 +79,7 @@ 'm', # ObjC 'mm', # ObjC++ 'cc', 'cp', 'cpp', 'c++', 'cxx', 'hpp', # C++ + 'cu', # CUDA # Other languages that clang-format supports 'proto', 'protodevel', # Protocol Buffers 'java', # Java Index: cfe/trunk/tools/clang-format/git-clang-format === --- cfe/trunk/tools/clang-format/git-clang-format +++ cfe/trunk/tools/clang-format/git-clang-format @@ -79,6 +79,7 @@ 'm', # ObjC 'mm', # ObjC++ 'cc', 'cp', 'cpp', 'c++', 'cxx', 'hpp', # C++ + 'cu', # CUDA # Other languages that clang-format supports 'proto', 'protodevel', # Protocol Buffers 'java', # Java ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42354: Fix libcxx MSVC C++17 redefinition of 'align_val_t'
fcharlie accepted this revision. fcharlie added a comment. libcxx: Fix libcxx MSVC C++17 redefinition of 'align_val_t' Differential Revision: https://reviews.llvm.org/D42354 Repository: rCXX libc++ https://reviews.llvm.org/D42354 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42354: Fix libcxx MSVC C++17 redefinition of 'align_val_t'
fcharlie added a comment. @compnerd Please commit this, Thanks Repository: rCXX libc++ https://reviews.llvm.org/D42354 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r323617 - Change memcpy/memove/memset to have dest and source alignment attributes.
Author: dneilson Date: Sun Jan 28 09:27:45 2018 New Revision: 323617 URL: http://llvm.org/viewvc/llvm-project?rev=323617&view=rev Log: Change memcpy/memove/memset to have dest and source alignment attributes. Summary: This change is step three in the series of changes to remove alignment argument from memcpy/memmove/memset in favour of alignment attributes. Steps: Step 1) Remove alignment parameter and create alignment parameter attributes for memcpy/memmove/memset. ( rL322965, rC322964, rL322963 ) Step 2) Expand the IRBuilder API to allow creation of memcpy/memmove with differing source and dest alignments. ( rL323597 ) Step 3) Update Clang to use the new IRBuilder API. Step 4) Update Polly to use the new IRBuilder API. Step 5) Update LLVM passes that create memcpy/memmove calls to use the new IRBuilder API, and those that use use MemIntrinsicInst::[get|set]Alignment() to use getDestAlignment() and getSourceAlignment() instead. Step 6) Remove the single-alignment IRBuilder API for memcpy/memmove, and the MemIntrinsicInst::[get|set]Alignment() methods. Reference http://lists.llvm.org/pipermail/llvm-dev/2015-August/089384.html http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151109/312083.html Reviewers: rjmccall Subscribers: jyknight, nemanjai, nhaehnle, javed.absar, sbc100, aheejin, kbarton, fedor.sergeev, cfe-commits Differential Revision: https://reviews.llvm.org/D41677 Modified: cfe/trunk/lib/CodeGen/CGBuilder.h cfe/trunk/test/CodeGen/arm-arguments.c cfe/trunk/test/CodeGen/arm64-be-bitfield.c cfe/trunk/test/CodeGen/block-byref-aggr.c cfe/trunk/test/CodeGen/builtin-memfns.c cfe/trunk/test/CodeGen/c11atomics-ios.c cfe/trunk/test/CodeGen/c11atomics.c cfe/trunk/test/CodeGen/packed-nest-unpacked.c cfe/trunk/test/CodeGen/ppc64-align-struct.c cfe/trunk/test/CodeGen/ppc64-soft-float.c cfe/trunk/test/CodeGen/ppc64le-aggregates.c cfe/trunk/test/CodeGen/riscv32-abi.c cfe/trunk/test/CodeGen/riscv64-abi.c cfe/trunk/test/CodeGen/x86_32-arguments-realign.c cfe/trunk/test/CodeGen/x86_64-arguments.c cfe/trunk/test/CodeGenCXX/alignment.cpp cfe/trunk/test/CodeGenCXX/assign-construct-memcpy.cpp cfe/trunk/test/CodeGenCXX/copy-constructor-elim.cpp cfe/trunk/test/CodeGenCXX/eh.cpp cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp Modified: cfe/trunk/lib/CodeGen/CGBuilder.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuilder.h?rev=323617&r1=323616&r2=323617&view=diff == --- cfe/trunk/lib/CodeGen/CGBuilder.h (original) +++ cfe/trunk/lib/CodeGen/CGBuilder.h Sun Jan 28 09:27:45 2018 @@ -258,23 +258,23 @@ public: using CGBuilderBaseTy::CreateMemCpy; llvm::CallInst *CreateMemCpy(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile = false) { -auto Align = std::min(Dest.getAlignment(), Src.getAlignment()); -return CreateMemCpy(Dest.getPointer(), Src.getPointer(), Size, -Align.getQuantity(), IsVolatile); +return CreateMemCpy(Dest.getPointer(), Dest.getAlignment().getQuantity(), +Src.getPointer(), Src.getAlignment().getQuantity(), +Size,IsVolatile); } llvm::CallInst *CreateMemCpy(Address Dest, Address Src, uint64_t Size, bool IsVolatile = false) { -auto Align = std::min(Dest.getAlignment(), Src.getAlignment()); -return CreateMemCpy(Dest.getPointer(), Src.getPointer(), Size, -Align.getQuantity(), IsVolatile); +return CreateMemCpy(Dest.getPointer(), Dest.getAlignment().getQuantity(), +Src.getPointer(), Src.getAlignment().getQuantity(), +Size, IsVolatile); } using CGBuilderBaseTy::CreateMemMove; llvm::CallInst *CreateMemMove(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile = false) { -auto Align = std::min(Dest.getAlignment(), Src.getAlignment()); -return CreateMemMove(Dest.getPointer(), Src.getPointer(), Size, - Align.getQuantity(), IsVolatile); +return CreateMemMove(Dest.getPointer(), Dest.getAlignment().getQuantity(), + Src.getPointer(), Src.getAlignment().getQuantity(), + Size, IsVolatile); } using CGBuilderBaseTy::CreateMemSet; Modified: cfe/trunk/test/CodeGen/arm-arguments.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-arguments.c?rev=323617&r1=323616&r2=323617&view=diff == --- cfe/trunk/test/CodeGen/arm-arguments.c (original) +++ cfe/trunk/test/CodeGen/arm-arguments.c Sun Jan 28 09:27:45 2018 @@ -215,6 +215,6 @@ float32x4_t f35(int i, s35_with_align s1 // AAPCS: %[[a:.*]] = alloca %struct.s35, align 16 // AAPCS: %[[b:.*]] = b
[PATCH] D41677: Change memcpy/memove/memset to have dest and source alignment attributes.
This revision was automatically updated to reflect the committed changes. Closed by commit rL323617: Change memcpy/memove/memset to have dest and source alignment attributes. (authored by dneilson, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D41677 Files: cfe/trunk/lib/CodeGen/CGBuilder.h cfe/trunk/test/CodeGen/arm-arguments.c cfe/trunk/test/CodeGen/arm64-be-bitfield.c cfe/trunk/test/CodeGen/block-byref-aggr.c cfe/trunk/test/CodeGen/builtin-memfns.c cfe/trunk/test/CodeGen/c11atomics-ios.c cfe/trunk/test/CodeGen/c11atomics.c cfe/trunk/test/CodeGen/packed-nest-unpacked.c cfe/trunk/test/CodeGen/ppc64-align-struct.c cfe/trunk/test/CodeGen/ppc64-soft-float.c cfe/trunk/test/CodeGen/ppc64le-aggregates.c cfe/trunk/test/CodeGen/riscv32-abi.c cfe/trunk/test/CodeGen/riscv64-abi.c cfe/trunk/test/CodeGen/x86_32-arguments-realign.c cfe/trunk/test/CodeGen/x86_64-arguments.c cfe/trunk/test/CodeGenCXX/alignment.cpp cfe/trunk/test/CodeGenCXX/assign-construct-memcpy.cpp cfe/trunk/test/CodeGenCXX/copy-constructor-elim.cpp cfe/trunk/test/CodeGenCXX/eh.cpp cfe/trunk/test/OpenMP/parallel_reduction_codegen.cpp Index: cfe/trunk/lib/CodeGen/CGBuilder.h === --- cfe/trunk/lib/CodeGen/CGBuilder.h +++ cfe/trunk/lib/CodeGen/CGBuilder.h @@ -258,23 +258,23 @@ using CGBuilderBaseTy::CreateMemCpy; llvm::CallInst *CreateMemCpy(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile = false) { -auto Align = std::min(Dest.getAlignment(), Src.getAlignment()); -return CreateMemCpy(Dest.getPointer(), Src.getPointer(), Size, -Align.getQuantity(), IsVolatile); +return CreateMemCpy(Dest.getPointer(), Dest.getAlignment().getQuantity(), +Src.getPointer(), Src.getAlignment().getQuantity(), +Size,IsVolatile); } llvm::CallInst *CreateMemCpy(Address Dest, Address Src, uint64_t Size, bool IsVolatile = false) { -auto Align = std::min(Dest.getAlignment(), Src.getAlignment()); -return CreateMemCpy(Dest.getPointer(), Src.getPointer(), Size, -Align.getQuantity(), IsVolatile); +return CreateMemCpy(Dest.getPointer(), Dest.getAlignment().getQuantity(), +Src.getPointer(), Src.getAlignment().getQuantity(), +Size, IsVolatile); } using CGBuilderBaseTy::CreateMemMove; llvm::CallInst *CreateMemMove(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile = false) { -auto Align = std::min(Dest.getAlignment(), Src.getAlignment()); -return CreateMemMove(Dest.getPointer(), Src.getPointer(), Size, - Align.getQuantity(), IsVolatile); +return CreateMemMove(Dest.getPointer(), Dest.getAlignment().getQuantity(), + Src.getPointer(), Src.getAlignment().getQuantity(), + Size, IsVolatile); } using CGBuilderBaseTy::CreateMemSet; Index: cfe/trunk/test/CodeGen/ppc64le-aggregates.c === --- cfe/trunk/test/CodeGen/ppc64le-aggregates.c +++ cfe/trunk/test/CodeGen/ppc64le-aggregates.c @@ -104,7 +104,7 @@ // CHECK-LABEL: @call_f9 // CHECK: %[[TMP1:[^ ]+]] = alloca [5 x i64] // CHECK: %[[TMP2:[^ ]+]] = bitcast [5 x i64]* %[[TMP1]] to i8* -// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %[[TMP2]], i8* align 4 bitcast (%struct.f9* @global_f9 to i8*), i64 36, i1 false) +// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %[[TMP2]], i8* align 4 bitcast (%struct.f9* @global_f9 to i8*), i64 36, i1 false) // CHECK: %[[TMP3:[^ ]+]] = load [5 x i64], [5 x i64]* %[[TMP1]] // CHECK: call void @func_f9(%struct.f9* sret %{{[^ ]+}}, [5 x i64] %[[TMP3]]) struct f9 global_f9; Index: cfe/trunk/test/CodeGen/x86_32-arguments-realign.c === --- cfe/trunk/test/CodeGen/x86_32-arguments-realign.c +++ cfe/trunk/test/CodeGen/x86_32-arguments-realign.c @@ -2,7 +2,7 @@ // RUN: FileCheck < %t %s // CHECK-LABEL: define void @f0(%struct.s0* byval align 4) -// CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %{{.*}}, i8* align 4 %{{.*}}, i32 16, i1 false) +// CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %{{.*}}, i8* align 4 %{{.*}}, i32 16, i1 false) // CHECK: } struct s0 { long double a; }; void f0(struct s0 a0) { Index: cfe/trunk/test/CodeGen/arm64-be-bitfield.c === --- cfe/trunk/test/CodeGen/arm64-be-bitfield.c +++ cfe/trunk/test/CodeGen/arm64-be-bitfield.c @@ -7,6 +7,6 @@ // IR: callee_b0f(i64 [[ARG:%.*]]) // IR: store i64 [[ARG]], i64* [[PTR:%.*]], align 8 // IR: [[BITCAST:%.*]] = bitcast i64* [[PTR]] to i8* -// IR: call void @
[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons
tbourvon updated this revision to Diff 131709. tbourvon added a comment. Herald added a subscriber: hintonda. Separated the added matcher and lexer utils into a different diff. Also added unit tests to make sure we behave as expected when macros get in the way of the code we detect. https://reviews.llvm.org/D37014 Files: clang-tidy/readability/CMakeLists.txt clang-tidy/readability/ReadabilityTidyModule.cpp clang-tidy/readability/UnnecessaryIntermediateVarCheck.cpp clang-tidy/readability/UnnecessaryIntermediateVarCheck.h docs/ReleaseNotes.rst docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/readability-unnecessary-intermediate-var.rst test/clang-tidy/readability-unnecessary-intermediate-var.cpp Index: test/clang-tidy/readability-unnecessary-intermediate-var.cpp === --- /dev/null +++ test/clang-tidy/readability-unnecessary-intermediate-var.cpp @@ -0,0 +1,230 @@ +// RUN: %check_clang_tidy %s readability-unnecessary-intermediate-var %t + +bool f() { + auto test = 1; // Test + // CHECK-FIXES: {{^}} // Test{{$}} + return (test == 1); + // CHECK-FIXES: {{^}} return (1 == 1);{{$}} + // CHECK-MESSAGES: :[[@LINE-4]]:8: warning: unnecessary intermediate variable 'test' [readability-unnecessary-intermediate-var] + // CHECK-MESSAGES: :[[@LINE-3]]:11: note: because it is only used when returning the result of this comparison + // CHECK-MESSAGES: :[[@LINE-6]]:8: note: consider removing the variable declaration + // CHECK-MESSAGES: :[[@LINE-5]]:11: note: and directly using the variable initialization expression here +} + +bool f2() { + auto test1 = 1; // Test1 + // CHECK-FIXES: {{^}} // Test1{{$}} + auto test2 = 2; // Test2 + // CHECK-FIXES: {{^}} // Test2{{$}} + return (test1 == test2); + // CHECK-FIXES: {{^}} return (1 == 2);{{$}} + // CHECK-MESSAGES: :[[@LINE-6]]:8: warning: unnecessary intermediate variable 'test1' [readability-unnecessary-intermediate-var] + // CHECK-MESSAGES: :[[@LINE-5]]:8: warning: and so is 'test2' [readability-unnecessary-intermediate-var] + // CHECK-MESSAGES: :[[@LINE-4]]:11: note: because they are only used when returning the result of this comparison + // CHECK-MESSAGES: :[[@LINE-9]]:8: note: consider removing both this variable declaration + // CHECK-MESSAGES: :[[@LINE-8]]:8: note: and this one + // CHECK-MESSAGES: :[[@LINE-7]]:11: note: and directly using the variable initialization expressions here +} + +bool f3() { + auto test1 = 1; // Test1 + // CHECK-FIXES: {{^}} // Test1{{$}} + auto test2 = 2; // Test2 + return (test1 == 2); + // CHECK-FIXES: {{^}} return (1 == 2);{{$}} + // CHECK-MESSAGES: :[[@LINE-5]]:8: warning: unnecessary intermediate variable 'test1' [readability-unnecessary-intermediate-var] + // CHECK-MESSAGES: :[[@LINE-3]]:11: note: because it is only used when returning the result of this comparison + // CHECK-MESSAGES: :[[@LINE-7]]:8: note: consider removing the variable declaration + // CHECK-MESSAGES: :[[@LINE-5]]:11: note: and directly using the variable initialization expression here +} + +bool f4() { + auto test1 = 1; // Test1 + auto test2 = 2; // Test2 + // CHECK-FIXES: {{^}} // Test2{{$}} + return (test2 == 3); + // CHECK-FIXES: {{^}} return (2 == 3);{{$}} + // CHECK-MESSAGES: :[[@LINE-4]]:8: warning: unnecessary intermediate variable 'test2' [readability-unnecessary-intermediate-var] + // CHECK-MESSAGES: :[[@LINE-3]]:11: note: because it is only used when returning the result of this comparison + // CHECK-MESSAGES: :[[@LINE-6]]:8: note: consider removing the variable declaration + // CHECK-MESSAGES: :[[@LINE-5]]:11: note: and directly using the variable initialization expression here +} + +bool f5() { + auto test1 = 1; // Test1 + // CHECK-FIXES: {{^}} // Test1{{$}} + auto test2 = 2; // Test2 + return (2 == test1); + // CHECK-FIXES: {{^}} return (1 == 2);{{$}} + // CHECK-MESSAGES: :[[@LINE-5]]:8: warning: unnecessary intermediate variable 'test1' [readability-unnecessary-intermediate-var] + // CHECK-MESSAGES: :[[@LINE-3]]:16: note: because it is only used when returning the result of this comparison + // CHECK-MESSAGES: :[[@LINE-7]]:8: note: consider removing the variable declaration + // CHECK-MESSAGES: :[[@LINE-5]]:11: note: and directly using the variable initialization expression here +} + +bool f6() { + auto test1 = 1; // Test1 + auto test2 = 2; // Test2 + // CHECK-FIXES: {{^}} // Test2{{$}} + return (3 == test2); + // CHECK-FIXES: {{^}} return (2 == 3);{{$}} + // CHECK-MESSAGES: :[[@LINE-4]]:8: warning: unnecessary intermediate variable 'test2' [readability-unnecessary-intermediate-var] + // CHECK-MESSAGES: :[[@LINE-3]]:16: note: because it is only used when returning the result of this comparison + // CHECK-MESSAGES: :[[@LINE-6]]:8: note: consider removing the variable declaration + // CHECK-MESSAGES: :[[@LINE-5]]:11: note: and directly using the variable initialization expression here +} + +int foo() {
[PATCH] D42623: [clang-tidy] Add a Lexer util to get the source text of a statement
tbourvon created this revision. tbourvon added a reviewer: lebedev.ri. tbourvon added a project: clang-tools-extra. Herald added subscribers: hintonda, xazax.hun, mgorny. This is a simple Lexer util to get the source text of a statement given as parameter. This is needed for https://reviews.llvm.org/D37014. https://reviews.llvm.org/D42623 Files: clang-tidy/utils/LexerUtils.cpp clang-tidy/utils/LexerUtils.h unittests/clang-tidy/CMakeLists.txt unittests/clang-tidy/LexerUtilsTest.cpp Index: unittests/clang-tidy/LexerUtilsTest.cpp === --- /dev/null +++ unittests/clang-tidy/LexerUtilsTest.cpp @@ -0,0 +1,51 @@ +#include "ClangTidyTest.h" +#include "clang/Tooling/Tooling.h" +#include "utils/LexerUtils.h" +#include "gtest/gtest.h" + +namespace clang { +namespace tidy { +namespace test { + +class GetStmtTextTest : public ::testing::Test { +protected: + GetStmtTextTest() +: Unit(CheckASTUnitNotNull(tooling::buildASTFromCode("void foo() { int bar = 0; }"))), + SM(Unit->getSourceManager()) + {} + + std::unique_ptr CheckASTUnitNotNull(std::unique_ptr Unit) { +EXPECT_TRUE(Unit); +return Unit; + } + + std::unique_ptr Unit; + SourceManager& SM; +}; + +TEST_F(GetStmtTextTest, NullStatement) { + EXPECT_EQ(llvm::NoneType(), utils::lexer::getStmtText(nullptr, SM)); +} + +TEST_F(GetStmtTextTest, SimpleStatement) { + auto FooIdent = &Unit->getASTContext().Idents.getOwn("foo"); + auto FooDeclName = Unit->getASTContext().DeclarationNames.getIdentifier(FooIdent); + auto FooLookup = Unit->getASTContext().getTranslationUnitDecl()->lookup(FooDeclName); + auto FooFunction = dyn_cast_or_null(FooLookup.front()); + EXPECT_TRUE(FooFunction); + + auto FooBody = dyn_cast_or_null(FooFunction->getBody()); + EXPECT_TRUE(FooBody); + EXPECT_TRUE(FooBody->body_begin()); + + auto DeclStmt = *FooBody->body_begin(); + + + auto Res = utils::lexer::getStmtText(DeclStmt, SM); + EXPECT_TRUE(Res.hasValue()); + EXPECT_EQ("int bar = 0;", *Res); +} + +} // namespace test +} // namespace tidy +} // namespace clang Index: unittests/clang-tidy/CMakeLists.txt === --- unittests/clang-tidy/CMakeLists.txt +++ unittests/clang-tidy/CMakeLists.txt @@ -11,6 +11,7 @@ ClangTidyOptionsTest.cpp IncludeInserterTest.cpp GoogleModuleTest.cpp + LexerUtilsTest.cpp LLVMModuleTest.cpp NamespaceAliaserTest.cpp ObjCModuleTest.cpp Index: clang-tidy/utils/LexerUtils.h === --- clang-tidy/utils/LexerUtils.h +++ clang-tidy/utils/LexerUtils.h @@ -22,6 +22,9 @@ Token getPreviousToken(const ASTContext &Context, SourceLocation Location, bool SkipComments = true); +/// Get source code text for statement. +Optional getStmtText(const Stmt* Statement, const SourceManager& SM); + } // namespace lexer } // namespace utils } // namespace tidy Index: clang-tidy/utils/LexerUtils.cpp === --- clang-tidy/utils/LexerUtils.cpp +++ clang-tidy/utils/LexerUtils.cpp @@ -35,6 +35,20 @@ return Token; } +Optional getStmtText(const Stmt* Statement, const SourceManager& SM) { + if (!Statement) { +return llvm::NoneType(); + } + + bool Error = false; + auto Ret = Lexer::getSourceText( +CharSourceRange::getTokenRange(Statement->getSourceRange()), +SM, LangOptions(), +&Error); + + return Error ? llvm::NoneType() : Optional(Ret); +} + } // namespace lexer } // namespace utils } // namespace tidy ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons
lebedev.ri added inline comments. Comment at: test/clang-tidy/readability-unnecessary-intermediate-var.cpp:206 + auto test = 1; // Test +#ifdef INTERMITTENT_MACRO + return (test == 1); Tests are nice :) But please, add the test with assert-like macro.. https://reviews.llvm.org/D37014 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42624: [clang-tidy] Add a utility Matcher to match the next statement within a statement sequence
tbourvon created this revision. tbourvon added a reviewer: lebedev.ri. tbourvon added a project: clang-tools-extra. Herald added subscribers: hintonda, xazax.hun, mgorny. This adds a utility matcher (which is placed in `util/Matchers.h`, because it uses functions from `ASTMatchFinder.h` which cannot be used from `ASTMatchers.h`) used by https://reviews.llvm.org/D37014). https://reviews.llvm.org/D42624 Files: clang-tidy/utils/Matchers.h unittests/clang-tidy/CMakeLists.txt unittests/clang-tidy/MatchersUtilsTest.cpp Index: unittests/clang-tidy/MatchersUtilsTest.cpp === --- /dev/null +++ unittests/clang-tidy/MatchersUtilsTest.cpp @@ -0,0 +1,25 @@ +#include "../../../unittests/ASTMatchers/ASTMatchersTest.h" +#include "utils/Matchers.h" + +namespace clang { +namespace tidy { +namespace test { + +using namespace ast_matchers; +using namespace matchers; + +TEST(StatementMatcher, HasSuccessor) { + StatementMatcher DeclHasSuccessorReturnStmt = +declStmt(hasSuccessor(returnStmt())); + + EXPECT_TRUE(matches( +"void foo() { int bar; return; }", +DeclHasSuccessorReturnStmt)); + EXPECT_TRUE(notMatches( +"void foo() { int bar; bar++; return; }", +DeclHasSuccessorReturnStmt)); +} + +} +} +} Index: unittests/clang-tidy/CMakeLists.txt === --- unittests/clang-tidy/CMakeLists.txt +++ unittests/clang-tidy/CMakeLists.txt @@ -12,6 +12,7 @@ IncludeInserterTest.cpp GoogleModuleTest.cpp LLVMModuleTest.cpp + MatchersUtilsTest.cpp NamespaceAliaserTest.cpp ObjCModuleTest.cpp OverlappingReplacementsTest.cpp Index: clang-tidy/utils/Matchers.h === --- clang-tidy/utils/Matchers.h +++ clang-tidy/utils/Matchers.h @@ -12,6 +12,8 @@ #include "TypeTraits.h" #include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Analysis/CFG.h" namespace clang { namespace tidy { @@ -48,6 +50,67 @@ return referenceType(pointee(qualType(isConstQualified(; } +// Matches the next statement within the parent statement sequence. +AST_MATCHER_P(Stmt, hasSuccessor, + ast_matchers::internal::Matcher, InnerMatcher) { + using namespace ast_matchers; + + // We get the first parent, making sure that we're not in a case statement + // not in a compound statement directly inside a switch, because this causes + // the buildCFG call to crash. + auto Parent = selectFirst( +"parent", +match( + stmt(hasAncestor(stmt( +unless(caseStmt()), +unless(compoundStmt(hasParent(switchStmt(, +stmt().bind("parent", +Node, Finder->getASTContext())); + + // We build a Control Flow Graph (CFG) from the parent statement. + std::unique_ptr StatementCFG = +CFG::buildCFG(nullptr, const_cast(Parent), &Finder->getASTContext(), + CFG::BuildOptions()); + + if (!StatementCFG) { +return false; + } + + // We iterate through all the CFGBlocks, which basically means that we go over + // all the possible branches of the code and therefore cover all statements. + for (auto& Block : *StatementCFG) { +if (!Block) { + continue; +} + +// We iterate through all the statements of the block. +bool ReturnNextStmt = false; +for (auto& BlockItem : *Block) { + Optional CFGStatement = BlockItem.getAs(); + if (!CFGStatement) { +if (ReturnNextStmt) { + return false; +} + +continue; + } + + // If we found the next statement, we apply the inner matcher and return + // the result. + if (ReturnNextStmt) { +return InnerMatcher.matches(*CFGStatement->getStmt(), Finder, Builder); + } + + if (CFGStatement->getStmt() == &Node) { +ReturnNextStmt = true; + } +} + } + + // If we didn't find a successor, we just return false. + return false; +} + } // namespace matchers } // namespace tidy } // namespace clang ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons
tbourvon marked an inline comment as done. tbourvon added inline comments. Comment at: test/clang-tidy/readability-unnecessary-intermediate-var.cpp:206 + auto test = 1; // Test +#ifdef INTERMITTENT_MACRO + return (test == 1); lebedev.ri wrote: > Tests are nice :) > But please, add the test with assert-like macro.. Sorry, I'm not sure I understand what kind of test you are suggesting... Could you give me a short example? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D37014 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons
lebedev.ri added inline comments. Comment at: test/clang-tidy/readability-unnecessary-intermediate-var.cpp:206 + auto test = 1; // Test +#ifdef INTERMITTENT_MACRO + return (test == 1); tbourvon wrote: > lebedev.ri wrote: > > Tests are nice :) > > But please, add the test with assert-like macro.. > Sorry, I'm not sure I understand what kind of test you are suggesting... > Could you give me a short example? //Something// like this: (did not test at all, just back of the envelope code) ``` void die(); #ifndef NDEBUG #define assert(cond) void(0) // i.e. it does nothing #else #define assert(cond) (cond) ? void(0) : die(); #endif ``` ``` bool some_func(); bool f_preprocessor_macro2() { auto test = some_func(); assert(test); // <- should not be removed regardless of whether NDEBUG is set or not return test; } ``` Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D37014 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42605: [Sema] Toggle diags when finding allocators (NFCI)
modocache updated this revision to Diff 131728. modocache added a comment. Prevent note diagnostics from being emitted for arity mismatch. Repository: rC Clang https://reviews.llvm.org/D42605 Files: include/clang/Sema/Sema.h lib/Sema/SemaExprCXX.cpp Index: lib/Sema/SemaExprCXX.cpp === --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -2151,12 +2151,10 @@ return false; } -static bool -resolveAllocationOverload(Sema &S, LookupResult &R, SourceRange Range, - SmallVectorImpl &Args, bool &PassAlignment, - FunctionDecl *&Operator, - OverloadCandidateSet *AlignedCandidates = nullptr, - Expr *AlignArg = nullptr) { +static bool resolveAllocationOverload( +Sema &S, LookupResult &R, SourceRange Range, SmallVectorImpl &Args, +bool &PassAlignment, FunctionDecl *&Operator, +OverloadCandidateSet *AlignedCandidates, Expr *AlignArg, bool Diagnose) { OverloadCandidateSet Candidates(R.getNameLoc(), OverloadCandidateSet::CSK_Normal); for (LookupResult::iterator Alloc = R.begin(), AllocEnd = R.end(); @@ -2202,7 +2200,8 @@ AlignArg = Args[1]; Args.erase(Args.begin() + 1); return resolveAllocationOverload(S, R, Range, Args, PassAlignment, - Operator, &Candidates, AlignArg); + Operator, &Candidates, AlignArg, + Diagnose); } // MSVC will fall back on trying to find a matching global operator new @@ -2218,48 +2217,53 @@ S.LookupQualifiedName(R, S.Context.getTranslationUnitDecl()); // FIXME: This will give bad diagnostics pointing at the wrong functions. return resolveAllocationOverload(S, R, Range, Args, PassAlignment, - Operator, nullptr); + Operator, /*Candidates=*/nullptr, + /*AlignArg=*/nullptr, Diagnose); } -S.Diag(R.getNameLoc(), diag::err_ovl_no_viable_function_in_call) - << R.getLookupName() << Range; - -// If we have aligned candidates, only note the align_val_t candidates -// from AlignedCandidates and the non-align_val_t candidates from -// Candidates. -if (AlignedCandidates) { - auto IsAligned = [](OverloadCandidate &C) { -return C.Function->getNumParams() > 1 && - C.Function->getParamDecl(1)->getType()->isAlignValT(); - }; - auto IsUnaligned = [&](OverloadCandidate &C) { return !IsAligned(C); }; - - // This was an overaligned allocation, so list the aligned candidates - // first. - Args.insert(Args.begin() + 1, AlignArg); - AlignedCandidates->NoteCandidates(S, OCD_AllCandidates, Args, "", -R.getNameLoc(), IsAligned); - Args.erase(Args.begin() + 1); - Candidates.NoteCandidates(S, OCD_AllCandidates, Args, "", R.getNameLoc(), -IsUnaligned); -} else { - Candidates.NoteCandidates(S, OCD_AllCandidates, Args); +if (Diagnose) { + S.Diag(R.getNameLoc(), diag::err_ovl_no_viable_function_in_call) + << R.getLookupName() << Range; + + // If we have aligned candidates, only note the align_val_t candidates + // from AlignedCandidates and the non-align_val_t candidates from + // Candidates. + if (AlignedCandidates) { +auto IsAligned = [](OverloadCandidate &C) { + return C.Function->getNumParams() > 1 && + C.Function->getParamDecl(1)->getType()->isAlignValT(); +}; +auto IsUnaligned = [&](OverloadCandidate &C) { return !IsAligned(C); }; + +// This was an overaligned allocation, so list the aligned candidates +// first. +Args.insert(Args.begin() + 1, AlignArg); +AlignedCandidates->NoteCandidates(S, OCD_AllCandidates, Args, "", + R.getNameLoc(), IsAligned); +Args.erase(Args.begin() + 1); +Candidates.NoteCandidates(S, OCD_AllCandidates, Args, "", R.getNameLoc(), + IsUnaligned); + } else { +Candidates.NoteCandidates(S, OCD_AllCandidates, Args); + } } return true; case OR_Ambiguous: -S.Diag(R.getNameLoc(), diag::err_ovl_ambiguous_call) - << R.getLookupName() << Range; -Candidates.NoteCandidates(S, OCD_ViableCandidates, Args); +if (Diagnose) { + S.Diag(R.getNameLoc(), diag::err_ovl_ambiguous_call) + << R.getLookupName() << Range; + Candidates.NoteCandidates(S, OCD_ViableCandidates, Args); +} return true; case OR_Deleted: { -S.Diag(R.getNameLoc(), diag::err_ovl_deleted_call) - << Best->Function->isDeleted() - << R.getLookupName() - << S.getDele
[PATCH] D42606: [Coroutines] Use allocator overload when available
modocache updated this revision to Diff 131729. modocache added a comment. Add some diagnostics tests to SemaCXX/coroutines.cpp. Repository: rC Clang https://reviews.llvm.org/D42606 Files: lib/CodeGen/CGCoroutine.cpp lib/Sema/SemaCoroutine.cpp test/CodeGenCoroutines/coro-alloc.cpp test/SemaCXX/coroutines.cpp Index: test/SemaCXX/coroutines.cpp === --- test/SemaCXX/coroutines.cpp +++ test/SemaCXX/coroutines.cpp @@ -781,6 +781,68 @@ } template coro dependent_uses_nothrow_new(good_promise_13); +struct good_promise_custom_new_operator { + coro get_return_object(); + suspend_always initial_suspend(); + suspend_always final_suspend(); + void return_void(); + void unhandled_exception(); + void *operator new(unsigned long, double, float, int); +}; + +coro +good_coroutine_calls_custom_new_operator(double, float, int) { + co_return; +} + +struct bad_promise_mismatched_custom_new_operator { + coro get_return_object(); + suspend_always initial_suspend(); + suspend_always final_suspend(); + void return_void(); + void unhandled_exception(); + // expected-note@+1 {{candidate function not viable: requires 4 arguments, but 1 was provided}} + void *operator new(unsigned long, double, float, int); +}; + +coro +bad_coroutine_calls_mismatched_custom_new_operator(double) { + // expected-error@-1 {{no matching function for call to 'operator new'}} + co_return; +} + +struct bad_promise_throwing_custom_new_operator { + static coro get_return_object_on_allocation_failure(); + coro get_return_object(); + suspend_always initial_suspend(); + suspend_always final_suspend(); + void return_void(); + void unhandled_exception(); + // expected-error@+1 {{'operator new' is required to have a non-throwing noexcept specification when the promise type declares 'get_return_object_on_allocation_failure()'}} + void *operator new(unsigned long, double, float, int); +}; + +coro +bad_coroutine_calls_throwing_custom_new_operator(double, float, int) { + // expected-note@-1 {{call to 'operator new' implicitly required by coroutine function here}} + co_return; +} + +struct good_promise_noexcept_custom_new_operator { + static coro get_return_object_on_allocation_failure(); + coro get_return_object(); + suspend_always initial_suspend(); + suspend_always final_suspend(); + void return_void(); + void unhandled_exception(); + void *operator new(unsigned long, double, float, int) noexcept; +}; + +coro +good_coroutine_calls_noexcept_custom_new_operator(double, float, int) { + co_return; +} + struct mismatch_gro_type_tag1 {}; template<> struct std::experimental::coroutine_traits { Index: test/CodeGenCoroutines/coro-alloc.cpp === --- test/CodeGenCoroutines/coro-alloc.cpp +++ test/CodeGenCoroutines/coro-alloc.cpp @@ -106,6 +106,34 @@ co_return; } +struct promise_matching_placement_new_tag {}; + +template<> +struct std::experimental::coroutine_traits { + struct promise_type { +void *operator new(unsigned long, promise_matching_placement_new_tag, + int, float, double); +void get_return_object() {} +suspend_always initial_suspend() { return {}; } +suspend_always final_suspend() { return {}; } +void return_void() {} + }; +}; + +// CHECK-LABEL: f1a( +extern "C" void f1a(promise_matching_placement_new_tag, int x, float y , double z) { + // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16 + // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64() + // CHECK: store i32 %x, i32* %coro.allocate.x.addr, align 4 + // CHECK: %[[INT:.+]] = load i32, i32* %coro.allocate.x.addr, align 4 + // CHECK: store float %y, float* %coro.allocate.y.addr, align 4 + // CHECK: %[[FLOAT:.+]] = load float, float* %coro.allocate.y.addr, align 4 + // CHECK: store double %z, double* %coro.allocate.z.addr, align 8 + // CHECK: %[[DOUBLE:.+]] = load double, double* %coro.allocate.z.addr, align 8 + // CHECK: call i8* @_ZNSt12experimental16coroutine_traitsIJv34promise_matching_placement_new_tagifdEE12promise_typenwEmS1_ifd(i64 %[[SIZE]], i32 %[[INT]], float %[[FLOAT]], double %[[DOUBLE]]) + co_return; +} + struct promise_delete_tag {}; template<> Index: lib/Sema/SemaCoroutine.cpp === --- lib/Sema/SemaCoroutine.cpp +++ lib/Sema/SemaCoroutine.cpp @@ -1050,18 +1050,54 @@ const bool RequiresNoThrowAlloc = ReturnStmtOnAllocFailure != nullptr; - // FIXME: Add support for stateful allocators. + // [dcl.fct.def.coroutine]/7 + // Lookup allocation functions using a parameter list composed of the + // requested size of the coroutine state being allocated, followed by + // the coroutine function's arguments. If a matching allocation function + // exists, use it. Otherwise, use an allocation function that just takes + // the requested size. FunctionDecl *OperatorNew = nullptr; Function
[PATCH] D42464: add prefix with '_' support for property name. Corresponding apple dev doc: https://developer.apple.com/library/content/qa/qa1908/_index.html
Wizard marked 3 inline comments as done. Wizard added inline comments. Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:115 + +bool prefixedPropertyNameMatches(const llvm::StringRef &PropertyName, + const std::vector &Acronyms) { hokein wrote: > Wizard wrote: > > hokein wrote: > > > no need to pass const reference of `llvm::StringRef`. `StringRef` is > > > cheap. > > The original property name I directly get from ast is a const. If I remove > > the const here, I will have to make a copy of the property name before > > calling this. > > I prefer keep this const to save that copy :-) > Why? `MatchedDecl->getName()` returns `llvm::StringRef`. As the name > indicates, StringRef is a const reference of String, using StringRef is > sufficient. > > The same to ArrayRef. So the function is like `bool > prefixedPropertyNameMatches(llvm::StringRef PropertyName, > llvm::ArrayRef Acronyms)`. > > If I remove the const in the method, compiler will have error of "candidate function not viable: expects an l-value for 1st argument". I believe it cannot accept a const reference as arg if the definition is var. Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:151 + hasCategoryPropertyPrefix(MatchedDecl->getName())) { +const auto *CategoryDecl = (const ObjCCategoryDecl *)(DeclContext); +if (!prefixedPropertyNameMatches(MatchedDecl->getName(), SpecialAcronyms) || hokein wrote: > Wizard wrote: > > hokein wrote: > > > Consider using `const auto* CategoryDecl = > > > dyn_cast(DeclContext)`, we can get rid of this cast, > > > and `NodeKind` variable. > > Tried that before but I encountered 2 issues: > > 1. 'clang::DeclContext' is not polymorphic > > 2. cannot use dynamic_cast with -fno-rtti > > which are preventing me from using dynamic_cast > Sorry, I mean `llvm::dyn_cast` here, it should work. It is not working either. It says "error: static_cast from 'clang::Decl *' to 'const clang::ObjCCategoryDecl *const *' is not allowed" though I have no idea why it is regarded as a static cast. I am using it like this: const auto *CategoryDecl = llvm::dyn_cast(DeclContext); Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:121 + +bool hasCategoryPropertyPrefix(const llvm::StringRef &PropertyName) { + auto RegexExp = llvm::Regex("^[a-z]+_[a-zA-Z0-9][a-zA-Z0-9_]+$"); hokein wrote: > The same: `llvm::StringRef` Cannot remove the const for the same reason. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D42464 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42464: add prefix with '_' support for property name. Corresponding apple dev doc: https://developer.apple.com/library/content/qa/qa1908/_index.html
Wizard updated this revision to Diff 131741. Wizard added a comment. resolve comments Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D42464 Files: clang-tidy/objc/PropertyDeclarationCheck.cpp docs/clang-tidy/checks/objc-property-declaration.rst test/clang-tidy/objc-property-declaration-custom.m test/clang-tidy/objc-property-declaration.m Index: test/clang-tidy/objc-property-declaration.m === --- test/clang-tidy/objc-property-declaration.m +++ test/clang-tidy/objc-property-declaration.m @@ -3,11 +3,22 @@ @interface Foo @property(assign, nonatomic) int NotCamelCase; -// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'NotCamelCase' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration] +// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'NotCamelCase' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration] // CHECK-FIXES: @property(assign, nonatomic) int notCamelCase; @property(assign, nonatomic) int camelCase; @property(strong, nonatomic) NSString *URLString; @property(strong, nonatomic) NSString *bundleID; @property(strong, nonatomic) NSString *URL_string; -// CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration] +// CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration] @end + +@interface Foo (Bar) +@property(assign, nonatomic) int abc_NotCamelCase; +// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'abc_NotCamelCase' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration] +@property(assign, nonatomic) int abc_camelCase; +@end + +@interface Foo () +@property(assign, nonatomic) int abc_camelCase; +// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'abc_camelCase' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration] +@end \ No newline at end of file Index: test/clang-tidy/objc-property-declaration-custom.m === --- test/clang-tidy/objc-property-declaration-custom.m +++ test/clang-tidy/objc-property-declaration-custom.m @@ -6,9 +6,9 @@ @interface Foo @property(assign, nonatomic) int AbcNotRealPrefix; -// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'AbcNotRealPrefix' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration] +// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'AbcNotRealPrefix' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration] // CHECK-FIXES: @property(assign, nonatomic) int abcNotRealPrefix; @property(assign, nonatomic) int ABCCustomPrefix; @property(strong, nonatomic) NSString *ABC_custom_prefix; -// CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'ABC_custom_prefix' should use lowerCamelCase style, according to the Apple Coding Guidelines [objc-property-declaration] +// CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'ABC_custom_prefix' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration] @end Index: docs/clang-tidy/checks/objc-property-declaration.rst === --- docs/clang-tidy/checks/objc-property-declaration.rst +++ docs/clang-tidy/checks/objc-property-declaration.rst @@ -32,6 +32,15 @@ The corresponding style rule: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingIvarsAndTypes.html#//apple_ref/doc/uid/20001284-1001757 +The check will also accept property declared in category with a prefix of +lowercase letters followed by a '_' to avoid naming conflict. For example: + +.. code-block:: objc +@property(nonatomic, assign) int abc_lowerCamelCase; + +The corresponding style rule: https://developer.apple.com/library/content/qa/qa1908/_index.html + + Options --- Index: clang-tidy/objc/PropertyDeclarationCheck.cpp === --- clang-tidy/objc/PropertyDeclarationCheck.cpp +++ clang-tidy/objc/PropertyDeclarationCheck.cpp @@ -8,20 +8,31 @@ //===--===// #include "PropertyDeclarationCheck.h" +#include #include "../utils/OptionsUtils.h" #include "clang/AST/ASTContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Basic/CharInfo.h" #include "llvm/ADT/Strin
[PATCH] D41829: [cmake] WIP: Add cache file to bootstrap linux cross compile on Darwin.
hintonda updated this revision to Diff 131742. hintonda edited the summary of this revision. hintonda added a comment. - Libfuzzers won't build, so turn off. - Fix typos, and set cache. Repository: rC Clang https://reviews.llvm.org/D41829 Files: cmake/caches/Linux.cmake Index: cmake/caches/Linux.cmake === --- /dev/null +++ cmake/caches/Linux.cmake @@ -0,0 +1,98 @@ +# This file is primarily for cross compiling clang+llvm, et al, for +# Linux on Darwin, and can be invoked like this: +# +# cmake -GNinja -DBOOTSTRAP_CMAKE_SYSROOT= [OPTIONS] \ +#-C /cmake/caches/Linux.cmake ../llvm +# +# Use "BOOTSTRAP_" prefix to pass options to stage2, e.g., +# "-DBOOTSTRAP_CMAKE_BUILD_TYPE=Release", and +# "-DSTAGE2_CACHE_FILE=" to specify a stage2 cache file. +# + + +if(NOT DEFINED BOOTSTRAP_CMAKE_SYSROOT) + message(FATAL_ERROR "Missing required argument -DBOOTSTRAP_CMAKE_SYSROOT=.") +endif() + +# FIXME: Default to Linux, but should this be required? +if(NOT DEFINED BOOTSTRAP_CMAKE_SYSTEM_NAME) + set(BOOTSTRAP_CMAKE_SYSTEM_NAME Linux CACHE STRING "") +endif() + +# FIXME: Should this default be based on BOOTSTRAP_CMAKE_SYSTEM_NAME? +if(NOT DEFINED BOOTSTRAP_LLVM_DEFAULT_TARGET_TRIPLE) + set(BOOTSTRAP_LLVM_DEFAULT_TARGET_TRIPLE "x86_64-unknown-linux-gnu" CACHE STRING "") +endif() + +if(NOT DEFINED BOOTSTRAP_GCC_INSTALL_PREFIX) + # Force clang to look for gcc at runtime -- otherwise it will + # default to 4.2.1. + set(BOOTSTRAP_GCC_INSTALL_PREFIX "/usr" CACHE STRING "") +endif() + +# Allow user to pass a custom stage2 cache file. +if(DEFINED STAGE2_CACHE_FILE) + if(NOT IS_ABSOLUTE ${STAGE2_CACHE_FILE}) +message(SEND_ERROR "STAGE2_CACHE_FILE [${STAGE2_CACHE_FILE}] must be an absolute path.") + endif() + if(NOT EXISTS ${STAGE2_CACHE_FILE}) +message(SEND_ERROR "STAGE2_CACHE_FILE [${STAGE2_CACHE_FILE}] does not exist.") + endif() + list(APPEND EXTRA_ARGS -C${STAGE2_CACHE_FILE}) +endif() + +list(APPEND EXTRA_ARGS + -DCMAKE_C_COMPILER_TARGET=${BOOTSTRAP_LLVM_DEFAULT_TARGET_TRIPLE} + -DCMAKE_CXX_COMPILER_TARGET=${BOOTSTRAP_LLVM_DEFAULT_TARGET_TRIPLE} + -DCMAKE_ASM_COMPILER_TARGET=${BOOTSTRAP_LLVM_DEFAULT_TARGET_TRIPLE} + + # Adjust the default behaviour of the FIND_XXX() commands to only + # search for headers and libraries in the + # CMAKE_SYSROOT/CMAKE_FIND_ROOT_PATH, and always search for programs + # in the host system. These all default to BOTH. + -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER + -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY + -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY + ) + +set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "") +set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "") +set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "") + +set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "") +set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "") +set(LLVM_INCLUDE_RUNTIMES OFF CACHE BOOL "") +set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "") +set(LLVM_INCLUDE_UTILS OFF CACHE BOOL "") +set(CLANG_BUILD_TOOLS OFF CACHE BOOL "") +set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "") +set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "") + +# FIXME: Is there a better way to specify this? i.e., target is elf, +# but host isn't. +if(CMAKE_HOST_APPLE) + # Make sure at least clang and lld are included. + set(LLVM_ENABLE_PROJECTS ${LLVM_ENABLE_PROJECTS} clang lld CACHE STRING "") + + # Passing -fuse-ld=lld is hard for cmake to handle correctly, so + # make lld the default linker. + set(CLANG_DEFAULT_LINKER lld CACHE STRING "") + + set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "") + + list(APPEND EXTRA_ARGS +# FIXME: Libfuzzer won't build correctly, so turn off for now. +-DCOMPILER_RT_BUILD_LIBFUZZER=OFF +-DLLVM_ENABLE_LLD=ON +-DCMAKE_AR=${CMAKE_BINARY_DIR}/bin/llvm-ar +-DCMAKE_OBJCOPY=${CMAKE_BINARY_DIR}/bin/llvm-objcopy +-DCMAKE_RANLIB=${CMAKE_BINARY_DIR}/bin/llvm-ranlib +-DCLANG_TABLEGEN=${CMAKE_BINARY_DIR}/bin/clang-tblgen +-DLLVM_TABLEGEN=${CMAKE_BINARY_DIR}/bin/llvm-tblgen +-DLLVM_CONFIG_PATH=${CMAKE_BINARY_DIR}/bin/llvm-config +) + +endif() + +set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") +set(CLANG_BOOTSTRAP_CMAKE_ARGS ${EXTRA_ARGS} CACHE STRING "") ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r323627 - [NFC] fix trivial typos in comments
Author: inouehrs Date: Sun Jan 28 21:15:18 2018 New Revision: 323627 URL: http://llvm.org/viewvc/llvm-project?rev=323627&view=rev Log: [NFC] fix trivial typos in comments "to to" -> "to" Modified: cfe/trunk/lib/Headers/opencl-c.h cfe/trunk/test/Driver/cl-pch-search.cpp cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Modified: cfe/trunk/lib/Headers/opencl-c.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=323627&r1=323626&r2=323627&view=diff == --- cfe/trunk/lib/Headers/opencl-c.h (original) +++ cfe/trunk/lib/Headers/opencl-c.h Sun Jan 28 21:15:18 2018 @@ -12862,7 +12862,7 @@ void __ovld mem_fence(cl_mem_fence_flags * Read memory barrier that orders only * loads. * The flags argument specifies the memory - * address space and can be set to to a + * address space and can be set to a * combination of the following literal * values: * CLK_LOCAL_MEM_FENCE @@ -12874,7 +12874,7 @@ void __ovld read_mem_fence(cl_mem_fence_ * Write memory barrier that orders only * stores. * The flags argument specifies the memory - * address space and can be set to to a + * address space and can be set to a * combination of the following literal * values: * CLK_LOCAL_MEM_FENCE Modified: cfe/trunk/test/Driver/cl-pch-search.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-pch-search.cpp?rev=323627&r1=323626&r2=323627&view=diff == --- cfe/trunk/test/Driver/cl-pch-search.cpp (original) +++ cfe/trunk/test/Driver/cl-pch-search.cpp Sun Jan 28 21:15:18 2018 @@ -2,5 +2,5 @@ // command-line option, e.g. on Mac where %s is commonly under /Users. // REQUIRES: x86-registered-target -// Check that pchfile.h next to to pchfile.cc is found correctly. +// Check that pchfile.h next to pchfile.cc is found correctly. // RUN: %clang_cl -Werror --target=x86_64-windows /Ycpchfile.h /FIpchfile.h /c /Fo%t.obj /Fp%t.pch -- %S/Inputs/pchfile.cpp Modified: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp?rev=323627&r1=323626&r2=323627&view=diff == --- cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp (original) +++ cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Sun Jan 28 21:15:18 2018 @@ -412,7 +412,7 @@ class ObjectFileHandler final : public F /// read from the buffers. unsigned NumberOfProcessedInputs = 0; - /// LLVM context used to to create the auxiliary modules. + /// LLVM context used to create the auxiliary modules. LLVMContext VMContext; /// LLVM module used to create an object with all the bundle ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits