[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
chrib updated this revision to Diff 94329. chrib added a comment. - NeedsUnwindTable check thumb arch https://reviews.llvm.org/D31140 Files: lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h Index: lib/CodeGen/CodeGenModule.h === --- lib/CodeGen/CodeGenModule.h +++ lib/CodeGen/CodeGenModule.h @@ -1341,6 +1341,11 @@ void ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone, bool AttrOnCallSite, llvm::AttrBuilder &FuncAttrs); + + /// Check whether the attribute UWTable must be set to emit the unwind table + /// for exceptions + bool NeedsUnwindTable(); + }; } // end namespace CodeGen } // end namespace clang Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -865,13 +865,27 @@ return true; } +// This function needs an unwind table +bool CodeGenModule::NeedsUnwindTable() { + if (CodeGenOpts.UnwindTables) +return true; + + llvm::Triple::ArchType Arch = Context.getTargetInfo().getTriple().getArch(); + return hasUnwindExceptions (LangOpts) && +(Arch == llvm::Triple::arm || + Arch == llvm::Triple::thumb); +} + void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F) { llvm::AttrBuilder B; - if (CodeGenOpts.UnwindTables) + // Set the attribute if the user requests it or if the language requiers it. + if (NeedsUnwindTable()) B.addAttribute(llvm::Attribute::UWTable); + // If the module doesn't support exceptions the function cannot throw. + // We can have a nothrow function even if unwind tables are required. if (!hasUnwindExceptions(LangOpts)) B.addAttribute(llvm::Attribute::NoUnwind); Index: lib/CodeGen/CodeGenModule.h === --- lib/CodeGen/CodeGenModule.h +++ lib/CodeGen/CodeGenModule.h @@ -1341,6 +1341,11 @@ void ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone, bool AttrOnCallSite, llvm::AttrBuilder &FuncAttrs); + + /// Check whether the attribute UWTable must be set to emit the unwind table + /// for exceptions + bool NeedsUnwindTable(); + }; } // end namespace CodeGen } // end namespace clang Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -865,13 +865,27 @@ return true; } +// This function needs an unwind table +bool CodeGenModule::NeedsUnwindTable() { + if (CodeGenOpts.UnwindTables) +return true; + + llvm::Triple::ArchType Arch = Context.getTargetInfo().getTriple().getArch(); + return hasUnwindExceptions (LangOpts) && +(Arch == llvm::Triple::arm || + Arch == llvm::Triple::thumb); +} + void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F) { llvm::AttrBuilder B; - if (CodeGenOpts.UnwindTables) + // Set the attribute if the user requests it or if the language requiers it. + if (NeedsUnwindTable()) B.addAttribute(llvm::Attribute::UWTable); + // If the module doesn't support exceptions the function cannot throw. + // We can have a nothrow function even if unwind tables are required. if (!hasUnwindExceptions(LangOpts)) B.addAttribute(llvm::Attribute::NoUnwind); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27334: [OpenCL] Ambiguous function call.
echuraev added a comment. In https://reviews.llvm.org/D27334#700521, @Anastasia wrote: > I don't actually. But remembering the follow up discussion: > http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20161205/178846.html > and since we have to deviate from the standard C/C++ implementation anyways > I am wondering whether modifying overloading resolution is a better way to go? Yes, I remember this discussion. But we saw this problem in the real OpenCL code and this warning is able to help developer to understand where his code could be ambiguous. Actually, I don't know the modifying overloading resolution is a better way to go or not. Do you have any suggestions how could we notify developer about this potential problem in better way? https://reviews.llvm.org/D27334 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31745: [OpenCL] Added diagnostic for implicit declaration of function in OpenCL
echuraev created this revision. Herald added a subscriber: yaxunl. https://reviews.llvm.org/D31745 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDecl.cpp test/SemaOpenCL/clang-builtin-version.cl test/SemaOpenCL/to_addr_builtin.cl Index: test/SemaOpenCL/to_addr_builtin.cl === --- test/SemaOpenCL/to_addr_builtin.cl +++ test/SemaOpenCL/to_addr_builtin.cl @@ -10,7 +10,7 @@ glob = to_global(glob, loc); #if __OPENCL_C_VERSION__ < CL_VERSION_2_0 - // expected-warning@-2{{implicit declaration of function 'to_global' is invalid in C99}} + // expected-error@-2{{implicit declaration of function 'to_global' is invalid in OpenCL}} // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}} #else // expected-error@-5{{invalid number of arguments to function: 'to_global'}} Index: test/SemaOpenCL/clang-builtin-version.cl === --- test/SemaOpenCL/clang-builtin-version.cl +++ test/SemaOpenCL/clang-builtin-version.cl @@ -4,41 +4,56 @@ kernel void dse_builtins() { int tmp; - enqueue_kernel(tmp, tmp, tmp, ^(void) { // expected-warning{{implicit declaration of function 'enqueue_kernel' is invalid in C99}} + enqueue_kernel(tmp, tmp, tmp, ^(void) { // expected-error{{implicit declaration of function 'enqueue_kernel' is invalid in OpenCL}} return; }); - unsigned size = get_kernel_work_group_size(^(void) { // expected-warning{{implicit declaration of function 'get_kernel_work_group_size' is invalid in C99}} + unsigned size = get_kernel_work_group_size(^(void) { // expected-error{{implicit declaration of function 'get_kernel_work_group_size' is invalid in OpenCL}} return; }); - size = get_kernel_preferred_work_group_size_multiple(^(void) { // expected-warning{{implicit declaration of function 'get_kernel_preferred_work_group_size_multiple' is invalid in C99}} + size = get_kernel_preferred_work_group_size_multiple(^(void) { // expected-error{{implicit declaration of function 'get_kernel_preferred_work_group_size_multiple' is invalid in OpenCL}} return; }); } void pipe_builtins() { int tmp; - read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'read_pipe' is invalid in C99}} - write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'write_pipe' is invalid in C99}} - - reserve_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'reserve_read_pipe' is invalid in C99}} - reserve_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'reserve_write_pipe' is invalid in C99}} - - work_group_reserve_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'work_group_reserve_read_pipe' is invalid in C99}} - work_group_reserve_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'work_group_reserve_write_pipe' is invalid in C99}} - - sub_group_reserve_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'sub_group_reserve_write_pipe' is invalid in C99}} - sub_group_reserve_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'sub_group_reserve_read_pipe' is invalid in C99}} - - commit_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'commit_read_pipe' is invalid in C99}} - commit_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'commit_write_pipe' is invalid in C99}} - - work_group_commit_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'work_group_commit_read_pipe' is invalid in C99}} - work_group_commit_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'work_group_commit_write_pipe' is invalid in C99}} - - sub_group_commit_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'sub_group_commit_write_pipe' is invalid in C99}} - sub_group_commit_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'sub_group_commit_read_pipe' is invalid in C99}} - - get_pipe_num_packets(tmp); // expected-warning{{implicit declaration of function 'get_pipe_num_packets' is invalid in C99}} - get_pipe_max_packets(tmp); // expected-warning{{implicit declaration of function 'get_pipe_max_packets' is invalid in C99}} + read_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'read_pipe' is invalid in OpenCL}} + write_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'write_pipe' is invalid in OpenCL}} + + reserve_read_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'reserve_read_pipe' is invalid in OpenCL}} + // expected-note@-1{{'reserve_read_pipe' declared here}} + reserve_write_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'reserve_write_pipe' is invalid in OpenCL}} + // expected-n
[PATCH] D31713: [Basic] getColumnNumber returns location of CR+LF on Windows
alexfh accepted this revision. alexfh added a comment. This revision is now accepted and ready to land. LG with one nit. Thank you for tracking down this bug and fixing it! Comment at: lib/Basic/SourceManager.cpp:1153 + if (FilePos + 1 == LineEnd && FilePos > LineStart) { +const char *Buf = MemBuf->getBufferStart(); +if (Buf[FilePos - 1] == '\r' || Buf[FilePos - 1] == '\n') I'd move this line before the outermost `if` and remove the identical line below. Repository: rL LLVM https://reviews.llvm.org/D31713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator
bradfier updated this revision to Diff 94334. bradfier added a reviewer: klimek. bradfier added a comment. Add more diff context, add klimek as reviewer. Repository: rL LLVM https://reviews.llvm.org/D31652 Files: include/clang/Basic/LangOptions.def include/clang/Basic/TokenKinds.def lib/Format/Format.cpp lib/Lex/Lexer.cpp unittests/Format/FormatTestJava.cpp Index: unittests/Format/FormatTestJava.cpp === --- unittests/Format/FormatTestJava.cpp +++ unittests/Format/FormatTestJava.cpp @@ -522,5 +522,17 @@ " void f() {}")); } +TEST_F(FormatTestJava, RetainsLogicalShiftAssignments) { +verifyFormat("void f() {\n" + " int a = 1;\n" + " a >>>= 1;\n" + "}"); +verifyFormat("void f() {\n" + " int a = 1;\n" + " a <<<= 1;\n" + "}"); +} + + } // end namespace tooling } // end namespace clang Index: lib/Lex/Lexer.cpp === --- lib/Lex/Lexer.cpp +++ lib/Lex/Lexer.cpp @@ -2967,7 +2967,7 @@ Result.setFlag(Token::LeadingSpace); } - unsigned SizeTmp, SizeTmp2; // Temporaries for use in cases below. + unsigned SizeTmp, SizeTmp2, SizeTmp3; // Temporaries for use in cases below. // Read a character, advancing over it. char Char = getAndAdvanceChar(CurPtr, Result); @@ -3449,6 +3449,14 @@ Kind = tok::lesslessless; CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), SizeTmp2, Result); + } else if (LangOpts.Java && After == '<') { + char Fourth = getCharAndSize(CurPtr+SizeTmp+SizeTmp2, SizeTmp3); + if (Fourth == '=') { + Kind = tok::lesslesslessequal; + CurPtr = ConsumeChar(ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), + SizeTmp2, Result), + SizeTmp3, Result); + } } else { CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); Kind = tok::lessless; @@ -3505,6 +3513,14 @@ Kind = tok::greatergreatergreater; CurPtr = ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), SizeTmp2, Result); + } else if (LangOpts.Java && After == '>') { + char Fourth = getCharAndSize(CurPtr+SizeTmp+SizeTmp2, SizeTmp3); + if (Fourth == '=') { + Kind = tok::greatergreatergreaterequal; + CurPtr = ConsumeChar(ConsumeChar(ConsumeChar(CurPtr, SizeTmp, Result), + SizeTmp2, Result), + SizeTmp3, Result); + } } else { CurPtr = ConsumeChar(CurPtr, SizeTmp, Result); Kind = tok::greatergreater; Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1903,6 +1903,7 @@ LangOpts.ObjC2 = 1; LangOpts.MicrosoftExt = 1;// To get kw___try, kw___finally. LangOpts.DeclSpecKeyword = 1; // To get __declspec. + LangOpts.Java = Style.Language == FormatStyle::LK_Java; return LangOpts; } Index: include/clang/Basic/TokenKinds.def === --- include/clang/Basic/TokenKinds.def +++ include/clang/Basic/TokenKinds.def @@ -225,6 +225,10 @@ // CL support PUNCTUATOR(caretcaret,"^^") +// Java support (for clang-format only) +PUNCTUATOR(greatergreatergreaterequal, ">>>=") +PUNCTUATOR(lesslesslessequal, "<<<=") + // C99 6.4.1: Keywords. These turn into kw_* tokens. // Flags allowed: // KEYALL - This is a keyword in all variants of C and C++, or it Index: include/clang/Basic/LangOptions.def === --- include/clang/Basic/LangOptions.def +++ include/clang/Basic/LangOptions.def @@ -92,6 +92,7 @@ LANGOPT(CPlusPlus1z , 1, 0, "C++1z") LANGOPT(ObjC1 , 1, 0, "Objective-C 1") LANGOPT(ObjC2 , 1, 0, "Objective-C 2") +LANGOPT(Java , 1, 0, "Java") BENIGN_LANGOPT(ObjCDefaultSynthProperties , 1, 0, "Objective-C auto-synthesized properties") BENIGN_LANGOPT(EncodeExtendedBlockSig , 1, 0, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector
teemperor updated this revision to Diff 94337. teemperor added a comment. - Renamed variable from 'S' to 'Child' to make the buildbots happy (and because it's more expressive) - Fixed the name of the unit test. https://reviews.llvm.org/D23418 Files: include/clang/Analysis/CloneDetection.h lib/Analysis/CloneDetection.cpp lib/StaticAnalyzer/Checkers/CloneChecker.cpp unittests/Analysis/CMakeLists.txt unittests/Analysis/CloneDetectionTest.cpp Index: unittests/Analysis/CloneDetectionTest.cpp === --- /dev/null +++ unittests/Analysis/CloneDetectionTest.cpp @@ -0,0 +1,110 @@ +//===- unittests/Analysis/CloneDetectionTest.cpp - Clone detection tests --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "clang/AST/RecursiveASTVisitor.h" +#include "clang/Analysis/CloneDetection.h" +#include "clang/Tooling/Tooling.h" +#include "gtest/gtest.h" + +namespace clang { +namespace analysis { +namespace { + +class CloneDetectionVisitor +: public RecursiveASTVisitor { + + CloneDetector &Detector; + +public: + explicit CloneDetectionVisitor(CloneDetector &D) : Detector(D) {} + + bool VisitFunctionDecl(FunctionDecl *D) { +Detector.analyzeCodeBody(D); +return true; + } +}; + +/// Example constraint for testing purposes. +/// Filters out all statements that are in a function which name starts with +/// "bar". +class NoBarFunctionConstraint { +public: + void constrain(std::vector &CloneGroups) { +CloneConstraint::splitCloneGroups( +CloneGroups, [](const StmtSequence &A, const StmtSequence &B) { + // Check if one of the sequences is in a function which name starts + // with "bar". + for (const StmtSequence &Arg : {A, B}) { +if (const auto *D = +dyn_cast(Arg.getContainingDecl())) { + if (D->getNameAsString().find("bar") == 0) +return false; +} + } + return true; +}); + } +}; + +TEST(CloneDetector, FilterFunctionsByName) { + auto ASTUnit = + clang::tooling::buildASTFromCode("void foo1(int &a1) { a1++; }\n" + "void foo2(int &a2) { a2++; }\n" + "void bar1(int &a3) { a3++; }\n" + "void bar2(int &a4) { a4++; }\n"); + auto TU = ASTUnit->getASTContext().getTranslationUnitDecl(); + + CloneDetector Detector; + // Push all the function bodies into the detector. + CloneDetectionVisitor Visitor(Detector); + Visitor.TraverseTranslationUnitDecl(TU); + + // Find clones with the usual settings, but but we want to filter out + // all statements from functions which names start with "bar". + std::vector CloneGroups; + Detector.findClones(CloneGroups, NoBarFunctionConstraint(), + RecursiveCloneTypeIIConstraint(), + MinComplexityConstraint(2), MinGroupSizeConstraint(2), + OnlyLargestCloneConstraint()); + + ASSERT_EQ(CloneGroups.size(), 1u); + ASSERT_EQ(CloneGroups.front().size(), 2u); + + for (auto &Clone : CloneGroups.front()) { +const auto ND = dyn_cast(Clone.getContainingDecl()); +ASSERT_TRUE(ND != nullptr); +// Check that no function name starting with "bar" is in the results... +ASSERT_TRUE(ND->getNameAsString().find("bar") != 0); + } + + // Retry above's example without the filter... + CloneGroups.clear(); + + Detector.findClones(CloneGroups, RecursiveCloneTypeIIConstraint(), + MinComplexityConstraint(2), MinGroupSizeConstraint(2), + OnlyLargestCloneConstraint()); + ASSERT_EQ(CloneGroups.size(), 1u); + ASSERT_EQ(CloneGroups.front().size(), 4u); + + // Count how many functions with the bar prefix we have in the results. + int FoundFunctionsWithBarPrefix = 0; + for (auto &Clone : CloneGroups.front()) { +const auto ND = dyn_cast(Clone.getContainingDecl()); +ASSERT_TRUE(ND != nullptr); +// This time check that we picked up the bar functions from above +if (ND->getNameAsString().find("bar") == 0) { + FoundFunctionsWithBarPrefix++; +} + } + // We should have found the two functions bar1 and bar2. + ASSERT_EQ(FoundFunctionsWithBarPrefix, 2); +} +} // namespace +} // namespace analysis +} // namespace clang Index: unittests/Analysis/CMakeLists.txt === --- unittests/Analysis/CMakeLists.txt +++ unittests/Analysis/CMakeLists.txt @@ -2,11 +2,12 @@ Support ) -add_clang_unittest(CFGTests +add_clang_unittest(ClangAnalysisTests CFGTest.cpp + CloneDetectionTest.cpp ) -target_link_libraries(CFGTests +target_link_libraries(ClangAnalysisTests
[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector
teemperor added inline comments. Comment at: lib/Analysis/CloneDetection.cpp:395 + + for (const Stmt *Child : S->children()) { +if (Child == nullptr) { I couldn't reproduce, but from what I assume form the warning and the crash that we confused the compiler here by naming both the loop-variable and the parameter 'S'. I renamed it to 'Child' which /should/ fix it. https://reviews.llvm.org/D23418 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29621: Add ASTMatchRefactorer and ReplaceNodeWithTemplate to RefactoringCallbacks
ioeric added a comment. Still LGTM. Please run `ninja check-clang` and fix the warning. I'll land this patch for you afterwards. Comment at: lib/Tooling/RefactoringCallbacks.cpp:222 +} +default: + llvm_unreachable("Element.Type not recognized"); ``` ninja check-clang RefactoringCallbacks.cpp:222:5: warning: default label in switch which covers all enumeration values [-Wcovered-switch-default] ``` Please remove the `default`. https://reviews.llvm.org/D29621 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30547: [clang-tidy] Forwarding reference overload in constructors
This revision was automatically updated to reflect the committed changes. Closed by commit rL299638: [clang-tidy] Check for forwarding reference overload in constructors. (authored by xazax). Changed prior to commit: https://reviews.llvm.org/D30547?vs=94028&id=94339#toc Repository: rL LLVM https://reviews.llvm.org/D30547 Files: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt clang-tools-extra/trunk/clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/ForwardingReferenceOverloadCheck.h clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp clang-tools-extra/trunk/docs/ReleaseNotes.rst clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-forwarding-reference-overload.rst clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp Index: clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp === --- clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp +++ clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp @@ -0,0 +1,139 @@ +// RUN: %check_clang_tidy %s misc-forwarding-reference-overload %t + +namespace std { +template +struct enable_if {}; + +template +struct enable_if { typedef T type; }; + +template +using enable_if_t = typename enable_if::type; + +template +struct enable_if_nice { typedef T type; }; +} + +namespace foo { +template +struct enable_if { typedef T type; }; +} + +template +constexpr bool just_true = true; + +class Test1 { +public: + template + Test1(T &&n); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy and move constructors [misc-forwarding-reference-overload] + + template + Test1(T &&n, int i = 5, ...); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy and move constructors [misc-forwarding-reference-overload] + + template ::type> + Test1(T &&n); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy and move constructors [misc-forwarding-reference-overload] + + template + Test1(T &&n, typename foo::enable_if::type i = 5, ...); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy and move constructors [misc-forwarding-reference-overload] + + Test1(const Test1 &other) {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: note: copy constructor declared here + + Test1(Test1 &other) {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: note: copy constructor declared here + + Test1(Test1 &&other) {} + // CHECK-MESSAGES: :[[@LINE-1]]:3: note: move constructor declared here +}; + +template +class Test2 { +public: + // Two parameters without default value, can't act as copy / move constructor. + template + Test2(T &&n, V &&m, int i = 5, ...); + + // Guarded with enable_if. + template + Test2(T &&n, int i = 5, std::enable_if_t a = 5, ...); + + // Guarded with enable_if. + template ::type &> + Test2(T &&n); + + // Guarded with enable_if. + template + Test2(T &&n, typename std::enable_if>::type **a = nullptr); + + // Guarded with enable_if. + template > *&&> + Test2(T &&n, double d = 0.0); + + // Not a forwarding reference parameter. + template + Test2(const T &&n); + + // Not a forwarding reference parameter. + Test2(int &&x); + + // Two parameters without default value, can't act as copy / move constructor. + template + Test2(T &&n, int x); + + // Not a forwarding reference parameter. + template + Test2(U &&n); +}; + +// The copy and move constructors are both disabled. +class Test3 { +public: + template + Test3(T &&n); + + template + Test3(T &&n, int I = 5, ...); + + Test3(const Test3 &rhs) = delete; + +private: + Test3(Test3 &&rhs); +}; + +// Both the copy and the (compiler generated) move constructors can be hidden. +class Test4 { +public: + template + Test4(T &&n); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy and move constructors [misc-forwarding-reference-overload] + + Test4(const Test4 &rhs); + // CHECK-MESSAGES: :[[@LINE-1]]:3: note: copy constructor declared here +}; + +// Only the (compiler generated) copy constructor can be hidden. +class Test5 { +public: + template + Test5(T &&n); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy constructor [misc-forwarding-reference-overload] + + Test5(Test5 &&rhs) = delete; +}; + +// Only the move constructor can be hidden. +class Test6 { +public: + template + Test6(T &&n); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the move constructor [misc-forwarding-reference-overload] + + Test6(Test6 &&rhs); + // CH
[clang-tools-extra] r299638 - [clang-tidy] Check for forwarding reference overload in constructors.
Author: xazax Date: Thu Apr 6 04:56:42 2017 New Revision: 299638 URL: http://llvm.org/viewvc/llvm-project?rev=299638&view=rev Log: [clang-tidy] Check for forwarding reference overload in constructors. Patch by András Leitereg! Differential Revision: https://reviews.llvm.org/D30547 Added: clang-tools-extra/trunk/clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp clang-tools-extra/trunk/clang-tidy/misc/ForwardingReferenceOverloadCheck.h clang-tools-extra/trunk/docs/clang-tidy/checks/misc-forwarding-reference-overload.rst clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp clang-tools-extra/trunk/docs/ReleaseNotes.rst clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=299638&r1=299637&r2=299638&view=diff == --- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Thu Apr 6 04:56:42 2017 @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS support) add_clang_library(clangTidyMiscModule ArgumentCommentCheck.cpp AssertSideEffectCheck.cpp + ForwardingReferenceOverloadCheck.cpp MisplacedConstCheck.cpp UnconventionalAssignOperatorCheck.cpp BoolPointerImplicitConversionCheck.cpp Added: clang-tools-extra/trunk/clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp?rev=299638&view=auto == --- clang-tools-extra/trunk/clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp (added) +++ clang-tools-extra/trunk/clang-tidy/misc/ForwardingReferenceOverloadCheck.cpp Thu Apr 6 04:56:42 2017 @@ -0,0 +1,145 @@ +//===--- ForwardingReferenceOverloadCheck.cpp - clang-tidy-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "ForwardingReferenceOverloadCheck.h" +#include "clang/AST/ASTContext.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include + +using namespace clang::ast_matchers; + +namespace clang { +namespace tidy { +namespace misc { + +namespace { +// Check if the given type is related to std::enable_if. +AST_MATCHER(QualType, isEnableIf) { + auto CheckTemplate = [](const TemplateSpecializationType *Spec) { +if (!Spec || !Spec->getTemplateName().getAsTemplateDecl()) { + return false; +} +const NamedDecl *TypeDecl = +Spec->getTemplateName().getAsTemplateDecl()->getTemplatedDecl(); +return TypeDecl->isInStdNamespace() && + (TypeDecl->getName().equals("enable_if") || +TypeDecl->getName().equals("enable_if_t")); + }; + const Type *BaseType = Node.getTypePtr(); + // Case: pointer or reference to enable_if. + while (BaseType->isPointerType() || BaseType->isReferenceType()) { +BaseType = BaseType->getPointeeType().getTypePtr(); + } + // Case: type parameter dependent (enable_if>). + if (const auto *Dependent = BaseType->getAs()) { +BaseType = Dependent->getQualifier()->getAsType(); + } + if (CheckTemplate(BaseType->getAs())) { +return true; // Case: enable_if_t< >. + } else if (const auto *Elaborated = BaseType->getAs()) { +if (const auto *Qualifier = Elaborated->getQualifier()->getAsType()) { + if (CheckTemplate(Qualifier->getAs())) { +return true; // Case: enable_if< >::type. + } +} + } + return false; +} +AST_MATCHER_P(TemplateTypeParmDecl, hasDefaultArgument, + clang::ast_matchers::internal::Matcher, TypeMatcher) { + return Node.hasDefaultArgument() && + TypeMatcher.matches(Node.getDefaultArgument(), Finder, Builder); +} +} + +void ForwardingReferenceOverloadCheck::registerMatchers(MatchFinder *Finder) { + // Forwarding references require C++11 or later. + if (!getLangOpts().CPlusPlus11) +return; + + auto ForwardingRefParm = + parmVarDecl( + hasType(qualType(rValueReferenceType(), + references(templateTypeParmType(hasDeclaration( + templateTypeParmDecl().bind("type-parm-decl", + unless(references(isConstQualified()) + .bind("parm-var"); + + DeclarationMatcher findOverload = + cxxConstructorDecl( + hasParameter(0, ForwardingRefParm), + unless(hasAnyParameter( + // No warning: enable_if as constructo
r299639 - PR16106: Correct the docs to reflect the actual behavior of the interface.
Author: vvassilev Date: Thu Apr 6 05:05:46 2017 New Revision: 299639 URL: http://llvm.org/viewvc/llvm-project?rev=299639&view=rev Log: PR16106: Correct the docs to reflect the actual behavior of the interface. Modified: cfe/trunk/include/clang-c/Index.h Modified: cfe/trunk/include/clang-c/Index.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=299639&r1=299638&r2=299639&view=diff == --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Thu Apr 6 05:05:46 2017 @@ -478,8 +478,8 @@ CINDEX_LINKAGE void clang_getExpansionLo unsigned *offset); /** - * \brief Retrieve the file, line, column, and offset represented by - * the given source location, as specified in a # line directive. + * \brief Retrieve the file, line and column represented by the given source + * location, as specified in a # line directive. * * Example: given the following source code in a file somefile.c * ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31667: [Sema] Extend GetSignedVectorType to deal with non ExtVector types
sdardis marked an inline comment as done. sdardis added inline comments. Comment at: lib/Sema/SemaExpr.cpp:9736 + } + + if (TypeSize == Context.getTypeSize(Context.LongLongTy)) ahatanak wrote: > This isn't particularly urgent, but can we use ASTContext > ::getIntTypeForBitwidth here rather than calling getVectorType or > getExtVectorType in many places? > Yeah, it appears we can. I'll commit the current version and post a refactoring patch. https://reviews.llvm.org/D31667 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31667: [Sema] Extend GetSignedVectorType to deal with non ExtVector types
This revision was automatically updated to reflect the committed changes. Closed by commit rL299641: [Sema] Extend GetSignedVectorType to deal with non ExtVector types (authored by sdardis). Changed prior to commit: https://reviews.llvm.org/D31667?vs=94205&id=94344#toc Repository: rL LLVM https://reviews.llvm.org/D31667 Files: cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/Sema/vector-ops.c Index: cfe/trunk/lib/Sema/SemaExpr.cpp === --- cfe/trunk/lib/Sema/SemaExpr.cpp +++ cfe/trunk/lib/Sema/SemaExpr.cpp @@ -9711,24 +9711,45 @@ return InvalidOperands(Loc, LHS, RHS); } - -// Return a signed type that is of identical size and number of elements. -// For floating point vectors, return an integer type of identical size -// and number of elements. +// Return a signed ext_vector_type that is of identical size and number of +// elements. For floating point vectors, return an integer type of identical +// size and number of elements. In the non ext_vector_type case, search from +// the largest type to the smallest type to avoid cases where long long == long, +// where long gets picked over long long. QualType Sema::GetSignedVectorType(QualType V) { const VectorType *VTy = V->getAs(); unsigned TypeSize = Context.getTypeSize(VTy->getElementType()); - if (TypeSize == Context.getTypeSize(Context.CharTy)) -return Context.getExtVectorType(Context.CharTy, VTy->getNumElements()); - else if (TypeSize == Context.getTypeSize(Context.ShortTy)) -return Context.getExtVectorType(Context.ShortTy, VTy->getNumElements()); - else if (TypeSize == Context.getTypeSize(Context.IntTy)) -return Context.getExtVectorType(Context.IntTy, VTy->getNumElements()); + + if (isa(VTy)) { +if (TypeSize == Context.getTypeSize(Context.CharTy)) + return Context.getExtVectorType(Context.CharTy, VTy->getNumElements()); +else if (TypeSize == Context.getTypeSize(Context.ShortTy)) + return Context.getExtVectorType(Context.ShortTy, VTy->getNumElements()); +else if (TypeSize == Context.getTypeSize(Context.IntTy)) + return Context.getExtVectorType(Context.IntTy, VTy->getNumElements()); +else if (TypeSize == Context.getTypeSize(Context.LongTy)) + return Context.getExtVectorType(Context.LongTy, VTy->getNumElements()); +assert(TypeSize == Context.getTypeSize(Context.LongLongTy) && + "Unhandled vector element size in vector compare"); +return Context.getExtVectorType(Context.LongLongTy, VTy->getNumElements()); + } + + if (TypeSize == Context.getTypeSize(Context.LongLongTy)) +return Context.getVectorType(Context.LongLongTy, VTy->getNumElements(), + VectorType::GenericVector); else if (TypeSize == Context.getTypeSize(Context.LongTy)) -return Context.getExtVectorType(Context.LongTy, VTy->getNumElements()); - assert(TypeSize == Context.getTypeSize(Context.LongLongTy) && +return Context.getVectorType(Context.LongTy, VTy->getNumElements(), + VectorType::GenericVector); + else if (TypeSize == Context.getTypeSize(Context.IntTy)) +return Context.getVectorType(Context.IntTy, VTy->getNumElements(), + VectorType::GenericVector); + else if (TypeSize == Context.getTypeSize(Context.ShortTy)) +return Context.getVectorType(Context.ShortTy, VTy->getNumElements(), + VectorType::GenericVector); + assert(TypeSize == Context.getTypeSize(Context.CharTy) && "Unhandled vector element size in vector compare"); - return Context.getExtVectorType(Context.LongLongTy, VTy->getNumElements()); + return Context.getVectorType(Context.CharTy, VTy->getNumElements(), + VectorType::GenericVector); } /// CheckVectorCompareOperands - vector comparisons are a clang extension that @@ -9775,7 +9796,7 @@ assert (RHS.get()->getType()->hasFloatingRepresentation()); CheckFloatComparison(Loc, LHS.get(), RHS.get()); } - + // Return a signed type for the vector. return GetSignedVectorType(vType); } @@ -9792,7 +9813,7 @@ if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 && vType->hasFloatingRepresentation()) return InvalidOperands(Loc, LHS, RHS); - + return GetSignedVectorType(LHS.get()->getType()); } Index: cfe/trunk/test/Sema/vector-ops.c === --- cfe/trunk/test/Sema/vector-ops.c +++ cfe/trunk/test/Sema/vector-ops.c @@ -13,9 +13,9 @@ (void)(~v2fa); // expected-error{{invalid argument type 'v2f' (vector of 2 'float' values) to unary}} // Comparison operators - v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from 'int __attribute__((ext_vector_type(2)))' (vector of 2 'int' values)}} + v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assign
r299641 - [Sema] Extend GetSignedVectorType to deal with non ExtVector types
Author: sdardis Date: Thu Apr 6 05:38:03 2017 New Revision: 299641 URL: http://llvm.org/viewvc/llvm-project?rev=299641&view=rev Log: [Sema] Extend GetSignedVectorType to deal with non ExtVector types This improves some error messages which would otherwise refer to ext_vector_type types in contexts where there are no such types. Factored out from D25866 at reviewer's request. Reviewers: bruno Differential Revision: https://reviews.llvm.org/D31667 Modified: cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/Sema/vector-ops.c Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=299641&r1=299640&r2=299641&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Apr 6 05:38:03 2017 @@ -9711,24 +9711,45 @@ QualType Sema::CheckCompareOperands(Expr return InvalidOperands(Loc, LHS, RHS); } - -// Return a signed type that is of identical size and number of elements. -// For floating point vectors, return an integer type of identical size -// and number of elements. +// Return a signed ext_vector_type that is of identical size and number of +// elements. For floating point vectors, return an integer type of identical +// size and number of elements. In the non ext_vector_type case, search from +// the largest type to the smallest type to avoid cases where long long == long, +// where long gets picked over long long. QualType Sema::GetSignedVectorType(QualType V) { const VectorType *VTy = V->getAs(); unsigned TypeSize = Context.getTypeSize(VTy->getElementType()); - if (TypeSize == Context.getTypeSize(Context.CharTy)) -return Context.getExtVectorType(Context.CharTy, VTy->getNumElements()); - else if (TypeSize == Context.getTypeSize(Context.ShortTy)) -return Context.getExtVectorType(Context.ShortTy, VTy->getNumElements()); - else if (TypeSize == Context.getTypeSize(Context.IntTy)) -return Context.getExtVectorType(Context.IntTy, VTy->getNumElements()); + + if (isa(VTy)) { +if (TypeSize == Context.getTypeSize(Context.CharTy)) + return Context.getExtVectorType(Context.CharTy, VTy->getNumElements()); +else if (TypeSize == Context.getTypeSize(Context.ShortTy)) + return Context.getExtVectorType(Context.ShortTy, VTy->getNumElements()); +else if (TypeSize == Context.getTypeSize(Context.IntTy)) + return Context.getExtVectorType(Context.IntTy, VTy->getNumElements()); +else if (TypeSize == Context.getTypeSize(Context.LongTy)) + return Context.getExtVectorType(Context.LongTy, VTy->getNumElements()); +assert(TypeSize == Context.getTypeSize(Context.LongLongTy) && + "Unhandled vector element size in vector compare"); +return Context.getExtVectorType(Context.LongLongTy, VTy->getNumElements()); + } + + if (TypeSize == Context.getTypeSize(Context.LongLongTy)) +return Context.getVectorType(Context.LongLongTy, VTy->getNumElements(), + VectorType::GenericVector); else if (TypeSize == Context.getTypeSize(Context.LongTy)) -return Context.getExtVectorType(Context.LongTy, VTy->getNumElements()); - assert(TypeSize == Context.getTypeSize(Context.LongLongTy) && +return Context.getVectorType(Context.LongTy, VTy->getNumElements(), + VectorType::GenericVector); + else if (TypeSize == Context.getTypeSize(Context.IntTy)) +return Context.getVectorType(Context.IntTy, VTy->getNumElements(), + VectorType::GenericVector); + else if (TypeSize == Context.getTypeSize(Context.ShortTy)) +return Context.getVectorType(Context.ShortTy, VTy->getNumElements(), + VectorType::GenericVector); + assert(TypeSize == Context.getTypeSize(Context.CharTy) && "Unhandled vector element size in vector compare"); - return Context.getExtVectorType(Context.LongLongTy, VTy->getNumElements()); + return Context.getVectorType(Context.CharTy, VTy->getNumElements(), + VectorType::GenericVector); } /// CheckVectorCompareOperands - vector comparisons are a clang extension that @@ -9775,7 +9796,7 @@ QualType Sema::CheckVectorCompareOperand assert (RHS.get()->getType()->hasFloatingRepresentation()); CheckFloatComparison(Loc, LHS.get(), RHS.get()); } - + // Return a signed type for the vector. return GetSignedVectorType(vType); } @@ -9792,7 +9813,7 @@ QualType Sema::CheckVectorLogicalOperand if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 && vType->hasFloatingRepresentation()) return InvalidOperands(Loc, LHS, RHS); - + return GetSignedVectorType(LHS.get()->getType()); } Modified: cfe/trunk/test/Sema/vector-ops.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vector-ops.c?rev=299641&r1=299640&r2=299641&view=diff ==
[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector
NoQ added a comment. $ cat test.c #include int main() { int i = 5; { int i = i; printf("%d\n", i); } return 0; } $ clang test.c $ ./a.out 32767 $ clang test.c -Xclang -ast-dump ... `-FunctionDecl 0x7ff82d8eac78 line:2:5 main 'int ()' `-CompoundStmt 0x7ff82d8eb070 |-DeclStmt 0x7ff82d8eadb0 | `-VarDecl 0x7ff82d8ead30 col:7 i 'int' cinit | `-IntegerLiteral 0x7ff82d8ead90 'int' 5 |-CompoundStmt 0x7ff82d8eb010 | |-DeclStmt 0x7ff82d8eae78 | | `-VarDecl 0x7ff82d8eadd8 col:9 used i 'int' cinit | | `-ImplicitCastExpr 0x7ff82d8eae60 'int' | | `-DeclRefExpr 0x7ff82d8eae38 'int' lvalue Var 0x7ff82d8eadd ... It seems that in `int i = i;` the `i` in the new `i`, which is already declared by now, just not initialized yet, rather than the old `i`. https://reviews.llvm.org/D23418 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r299642 - Wdocumentation fix
Author: rksimon Date: Thu Apr 6 05:49:02 2017 New Revision: 299642 URL: http://llvm.org/viewvc/llvm-project?rev=299642&view=rev Log: Wdocumentation fix Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.h Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.h?rev=299642&r1=299641&r2=299642&view=diff == --- clang-tools-extra/trunk/clang-rename/USRLocFinder.h (original) +++ clang-tools-extra/trunk/clang-rename/USRLocFinder.h Thu Apr 6 05:49:02 2017 @@ -29,9 +29,9 @@ namespace rename { /// Create atomic changes for renaming all symbol references which are /// identified by the USRs set to a given new name. /// -/// \param USRs: The set containing USRs of a particular old symbol. -/// \param NewName: The new name to replace old symbol name. -/// \param TranslationUnitDecl: The translation unit declaration. +/// \param USRs The set containing USRs of a particular old symbol. +/// \param NewName The new name to replace old symbol name. +/// \param TranslationUnitDecl The translation unit declaration. /// /// \return Atomic changes for renaming. std::vector ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator
arphaman added a comment. Are the `<<<` and `>>>` operators handled correctly? Repository: rL LLVM https://reviews.llvm.org/D31652 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator
arphaman added inline comments. Comment at: include/clang/Basic/LangOptions.def:95 LANGOPT(ObjC2 , 1, 0, "Objective-C 2") +LANGOPT(Java , 1, 0, "Java") BENIGN_LANGOPT(ObjCDefaultSynthProperties , 1, 0, I don't think we should have a `Java` lang option, since Clang is not actually a Java frontend. Maybe another option like `LogicalShiftOperators` will work better? Repository: rL LLVM https://reviews.llvm.org/D31652 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r299643 - [Sema] Retarget test to a specific platform for consistent datasizes
Author: sdardis Date: Thu Apr 6 06:12:14 2017 New Revision: 299643 URL: http://llvm.org/viewvc/llvm-project?rev=299643&view=rev Log: [Sema] Retarget test to a specific platform for consistent datasizes Attempt to satisfy llvm-clang-x86_64-expensive-checks-win by targeting x86_64-apple-darwin10 for Sema/vector-ops.c. The underlying failure is due to datatype differences between platforms. Modified: cfe/trunk/test/Sema/vector-ops.c Modified: cfe/trunk/test/Sema/vector-ops.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vector-ops.c?rev=299643&r1=299642&r2=299643&view=diff == --- cfe/trunk/test/Sema/vector-ops.c (original) +++ cfe/trunk/test/Sema/vector-ops.c Thu Apr 6 06:12:14 2017 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion +// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion -triple x86_64-apple-darwin10 typedef unsigned int v2u __attribute__ ((vector_size (8))); typedef int v2s __attribute__ ((vector_size (8))); typedef float v2f __attribute__ ((vector_size(8))); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector
teemperor added a comment. I think for range loops work differently: #include #include #include struct Foo { int* begin() const { assert(false); } int* end() const { assert(false); } void bar() const { std::cout << "Different behavior" << std::endl; } }; int main() { std::vector F; F.resize(1); for (const Foo* F : F) { F->bar(); } } teemperor@ftlserver ~/test> clang++ test.cpp -std=c++11 ; and ./a.out Different behavior https://reviews.llvm.org/D23418 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator
bradfier added a comment. In https://reviews.llvm.org/D31652#719990, @arphaman wrote: > Are the `<<<` and `>>>` operators handled correctly? Yes, as a side-effect of CUDA kernel-call syntax which uses `>>>` and `<<<`, those tokens are recognised as punctuators. Repository: rL LLVM https://reviews.llvm.org/D31652 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator
bradfier added inline comments. Comment at: include/clang/Basic/LangOptions.def:95 LANGOPT(ObjC2 , 1, 0, "Objective-C 2") +LANGOPT(Java , 1, 0, "Java") BENIGN_LANGOPT(ObjCDefaultSynthProperties , 1, 0, arphaman wrote: > I don't think we should have a `Java` lang option, since Clang is not > actually a Java frontend. Maybe another option like `LogicalShiftOperators` > will work better? That seems reasonable. C and C++ have `>>>` or `<<<` operators as part of CUDA extensions though, so maybe the full `LogicalShiftAssignOperators` is more precise? Repository: rL LLVM https://reviews.llvm.org/D31652 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31746: Remove ASTUnits for closed documents and cache CompilationDatabase per directory in clangd.
krasimir added a comment. Looks great! I'm wondering, can you think of ways to test the `didClose` method similarly to how it's done for other handlers? Comment at: clangd/ASTManager.cpp:203 + // TODO(ibiryukov): at this point DocDatasLock can be unlocked in asynchronous + // mode Why not make the locking explicit here and don't require `handleRequest` and `parseFileAndPublishDiagnostics` to be called under a lock? Comment at: clangd/ASTManager.h:60 + ASTManagerRequest() = default; + ASTManagerRequest(ASTManagerRequestType Type, std::string FileUri, +DocVersion FileVersion); I'd call the second parameter just `Uri`. Comment at: clangd/ASTManager.h:64 + ASTManagerRequestType type; + std::string fileUri; + DocVersion fileVersion; I'd call this `Uri`. Comment at: clangd/ASTManager.h:65 + std::string fileUri; + DocVersion fileVersion; +}; I'd capitalize the member variables. In general, this is the llvm/clang style and the lowercase member variables in `Protocol.h` are for consistency with the Language Server Protocol. Comment at: clangd/ASTManager.h:112 + /// thread. + /// If RunSynchronously is true, runs the request handler immideately + void queueOrRun(ASTManagerRequestType RequestType, StringRef Uri); nit: `s/immideately/immediately` and add a full stop. Comment at: clangd/ASTManager.h:117 + /// Should be called under DocDataLock when RunSynchronously is false + void handleRequest(ASTManagerRequestType RequestType, StringRef Uri); + /// Should be called under DocDataLock when RunSynchronously is false It's sad that handle request should be called under the lock :( Comment at: clangd/ASTManager.h:119 + /// Should be called under DocDataLock when RunSynchronously is false + void parseFileAndPublishDiagnostics(StringRef Uri); Maybe it's worth noting whether the main or the worker thread calls these during asynchronous execution. Comment at: clangd/ASTManager.h:131 std::shared_ptr PCHs; + /// A lock for access to the DocDatas, CompilationDatabases and PCHs + std::mutex DocDatasLock; nit: missing trailing full stop. Comment at: clangd/ASTManager.h:132 + /// A lock for access to the DocDatas, CompilationDatabases and PCHs + std::mutex DocDatasLock; I'd rename this lock to `ClangObjectLock` or something else; its name currently gives the wrong feeling that it's used only for `DocDatas`. https://reviews.llvm.org/D31746 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29877: Warn about unused static file scope function template declarations.
v.g.vassilev updated this revision to Diff 94350. v.g.vassilev added a comment. Found out which is the right place to avoid the linkage computation issues. https://reviews.llvm.org/D29877 Files: lib/Sema/Sema.cpp lib/Sema/SemaDecl.cpp test/SemaCXX/warn-unused-filescoped.cpp Index: test/SemaCXX/warn-unused-filescoped.cpp === --- test/SemaCXX/warn-unused-filescoped.cpp +++ test/SemaCXX/warn-unused-filescoped.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -Wno-unused-local-typedefs -Wno-c++11-extensions -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -Wno-unused-local-typedefs -std=c++11 %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -Wno-unused-local-typedefs -std=c++14 %s #ifdef HEADER @@ -32,6 +32,14 @@ inline void bar(int, int) { } }; +namespace test8 { +// Should ignore overloaded operators. +template +struct S {}; +template +static bool operator==(S lhs, S rhs) { } +} + namespace pr19713 { #if __cplusplus >= 201103L static constexpr int constexpr1() { return 1; } @@ -65,7 +73,7 @@ template <> void TS::m() { } // expected-warning{{unused}} template - void tf() { } + void tf() { } // expected-warning{{unused}} template <> void tf() { } // expected-warning{{unused}} struct VS { @@ -200,6 +208,18 @@ static void func() {} } +namespace test9 { +template +static void completeRedeclChainForTemplateSpecialization() { } // expected-warning {{unused}} +} + +namespace test10 { +#if __cplusplus >= 201103L +template +constexpr T pi = T(3.14); // expected-warning {{unused}} +#endif +} + namespace pr19713 { #if __cplusplus >= 201103L // FIXME: We should warn on both of these. Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -1493,6 +1493,10 @@ // 'static inline' functions are defined in headers; don't warn. if (FD->isInlined() && !isMainFileLoc(*this, FD->getLocation())) return false; + // 'static operator' functions are defined in headers; don't warn. + if (FD->isOverloadedOperator() && + !isMainFileLoc(*this, FD->getLocation())) +return false; } if (FD->doesThisDeclarationHaveABody() && @@ -8887,6 +8891,7 @@ if (FunctionTemplate) { if (NewFD->isInvalidDecl()) FunctionTemplate->setInvalidDecl(); + MarkUnusedFileScopedDecl(NewFD); return FunctionTemplate; } } @@ -10991,8 +10996,7 @@ /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform /// any semantic actions necessary after any initializer has been attached. -void -Sema::FinalizeDeclaration(Decl *ThisDecl) { +void Sema::FinalizeDeclaration(Decl *ThisDecl) { // Note that we are no longer parsing the initializer for this declaration. ParsingInitForAutoVars.erase(ThisDecl); @@ -11157,9 +11161,8 @@ if (DC->getRedeclContext()->isFileContext() && VD->isExternallyVisible()) AddPushedVisibilityAttribute(VD); - // FIXME: Warn on unused templates. - if (VD->isFileVarDecl() && !VD->getDescribedVarTemplate() && - !isa(VD)) + // FIXME: Warn on unused var template partial specializations. + if (VD->isFileVarDecl() && !isa(VD)) MarkUnusedFileScopedDecl(VD); // Now we have parsed the initializer and can update the table of magic Index: lib/Sema/Sema.cpp === --- lib/Sema/Sema.cpp +++ lib/Sema/Sema.cpp @@ -470,6 +470,13 @@ return true; if (const FunctionDecl *FD = dyn_cast(D)) { +// If this is a function template and neither of its specs is unused we +// should warn. +if (FunctionTemplateDecl *Template = FD->getDescribedFunctionTemplate()) + for (const auto *Spec : Template->specializations()) +if (ShouldRemoveFromUnused(SemaRef, Spec)) + return true; + // UnusedFileScopedDecls stores the first declaration. // The declaration may have become definition so check again. const FunctionDecl *DeclToCheck; @@ -493,6 +500,11 @@ VD->isUsableInConstantExpressions(SemaRef->Context)) return true; +if (VarTemplateDecl *Template = VD->getDescribedVarTemplate()) + for (const auto *Spec : Template->specializations()) +if (ShouldRemoveFromUnused(SemaRef, Spec)) + return true; + // UnusedFileScopedDecls stores the first declaration. // The declaration may have become definition so check again. const VarDecl *DeclToCheck = VD->getDefinition(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29877: Warn about unused static file scope function template declarations.
v.g.vassilev updated this revision to Diff 94352. v.g.vassilev marked an inline comment as done. v.g.vassilev added a comment. Improve comment. https://reviews.llvm.org/D29877 Files: lib/Sema/Sema.cpp lib/Sema/SemaDecl.cpp test/SemaCXX/warn-unused-filescoped.cpp Index: test/SemaCXX/warn-unused-filescoped.cpp === --- test/SemaCXX/warn-unused-filescoped.cpp +++ test/SemaCXX/warn-unused-filescoped.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -Wno-unused-local-typedefs -Wno-c++11-extensions -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -Wno-unused-local-typedefs -std=c++11 %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function -Wno-unused-local-typedefs -std=c++14 %s #ifdef HEADER @@ -32,6 +32,14 @@ inline void bar(int, int) { } }; +namespace test8 { +// Should ignore overloaded operators. +template +struct S {}; +template +static bool operator==(S lhs, S rhs) { } +} + namespace pr19713 { #if __cplusplus >= 201103L static constexpr int constexpr1() { return 1; } @@ -65,7 +73,7 @@ template <> void TS::m() { } // expected-warning{{unused}} template - void tf() { } + void tf() { } // expected-warning{{unused}} template <> void tf() { } // expected-warning{{unused}} struct VS { @@ -200,6 +208,18 @@ static void func() {} } +namespace test9 { +template +static void completeRedeclChainForTemplateSpecialization() { } // expected-warning {{unused}} +} + +namespace test10 { +#if __cplusplus >= 201103L +template +constexpr T pi = T(3.14); // expected-warning {{unused}} +#endif +} + namespace pr19713 { #if __cplusplus >= 201103L // FIXME: We should warn on both of these. Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -1493,6 +1493,10 @@ // 'static inline' functions are defined in headers; don't warn. if (FD->isInlined() && !isMainFileLoc(*this, FD->getLocation())) return false; + // 'static operator' functions are defined in headers; don't warn. + if (FD->isOverloadedOperator() && + !isMainFileLoc(*this, FD->getLocation())) +return false; } if (FD->doesThisDeclarationHaveABody() && @@ -8887,6 +8891,7 @@ if (FunctionTemplate) { if (NewFD->isInvalidDecl()) FunctionTemplate->setInvalidDecl(); + MarkUnusedFileScopedDecl(NewFD); return FunctionTemplate; } } @@ -10991,8 +10996,7 @@ /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform /// any semantic actions necessary after any initializer has been attached. -void -Sema::FinalizeDeclaration(Decl *ThisDecl) { +void Sema::FinalizeDeclaration(Decl *ThisDecl) { // Note that we are no longer parsing the initializer for this declaration. ParsingInitForAutoVars.erase(ThisDecl); @@ -11157,9 +11161,8 @@ if (DC->getRedeclContext()->isFileContext() && VD->isExternallyVisible()) AddPushedVisibilityAttribute(VD); - // FIXME: Warn on unused templates. - if (VD->isFileVarDecl() && !VD->getDescribedVarTemplate() && - !isa(VD)) + // FIXME: Warn on unused var template partial specializations. + if (VD->isFileVarDecl() && !isa(VD)) MarkUnusedFileScopedDecl(VD); // Now we have parsed the initializer and can update the table of magic Index: lib/Sema/Sema.cpp === --- lib/Sema/Sema.cpp +++ lib/Sema/Sema.cpp @@ -470,6 +470,12 @@ return true; if (const FunctionDecl *FD = dyn_cast(D)) { +// If this is a function template and neither of its specs is used, warn. +if (FunctionTemplateDecl *Template = FD->getDescribedFunctionTemplate()) + for (const auto *Spec : Template->specializations()) +if (ShouldRemoveFromUnused(SemaRef, Spec)) + return true; + // UnusedFileScopedDecls stores the first declaration. // The declaration may have become definition so check again. const FunctionDecl *DeclToCheck; @@ -493,6 +499,12 @@ VD->isUsableInConstantExpressions(SemaRef->Context)) return true; +if (VarTemplateDecl *Template = VD->getDescribedVarTemplate()) + // If this is a variable template and neither of its specs is used, warn. + for (const auto *Spec : Template->specializations()) +if (ShouldRemoveFromUnused(SemaRef, Spec)) + return true; + // UnusedFileScopedDecls stores the first declaration. // The declaration may have become definition so check again. const VarDecl *DeclToCheck = VD->getDefinition(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31401: [clangd] Extract FsPath from file:// uri
krasimir accepted this revision. krasimir added a comment. This revision is now accepted and ready to land. Looks good! https://reviews.llvm.org/D31401 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31756: [cmake] Support Gentoo install for z3
mgorny created this revision. Add the 'z3' subdirectory to the list of possible path suffixes for libz3 header search. The z3 headers are installed in /usr/include/z3 on Gentoo. Repository: rL LLVM https://reviews.llvm.org/D31756 Files: cmake/modules/FindZ3.cmake Index: cmake/modules/FindZ3.cmake === --- cmake/modules/FindZ3.cmake +++ cmake/modules/FindZ3.cmake @@ -1,5 +1,5 @@ find_path(Z3_INCLUDE_DIR NAMES z3.h - PATH_SUFFIXES libz3 + PATH_SUFFIXES libz3 z3 ) find_library(Z3_LIBRARIES NAMES z3 libz3 Index: cmake/modules/FindZ3.cmake === --- cmake/modules/FindZ3.cmake +++ cmake/modules/FindZ3.cmake @@ -1,5 +1,5 @@ find_path(Z3_INCLUDE_DIR NAMES z3.h - PATH_SUFFIXES libz3 + PATH_SUFFIXES libz3 z3 ) find_library(Z3_LIBRARIES NAMES z3 libz3 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations
hokein created this revision. Herald added a subscriber: mgorny. The "performance-inefficient-vector-operation" check finds vector oprations in for-loop statements which may cause multiple memory reallocations. This is the first version, only detects typical for-loop: std::vector v; for (int i = 0; i < n; ++i) { v.push_back(i); } // or for (int i = 0; i < v2.size(); ++i) { v.push_back(v2[i]); } We can extend it to handle more cases like for-range loop in the future. https://reviews.llvm.org/D31757 Files: clang-tidy/performance/CMakeLists.txt clang-tidy/performance/InefficientVectorOperationCheck.cpp clang-tidy/performance/InefficientVectorOperationCheck.h clang-tidy/performance/PerformanceTidyModule.cpp docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/performance-inefficient-vector-operation.rst test/clang-tidy/performance-inefficient-vector-operation.cpp Index: test/clang-tidy/performance-inefficient-vector-operation.cpp === --- /dev/null +++ test/clang-tidy/performance-inefficient-vector-operation.cpp @@ -0,0 +1,102 @@ +// RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- -format-style=llvm -- + +typedef int size_t; + +namespace std { +template +class vector { + public: + typedef T* iterator; + typedef const T* const_iterator; + typedef T& reference; + typedef const T& const_reference; + typedef size_t size_type; + + explicit vector(); + explicit vector(size_type n); + + void push_back(const T& val); + void reserve(size_t n); + size_t size(); + const_reference operator[] (size_type) const; + reference operator[] (size_type); +}; +} // namespace std + +void f(std::vector& t) { + { +std::vector v; +// CHECK-FIXES: v.reserve(10); +for (int i = 0; i < 10; ++i) + v.push_back(i); + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: push_back is called inside a loop; consider pre-allocating the vector capacity before the loop + } + { +std::vector v; +// CHECK-FIXES: v.reserve(t.size()); +for (size_t i = 0; i < t.size(); ++i) { + v.push_back(t[i]); + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: push_back is called +} + } + { +std::vector v; +// CHECK-FIXES: v.reserve(t.size() - 1); +for (size_t i = 0; i < t.size() - 1; ++i) { + v.push_back(t[i]); +} // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: push_back is called + } + + // Non-fixed Cases + { +std::vector v; +v.reserve(20); +// CHECK-FIXES-NOT: v.reserve(10); +// There is a "reserve" call already. +for (int i = 0; i < 10; ++i) { + v.push_back(i); +} + } + { +std::vector v(20); +// CHECK-FIXES-NOT: v.reserve(10); +// v is not constructed with default constructor. +for (int i = 0; i < 10; ++i) { + v.push_back(i); +} + } + { +std::vector v; +// CHECK-FIXES-NOT: v.reserve(10); +// For-loop is not started with 0. +for (int i = 1; i < 10; ++i) { + v.push_back(i); +} + } + { +std::vector v; +// CHECK-FIXES-NOT: v.reserve(t.size()); +// v isn't referenced in for-loop body. +for (size_t i = 0; i < t.size(); ++i) { + t.push_back(i); +} + } + { +std::vector v; +int k; +// CHECK-FIXES-NOT: v.reserve(10); +// For-loop isn't a fixable loop. +for (size_t i = 0; k < 10; ++i) { + v.push_back(t[i]); +} + } + { +std::vector v; +int k; +// CHECK-FIXES-NOT: v.reserve(10); +// For-loop isn't a fixable loop. +for (size_t i = 0; i < 10; ++k) { + v.push_back(t[i]); +} + } +} Index: docs/clang-tidy/checks/performance-inefficient-vector-operation.rst === --- /dev/null +++ docs/clang-tidy/checks/performance-inefficient-vector-operation.rst @@ -0,0 +1,17 @@ +.. title:: clang-tidy - performance-inefficient-vector-operation + +performance-inefficient-vector-operation + + +Finds possible inefficient vector push_back operation that causes unnecessary +memory reallocation. + +.. code-block:: c++ + + std::vector v; + for (int i = 0; i < n; ++i) { +v.push_back(n); +// This will trigger the warning since the push_back may cause multiple +// memory reallocations in v. This can be avoid by inserting a reserve(n) +// statment before the for statment. + } Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -141,6 +141,7 @@ performance-for-range-copy performance-implicit-cast-in-loop performance-inefficient-string-concatenation + performance-inefficient-vector-operation performance-type-promotion-in-math-fn performance-unnecessary-copy-initialization performance-unnecessary-value-param Index: clang-tidy/performance/PerformanceTidyM
[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations
hokein updated this revision to Diff 94356. hokein added a comment. Fix a small nit. https://reviews.llvm.org/D31757 Files: clang-tidy/performance/CMakeLists.txt clang-tidy/performance/InefficientVectorOperationCheck.cpp clang-tidy/performance/InefficientVectorOperationCheck.h clang-tidy/performance/PerformanceTidyModule.cpp docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/performance-inefficient-vector-operation.rst test/clang-tidy/performance-inefficient-vector-operation.cpp Index: test/clang-tidy/performance-inefficient-vector-operation.cpp === --- /dev/null +++ test/clang-tidy/performance-inefficient-vector-operation.cpp @@ -0,0 +1,102 @@ +// RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- -format-style=llvm -- + +typedef int size_t; + +namespace std { +template +class vector { + public: + typedef T* iterator; + typedef const T* const_iterator; + typedef T& reference; + typedef const T& const_reference; + typedef size_t size_type; + + explicit vector(); + explicit vector(size_type n); + + void push_back(const T& val); + void reserve(size_t n); + size_t size(); + const_reference operator[] (size_type) const; + reference operator[] (size_type); +}; +} // namespace std + +void f(std::vector& t) { + { +std::vector v; +// CHECK-FIXES: v.reserve(10); +for (int i = 0; i < 10; ++i) + v.push_back(i); + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: push_back is called inside a loop; consider pre-allocating the vector capacity before the loop + } + { +std::vector v; +// CHECK-FIXES: v.reserve(t.size()); +for (size_t i = 0; i < t.size(); ++i) { + v.push_back(t[i]); + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: push_back is called +} + } + { +std::vector v; +// CHECK-FIXES: v.reserve(t.size() - 1); +for (size_t i = 0; i < t.size() - 1; ++i) { + v.push_back(t[i]); +} // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: push_back is called + } + + // Non-fixed Cases + { +std::vector v; +v.reserve(20); +// CHECK-FIXES-NOT: v.reserve(10); +// There is a "reserve" call already. +for (int i = 0; i < 10; ++i) { + v.push_back(i); +} + } + { +std::vector v(20); +// CHECK-FIXES-NOT: v.reserve(10); +// v is not constructed with default constructor. +for (int i = 0; i < 10; ++i) { + v.push_back(i); +} + } + { +std::vector v; +// CHECK-FIXES-NOT: v.reserve(10); +// For-loop is not started with 0. +for (int i = 1; i < 10; ++i) { + v.push_back(i); +} + } + { +std::vector v; +// CHECK-FIXES-NOT: v.reserve(t.size()); +// v isn't referenced in for-loop body. +for (size_t i = 0; i < t.size(); ++i) { + t.push_back(i); +} + } + { +std::vector v; +int k; +// CHECK-FIXES-NOT: v.reserve(10); +// For-loop isn't a fixable loop. +for (size_t i = 0; k < 10; ++i) { + v.push_back(t[i]); +} + } + { +std::vector v; +int k; +// CHECK-FIXES-NOT: v.reserve(10); +// For-loop isn't a fixable loop. +for (size_t i = 0; i < 10; ++k) { + v.push_back(t[i]); +} + } +} Index: docs/clang-tidy/checks/performance-inefficient-vector-operation.rst === --- /dev/null +++ docs/clang-tidy/checks/performance-inefficient-vector-operation.rst @@ -0,0 +1,17 @@ +.. title:: clang-tidy - performance-inefficient-vector-operation + +performance-inefficient-vector-operation + + +Finds possible inefficient vector push_back operation that causes unnecessary +memory reallocation. + +.. code-block:: c++ + + std::vector v; + for (int i = 0; i < n; ++i) { +v.push_back(n); +// This will trigger the warning since the push_back may cause multiple +// memory reallocations in v. This can be avoid by inserting a reserve(n) +// statment before the for statment. + } Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -141,6 +141,7 @@ performance-for-range-copy performance-implicit-cast-in-loop performance-inefficient-string-concatenation + performance-inefficient-vector-operation performance-type-promotion-in-math-fn performance-unnecessary-copy-initialization performance-unnecessary-value-param Index: clang-tidy/performance/PerformanceTidyModule.cpp === --- clang-tidy/performance/PerformanceTidyModule.cpp +++ clang-tidy/performance/PerformanceTidyModule.cpp @@ -14,6 +14,7 @@ #include "ForRangeCopyCheck.h" #include "ImplicitCastInLoopCheck.h" #include "InefficientStringConcatenationCheck.h" +#include "InefficientVectorOperationCheck.h" #include "TypePromotionInMathFnCheck.h" #incl
[clang-tools-extra] r299645 - Attempt to fix build bots after r299638.
Author: xazax Date: Thu Apr 6 07:49:35 2017 New Revision: 299645 URL: http://llvm.org/viewvc/llvm-project?rev=299645&view=rev Log: Attempt to fix build bots after r299638. Modified: clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp Modified: clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp?rev=299645&r1=299644&r2=299645&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp Thu Apr 6 07:49:35 2017 @@ -1,8 +1,8 @@ -// RUN: %check_clang_tidy %s misc-forwarding-reference-overload %t +// RUN: %check_clang_tidy %s misc-forwarding-reference-overload %t -- -- -std=c++14 namespace std { template -struct enable_if {}; +struct enable_if { typedef T type; }; template struct enable_if { typedef T type; }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r299646 - Fix lambda to block conversion in C++17 by avoiding copy elision for the
Author: arphaman Date: Thu Apr 6 07:53:43 2017 New Revision: 299646 URL: http://llvm.org/viewvc/llvm-project?rev=299646&view=rev Log: Fix lambda to block conversion in C++17 by avoiding copy elision for the lambda capture used by the created block The commit r288866 introduced guaranteed copy elision to C++ 17. This unfortunately broke the lambda to block conversion in C++17 (the compiler crashes when performing IRGen). This commit fixes the conversion by avoiding copy elision for the capture that captures the lambda that's used in the block created by the lambda to block conversion process. rdar://31385153 Differential Revision: https://reviews.llvm.org/D31669 Added: cfe/trunk/test/CodeGenObjCXX/lambda-to-block.mm Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/Initialization.h cfe/trunk/lib/Sema/SemaInit.cpp cfe/trunk/lib/Sema/SemaLambda.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=299646&r1=299645&r2=299646&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Apr 6 07:53:43 2017 @@ -1689,8 +1689,8 @@ def err_init_conversion_failed : Error< "cannot initialize %select{a variable|a parameter|return object|an " "exception object|a member subobject|an array element|a new value|a value|a " "base class|a constructor delegation|a vector element|a block element|a " - "complex element|a lambda capture|a compound literal initializer|a " - "related result|a parameter of CF audited function}0 " + "block element|a complex element|a lambda capture|a compound literal " + "initializer|a related result|a parameter of CF audited function}0 " "%diff{of type $ with an %select{rvalue|lvalue}2 of type $|" "with an %select{rvalue|lvalue}2 of incompatible type}1,3" "%select{|: different classes%diff{ ($ vs $)|}5,6" Modified: cfe/trunk/include/clang/Sema/Initialization.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=299646&r1=299645&r2=299646&view=diff == --- cfe/trunk/include/clang/Sema/Initialization.h (original) +++ cfe/trunk/include/clang/Sema/Initialization.h Thu Apr 6 07:53:43 2017 @@ -70,6 +70,9 @@ public: /// \brief The entity being initialized is a field of block descriptor for /// the copied-in c++ object. EK_BlockElement, +/// The entity being initialized is a field of block descriptor for the +/// copied-in lambda object that's used in the lambda to block conversion. +EK_LambdaToBlockConversionBlockElement, /// \brief The entity being initialized is the real or imaginary part of a /// complex number. EK_ComplexElement, @@ -260,7 +263,13 @@ public: QualType Type, bool NRVO) { return InitializedEntity(EK_BlockElement, BlockVarLoc, Type, NRVO); } - + + static InitializedEntity InitializeLambdaToBlock(SourceLocation BlockVarLoc, + QualType Type, bool NRVO) { +return InitializedEntity(EK_LambdaToBlockConversionBlockElement, + BlockVarLoc, Type, NRVO); + } + /// \brief Create the initialization entity for an exception object. static InitializedEntity InitializeException(SourceLocation ThrowLoc, QualType Type, bool NRVO) { Modified: cfe/trunk/lib/Sema/SemaInit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=299646&r1=299645&r2=299646&view=diff == --- cfe/trunk/lib/Sema/SemaInit.cpp (original) +++ cfe/trunk/lib/Sema/SemaInit.cpp Thu Apr 6 07:53:43 2017 @@ -950,6 +950,7 @@ static void warnBracedScalarInit(Sema &S case InitializedEntity::EK_Base: case InitializedEntity::EK_Delegating: case InitializedEntity::EK_BlockElement: + case InitializedEntity::EK_LambdaToBlockConversionBlockElement: case InitializedEntity::EK_Binding: llvm_unreachable("unexpected braced scalar init"); } @@ -2934,6 +2935,7 @@ DeclarationName InitializedEntity::getNa case EK_VectorElement: case EK_ComplexElement: case EK_BlockElement: + case EK_LambdaToBlockConversionBlockElement: case EK_CompoundLiteralInit: case EK_RelatedResult: return DeclarationName(); @@ -2963,6 +2965,7 @@ ValueDecl *InitializedEntity::getDecl() case EK_VectorElement: case EK_ComplexElement: case EK_BlockElement: + case EK_LambdaToBlockConversionBlockElement: case EK_LambdaCapture: case EK_CompoundLiteralInit: case EK_RelatedResult: @@ -2992,6 +2995,7 @@ bool InitializedEntity::allowsNRVO
[PATCH] D31669: Fix lambda to block conversion in C++17 by avoiding copy elision for the lambda capture used by the created block
This revision was automatically updated to reflect the committed changes. Closed by commit rL299646: Fix lambda to block conversion in C++17 by avoiding copy elision for the (authored by arphaman). Changed prior to commit: https://reviews.llvm.org/D31669?vs=94177&id=94358#toc Repository: rL LLVM https://reviews.llvm.org/D31669 Files: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/Initialization.h cfe/trunk/lib/Sema/SemaInit.cpp cfe/trunk/lib/Sema/SemaLambda.cpp cfe/trunk/test/CodeGenObjCXX/lambda-to-block.mm Index: cfe/trunk/include/clang/Sema/Initialization.h === --- cfe/trunk/include/clang/Sema/Initialization.h +++ cfe/trunk/include/clang/Sema/Initialization.h @@ -70,6 +70,9 @@ /// \brief The entity being initialized is a field of block descriptor for /// the copied-in c++ object. EK_BlockElement, +/// The entity being initialized is a field of block descriptor for the +/// copied-in lambda object that's used in the lambda to block conversion. +EK_LambdaToBlockConversionBlockElement, /// \brief The entity being initialized is the real or imaginary part of a /// complex number. EK_ComplexElement, @@ -260,7 +263,13 @@ QualType Type, bool NRVO) { return InitializedEntity(EK_BlockElement, BlockVarLoc, Type, NRVO); } - + + static InitializedEntity InitializeLambdaToBlock(SourceLocation BlockVarLoc, + QualType Type, bool NRVO) { +return InitializedEntity(EK_LambdaToBlockConversionBlockElement, + BlockVarLoc, Type, NRVO); + } + /// \brief Create the initialization entity for an exception object. static InitializedEntity InitializeException(SourceLocation ThrowLoc, QualType Type, bool NRVO) { Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td === --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td @@ -1689,8 +1689,8 @@ "cannot initialize %select{a variable|a parameter|return object|an " "exception object|a member subobject|an array element|a new value|a value|a " "base class|a constructor delegation|a vector element|a block element|a " - "complex element|a lambda capture|a compound literal initializer|a " - "related result|a parameter of CF audited function}0 " + "block element|a complex element|a lambda capture|a compound literal " + "initializer|a related result|a parameter of CF audited function}0 " "%diff{of type $ with an %select{rvalue|lvalue}2 of type $|" "with an %select{rvalue|lvalue}2 of incompatible type}1,3" "%select{|: different classes%diff{ ($ vs $)|}5,6" Index: cfe/trunk/test/CodeGenObjCXX/lambda-to-block.mm === --- cfe/trunk/test/CodeGenObjCXX/lambda-to-block.mm +++ cfe/trunk/test/CodeGenObjCXX/lambda-to-block.mm @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -x objective-c++ -fblocks -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -std=c++1z -emit-llvm -o - %s | FileCheck %s + +// rdar://31385153 +// Shouldn't crash! + +void takesBlock(void (^)(void)); + +struct Copyable { + Copyable(const Copyable &x); +}; + +void hasLambda(Copyable x) { + takesBlock([x] () { }); +} +// CHECK-LABEL: define internal void @__copy_helper_block_ +// CHECK: call void @"_ZZ9hasLambda8CopyableEN3$_0C1ERKS0_" +// CHECK-LABEL: define internal void @"_ZZ9hasLambda8CopyableEN3$_0C2ERKS0_" +// CHECK: call void @_ZN8CopyableC1ERKS_ Index: cfe/trunk/lib/Sema/SemaLambda.cpp === --- cfe/trunk/lib/Sema/SemaLambda.cpp +++ cfe/trunk/lib/Sema/SemaLambda.cpp @@ -1649,10 +1649,9 @@ CallOperator->markUsed(Context); ExprResult Init = PerformCopyInitialization( - InitializedEntity::InitializeBlock(ConvLocation, - Src->getType(), - /*NRVO=*/false), - CurrentLocation, Src); + InitializedEntity::InitializeLambdaToBlock(ConvLocation, Src->getType(), + /*NRVO=*/false), + CurrentLocation, Src); if (!Init.isInvalid()) Init = ActOnFinishFullExpr(Init.get()); Index: cfe/trunk/lib/Sema/SemaInit.cpp === --- cfe/trunk/lib/Sema/SemaInit.cpp +++ cfe/trunk/lib/Sema/SemaInit.cpp @@ -950,6 +950,7 @@ case InitializedEntity::EK_Base: case InitializedEntity::EK_Delegating: case InitializedEntity::EK_BlockElement: + case InitializedEntity::EK_LambdaToBlockConversionBlockElement: case InitializedEntity::EK_Binding:
r299648 - [ObjC++] Conversions from specialized to non-specialized Objective-C generic
Author: arphaman Date: Thu Apr 6 08:06:34 2017 New Revision: 299648 URL: http://llvm.org/viewvc/llvm-project?rev=299648&view=rev Log: [ObjC++] Conversions from specialized to non-specialized Objective-C generic object types should be preferred over conversions to other object pointers This change ensures that Clang will select the correct overload for the following code sample: void overload(Base *b); void overload(Derived *d); void test(Base b) { overload(b); // Select overload(Base *), not overload(Derived *) } rdar://20124827 Differential Revision: https://reviews.llvm.org/D31597 Modified: cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/test/SemaObjCXX/overload.mm Modified: cfe/trunk/lib/Sema/SemaOverload.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=299648&r1=299647&r2=299648&view=diff == --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) +++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Apr 6 08:06:34 2017 @@ -4047,7 +4047,7 @@ CompareDerivedToBaseConversions(Sema &S, = S.Context.canAssignObjCInterfaces(ToPtr1, ToPtr2); bool ToAssignRight = S.Context.canAssignObjCInterfaces(ToPtr2, ToPtr1); - + // A conversion to an a non-id object pointer type or qualified 'id' // type is better than a conversion to 'id'. if (ToPtr1->isObjCIdType() && @@ -4081,11 +4081,25 @@ CompareDerivedToBaseConversions(Sema &S, return ImplicitConversionSequence::Better; // -- "conversion of C* to B* is better than conversion of C* to A*," - if (S.Context.hasSameType(FromType1, FromType2) && + if (S.Context.hasSameType(FromType1, FromType2) && !FromPtr1->isObjCIdType() && !FromPtr1->isObjCClassType() && - (ToAssignLeft != ToAssignRight)) + (ToAssignLeft != ToAssignRight)) { +if (FromPtr1->isSpecialized()) { + // "conversion of B * to B * is better than conversion of B * to + // C *. + bool IsFirstSame = + FromPtr1->getInterfaceDecl() == ToPtr1->getInterfaceDecl(); + bool IsSecondSame = + FromPtr1->getInterfaceDecl() == ToPtr2->getInterfaceDecl(); + if (IsFirstSame) { +if (!IsSecondSame) + return ImplicitConversionSequence::Better; + } else if (IsSecondSame) +return ImplicitConversionSequence::Worse; +} return ToAssignLeft? ImplicitConversionSequence::Worse : ImplicitConversionSequence::Better; + } // -- "conversion of B* to A* is better than conversion of C* to A*," if (S.Context.hasSameUnqualifiedType(ToType1, ToType2) && Modified: cfe/trunk/test/SemaObjCXX/overload.mm URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/overload.mm?rev=299648&r1=299647&r2=299648&view=diff == --- cfe/trunk/test/SemaObjCXX/overload.mm (original) +++ cfe/trunk/test/SemaObjCXX/overload.mm Thu Apr 6 08:06:34 2017 @@ -174,3 +174,30 @@ namespace class_id { void f(Class) { } void f(id) { } } + +@interface NSDictionary<__covariant KeyType, __covariant ObjectType> : A +@end + +@interface NSMutableDictionary : NSDictionary +@end + +namespace rdar20124827 { + +int overload(NSDictionary *) { return 1; } + +__attribute__((deprecated)) // expected-note {{'overload' has been explicitly marked deprecated here}} +int overload(NSMutableDictionary *) { return 0; } + +__attribute__((deprecated)) +void overload2(NSDictionary *); // expected-note {{candidate function}} +void overload2(NSDictionary *); // expected-note {{candidate function}} + +void test(NSDictionary *d1, NSDictionary *d2, NSMutableDictionary *m1) { + overload(d1); + overload(d2); // no warning + overload(m1); // expected-warning {{'overload' is deprecated}} + overload2(d2); // no warning + overload2(m1); // expected-error {{call to 'overload2' is ambiguous}} +} + +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31597: [ObjC++] Conversions from specialized to non-specialized objective-c object type should be preferred over conversions to other object pointers
This revision was automatically updated to reflect the committed changes. Closed by commit rL299648: [ObjC++] Conversions from specialized to non-specialized Objective-C generic (authored by arphaman). Changed prior to commit: https://reviews.llvm.org/D31597?vs=93845&id=94360#toc Repository: rL LLVM https://reviews.llvm.org/D31597 Files: cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/test/SemaObjCXX/overload.mm Index: cfe/trunk/lib/Sema/SemaOverload.cpp === --- cfe/trunk/lib/Sema/SemaOverload.cpp +++ cfe/trunk/lib/Sema/SemaOverload.cpp @@ -4047,7 +4047,7 @@ = S.Context.canAssignObjCInterfaces(ToPtr1, ToPtr2); bool ToAssignRight = S.Context.canAssignObjCInterfaces(ToPtr2, ToPtr1); - + // A conversion to an a non-id object pointer type or qualified 'id' // type is better than a conversion to 'id'. if (ToPtr1->isObjCIdType() && @@ -4081,11 +4081,25 @@ return ImplicitConversionSequence::Better; // -- "conversion of C* to B* is better than conversion of C* to A*," - if (S.Context.hasSameType(FromType1, FromType2) && + if (S.Context.hasSameType(FromType1, FromType2) && !FromPtr1->isObjCIdType() && !FromPtr1->isObjCClassType() && - (ToAssignLeft != ToAssignRight)) + (ToAssignLeft != ToAssignRight)) { +if (FromPtr1->isSpecialized()) { + // "conversion of B * to B * is better than conversion of B * to + // C *. + bool IsFirstSame = + FromPtr1->getInterfaceDecl() == ToPtr1->getInterfaceDecl(); + bool IsSecondSame = + FromPtr1->getInterfaceDecl() == ToPtr2->getInterfaceDecl(); + if (IsFirstSame) { +if (!IsSecondSame) + return ImplicitConversionSequence::Better; + } else if (IsSecondSame) +return ImplicitConversionSequence::Worse; +} return ToAssignLeft? ImplicitConversionSequence::Worse : ImplicitConversionSequence::Better; + } // -- "conversion of B* to A* is better than conversion of C* to A*," if (S.Context.hasSameUnqualifiedType(ToType1, ToType2) && Index: cfe/trunk/test/SemaObjCXX/overload.mm === --- cfe/trunk/test/SemaObjCXX/overload.mm +++ cfe/trunk/test/SemaObjCXX/overload.mm @@ -174,3 +174,30 @@ void f(Class) { } void f(id) { } } + +@interface NSDictionary<__covariant KeyType, __covariant ObjectType> : A +@end + +@interface NSMutableDictionary : NSDictionary +@end + +namespace rdar20124827 { + +int overload(NSDictionary *) { return 1; } + +__attribute__((deprecated)) // expected-note {{'overload' has been explicitly marked deprecated here}} +int overload(NSMutableDictionary *) { return 0; } + +__attribute__((deprecated)) +void overload2(NSDictionary *); // expected-note {{candidate function}} +void overload2(NSDictionary *); // expected-note {{candidate function}} + +void test(NSDictionary *d1, NSDictionary *d2, NSMutableDictionary *m1) { + overload(d1); + overload(d2); // no warning + overload(m1); // expected-warning {{'overload' is deprecated}} + overload2(d2); // no warning + overload2(m1); // expected-error {{call to 'overload2' is ambiguous}} +} + +} Index: cfe/trunk/lib/Sema/SemaOverload.cpp === --- cfe/trunk/lib/Sema/SemaOverload.cpp +++ cfe/trunk/lib/Sema/SemaOverload.cpp @@ -4047,7 +4047,7 @@ = S.Context.canAssignObjCInterfaces(ToPtr1, ToPtr2); bool ToAssignRight = S.Context.canAssignObjCInterfaces(ToPtr2, ToPtr1); - + // A conversion to an a non-id object pointer type or qualified 'id' // type is better than a conversion to 'id'. if (ToPtr1->isObjCIdType() && @@ -4081,11 +4081,25 @@ return ImplicitConversionSequence::Better; // -- "conversion of C* to B* is better than conversion of C* to A*," - if (S.Context.hasSameType(FromType1, FromType2) && + if (S.Context.hasSameType(FromType1, FromType2) && !FromPtr1->isObjCIdType() && !FromPtr1->isObjCClassType() && - (ToAssignLeft != ToAssignRight)) + (ToAssignLeft != ToAssignRight)) { +if (FromPtr1->isSpecialized()) { + // "conversion of B * to B * is better than conversion of B * to + // C *. + bool IsFirstSame = + FromPtr1->getInterfaceDecl() == ToPtr1->getInterfaceDecl(); + bool IsSecondSame = + FromPtr1->getInterfaceDecl() == ToPtr2->getInterfaceDecl(); + if (IsFirstSame) { +if (!IsSecondSame) + return ImplicitConversionSequence::Better; + } else if (IsSecondSame) +return ImplicitConversionSequence::Worse; +} return ToAssignLeft? ImplicitConversionSequence::Worse
[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator
thakis added inline comments. Comment at: include/clang/Basic/TokenKinds.def:230 +PUNCTUATOR(greatergreatergreaterequal, ">>>=") +PUNCTUATOR(lesslesslessequal, "<<<=") + I think this is the wrong approach to go about this. clang is a C compiler, and its tokenizer shouldn't have to know about Java. Instead, this should be handled in the formatter. See tryMergePreviousTokens() in lib/Format/FormatTokenLexer.cpp for how we do this for e.g. => or >>>= etc for JavaScript – just do the same for Java. Repository: rL LLVM https://reviews.llvm.org/D31652 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31515: [libc++] Implement LWG 2911 - add an is_aggregate type-trait
mclow.lists accepted this revision. mclow.lists added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D31515 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r299649 - [clang-tidy] Add FormatStyle configuration option.
Author: alexfh Date: Thu Apr 6 08:41:29 2017 New Revision: 299649 URL: http://llvm.org/viewvc/llvm-project?rev=299649&view=rev Log: [clang-tidy] Add FormatStyle configuration option. Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp clang-tools-extra/trunk/clang-tidy/ClangTidy.h clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=299649&r1=299648&r2=299649&view=diff == --- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Apr 6 08:41:29 2017 @@ -89,13 +89,13 @@ private: class ErrorReporter { public: - ErrorReporter(bool ApplyFixes, StringRef FormatStyle) + ErrorReporter(ClangTidyContext &Context, bool ApplyFixes) : Files(FileSystemOptions()), DiagOpts(new DiagnosticOptions()), DiagPrinter(new TextDiagnosticPrinter(llvm::outs(), &*DiagOpts)), Diags(IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts, DiagPrinter), -SourceMgr(Diags, Files), ApplyFixes(ApplyFixes), TotalFixes(0), -AppliedFixes(0), WarningsAsErrors(0), FormatStyle(FormatStyle) { +SourceMgr(Diags, Files), Context(Context), ApplyFixes(ApplyFixes), +TotalFixes(0), AppliedFixes(0), WarningsAsErrors(0) { DiagOpts->ShowColors = llvm::sys::Process::StandardOutHasColors(); DiagPrinter->BeginSourceFile(LangOpts); } @@ -196,7 +196,8 @@ public: continue; } StringRef Code = Buffer.get()->getBuffer(); -auto Style = format::getStyle(FormatStyle, File, "none"); +auto Style = format::getStyle( +*Context.getOptionsForFile(File).FormatStyle, File, "none"); if (!Style) { llvm::errs() << llvm::toString(Style.takeError()) << "\n"; continue; @@ -255,11 +256,11 @@ private: DiagnosticsEngine Diags; SourceManager SourceMgr; llvm::StringMap FileReplacements; + ClangTidyContext &Context; bool ApplyFixes; unsigned TotalFixes; unsigned AppliedFixes; unsigned WarningsAsErrors; - StringRef FormatStyle; }; class ClangTidyASTConsumer : public MultiplexConsumer { @@ -471,13 +472,10 @@ ClangTidyOptions::OptionMap getCheckOpti return Factory.getCheckOptions(); } -ClangTidyStats -runClangTidy(std::unique_ptr OptionsProvider, - const CompilationDatabase &Compilations, - ArrayRef InputFiles, - std::vector *Errors, ProfileData *Profile) { +void runClangTidy(clang::tidy::ClangTidyContext &Context, + const CompilationDatabase &Compilations, + ArrayRef InputFiles, ProfileData *Profile) { ClangTool Tool(Compilations, InputFiles); - clang::tidy::ClangTidyContext Context(std::move(OptionsProvider)); // Add extra arguments passed by the clang-tidy command-line. ArgumentsAdjuster PerFileExtraArgumentsInserter = @@ -545,20 +543,18 @@ runClangTidy(std::unique_ptr &Errors, bool Fix, - StringRef FormatStyle, unsigned &WarningsAsErrorsCount) { - ErrorReporter Reporter(Fix, FormatStyle); +void handleErrors(ClangTidyContext &Context, bool Fix, + unsigned &WarningsAsErrorsCount) { + ErrorReporter Reporter(Context, Fix); vfs::FileSystem &FileSystem = *Reporter.getSourceManager().getFileManager().getVirtualFileSystem(); auto InitialWorkingDir = FileSystem.getCurrentWorkingDirectory(); if (!InitialWorkingDir) llvm::report_fatal_error("Cannot get current working path."); - for (const ClangTidyError &Error : Errors) { + for (const ClangTidyError &Error : Context.getErrors()) { if (!Error.BuildDirectory.empty()) { // By default, the working directory of file system is the current // clang-tidy running directory. Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.h?rev=299649&r1=299648&r2=299649&view=diff == --- clang-tools-extra/trunk/clang-tidy/ClangTidy.h (original) +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.h Thu Apr 6 08:41:29 2017 @@ -224,12 +224,10 @@ ClangTidyOptions::OptionMap getCheckOpti /// /// \param Profile if provided, it enables check profile collection in /// MatchFinder, and will contain the result of the profile. -ClangTidyStats -runClangTidy(std::unique_ptr OptionsProvider, - const tooling::CompilationDatabase &Compilations, - ArrayRef InputFiles, - std::vector *Errors, - ProfileData *Profil
[PATCH] D31760: [lsan] Enable LSan on arm Linux, clang part
m.ostapenko created this revision. Herald added subscribers: rengolin, aemerson. This is a compiler part of https://reviews.llvm.org/D29586. Enable LSan on arm Linux. Repository: rL LLVM https://reviews.llvm.org/D31760 Files: lib/Driver/ToolChains/Linux.cpp test/Driver/fsanitize.c Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -234,6 +234,12 @@ // RUN: %clang -target i686-linux-gnu -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-X86 // CHECK-SANL-X86: "-fsanitize=leak" +// RUN: %clang -target arm-linux-gnu -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-ARM +// CHECK-SANL-ARM: "-fsanitize=leak" + +// RUN: %clang -target arm-linux-gnu -fsanitize=address,leak -fno-sanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANL-NO-SANA-ARM +// CHECK-SANA-SANL-NO-SANA-ARM: "-fsanitize=leak" + // RUN: %clang -target i686-linux-gnu -fsanitize=address,leak -fno-sanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANL-NO-SANA-X86 // CHECK-SANA-SANL-NO-SANA-X86: "-fsanitize=leak" Index: lib/Driver/ToolChains/Linux.cpp === --- lib/Driver/ToolChains/Linux.cpp +++ lib/Driver/ToolChains/Linux.cpp @@ -864,14 +864,15 @@ getTriple().getArch() == llvm::Triple::ppc64le; const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64 || getTriple().getArch() == llvm::Triple::aarch64_be; + const bool IsArmArch = getTriple().getArch() == llvm::Triple::arm; SanitizerMask Res = ToolChain::getSupportedSanitizers(); Res |= SanitizerKind::Address; Res |= SanitizerKind::KernelAddress; Res |= SanitizerKind::Vptr; Res |= SanitizerKind::SafeStack; if (IsX86_64 || IsMIPS64 || IsAArch64) Res |= SanitizerKind::DataFlow; - if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86) + if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch) Res |= SanitizerKind::Leak; if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64) Res |= SanitizerKind::Thread; Index: test/Driver/fsanitize.c === --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -234,6 +234,12 @@ // RUN: %clang -target i686-linux-gnu -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-X86 // CHECK-SANL-X86: "-fsanitize=leak" +// RUN: %clang -target arm-linux-gnu -fsanitize=leak %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-ARM +// CHECK-SANL-ARM: "-fsanitize=leak" + +// RUN: %clang -target arm-linux-gnu -fsanitize=address,leak -fno-sanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANL-NO-SANA-ARM +// CHECK-SANA-SANL-NO-SANA-ARM: "-fsanitize=leak" + // RUN: %clang -target i686-linux-gnu -fsanitize=address,leak -fno-sanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANL-NO-SANA-X86 // CHECK-SANA-SANL-NO-SANA-X86: "-fsanitize=leak" Index: lib/Driver/ToolChains/Linux.cpp === --- lib/Driver/ToolChains/Linux.cpp +++ lib/Driver/ToolChains/Linux.cpp @@ -864,14 +864,15 @@ getTriple().getArch() == llvm::Triple::ppc64le; const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64 || getTriple().getArch() == llvm::Triple::aarch64_be; + const bool IsArmArch = getTriple().getArch() == llvm::Triple::arm; SanitizerMask Res = ToolChain::getSupportedSanitizers(); Res |= SanitizerKind::Address; Res |= SanitizerKind::KernelAddress; Res |= SanitizerKind::Vptr; Res |= SanitizerKind::SafeStack; if (IsX86_64 || IsMIPS64 || IsAArch64) Res |= SanitizerKind::DataFlow; - if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86) + if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch) Res |= SanitizerKind::Leak; if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64) Res |= SanitizerKind::Thread; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r299650 - Avoid the -Wdocumentation-unknown-command warning in Clang's C API docs
Author: arphaman Date: Thu Apr 6 09:03:25 2017 New Revision: 299650 URL: http://llvm.org/viewvc/llvm-project?rev=299650&view=rev Log: Avoid the -Wdocumentation-unknown-command warning in Clang's C API docs rdar://20441985 Modified: cfe/trunk/include/clang-c/Index.h Modified: cfe/trunk/include/clang-c/Index.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=299650&r1=299649&r2=299650&view=diff == --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Thu Apr 6 09:03:25 2017 @@ -4034,8 +4034,8 @@ CINDEX_LINKAGE unsigned clang_Cursor_get /** * \brief Given a cursor that represents an Objective-C method or property - * declaration, return non-zero if the declaration was affected by "@optional". - * Returns zero if the cursor is not such a declaration or it is "@required". + * declaration, return non-zero if the declaration was affected by "\@optional". + * Returns zero if the cursor is not such a declaration or it is "\@required". */ CINDEX_LINKAGE unsigned clang_Cursor_isObjCOptional(CXCursor C); @@ -4711,7 +4711,7 @@ enum CXCompletionChunkKind { */ CXCompletionChunk_HorizontalSpace, /** - * Vertical space ('\n'), after which it is generally a good idea to + * Vertical space ('\\n'), after which it is generally a good idea to * perform indentation. */ CXCompletionChunk_VerticalSpace ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31745: [OpenCL] Added diagnostic for implicit declaration of function in OpenCL
yaxunl added a comment. What happens if user declared a function without parameter as `void f();` instead of `void f(void)` then try to use it? Will this be treated as implicit declaration and results in an error instead of warning? https://reviews.llvm.org/D31745 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r299651 - [clang-tidy] Update docs and help message
Author: alexfh Date: Thu Apr 6 09:27:00 2017 New Revision: 299651 URL: http://llvm.org/viewvc/llvm-project?rev=299651&view=rev Log: [clang-tidy] Update docs and help message Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp clang-tools-extra/trunk/docs/clang-tidy/index.rst Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=299651&r1=299650&r2=299651&view=diff == --- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Thu Apr 6 09:27:00 2017 @@ -35,12 +35,13 @@ Configuration files: option, command-line option takes precedence. The effective configuration can be inspected using -dump-config: -$ clang-tidy -dump-config - -- +$ clang-tidy -dump-config --- Checks: '-*,some-check' WarningsAsErrors: '' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false +FormatStyle: none User:user CheckOptions: - key: some-check.SomeOption @@ -131,6 +132,8 @@ Style for formatting code around applied - 'llvm', 'google', 'webkit', 'mozilla' See clang-format documentation for the up-to-date information about formatting styles and options. +This option overrides the 'FormatStyle` option in +.clang-tidy file, if any. )"), cl::init("none"), cl::cat(ClangTidyCategory)); Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=299651&r1=299650&r2=299651&view=diff == --- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original) +++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Thu Apr 6 09:27:00 2017 @@ -169,6 +169,8 @@ An overview of all the command-line opti - 'llvm', 'google', 'webkit', 'mozilla' See clang-format documentation for the up-to-date information about formatting styles and options. + This option overrides the 'FormatStyle` option in + .clang-tidy file, if any. -header-filter= - Regular expression matching the names of the headers to output diagnostics from. Diagnostics @@ -195,9 +197,6 @@ An overview of all the command-line opti printing statistics about ignored warnings and warnings treated as errors if the respective options are specified. --style= - - Fallback style for reformatting after inserting fixes - if there is no clang-format config file found. -system-headers - Display the errors from system headers. -warnings-as-errors= - Upgrades warnings to errors. Same format as @@ -233,12 +232,13 @@ An overview of all the command-line opti option, command-line option takes precedence. The effective configuration can be inspected using -dump-config: - $ clang-tidy -dump-config - -- + $ clang-tidy -dump-config --- Checks: '-*,some-check' WarningsAsErrors: '' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false + FormatStyle: none User:user CheckOptions: - key: some-check.SomeOption ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r299652 - Restore Missing awk regex tests. Thanks to dexonsmith for noticing, and proposing this as https://reviews.llvm.org/D16541
Author: marshall Date: Thu Apr 6 09:32:42 2017 New Revision: 299652 URL: http://llvm.org/viewvc/llvm-project?rev=299652&view=rev Log: Restore Missing awk regex tests. Thanks to dexonsmith for noticing, and proposing this as https://reviews.llvm.org/D16541 Modified: libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp Modified: libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp?rev=299652&r1=299651&r2=299652&view=diff == --- libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp (original) +++ libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp Thu Apr 6 09:32:42 2017 @@ -26,7 +26,7 @@ int main() { -/*{ +{ std::cmatch m; const char s[] = "a"; assert(std::regex_match(s, m, std::regex("a", std::regex_constants::awk))); @@ -616,13 +616,12 @@ int main() assert(m.size() == 0); } std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2)); -*/{ -/* +{ std::cmatch m; const char s[] = "m"; -assert(std::regex_match(s, m, std::regex("[a[=M=]z]", - std::regex_constants::awk); - assert(m.size() == 1); +assert(std::regex_match(s, m, + std::regex("[a[=M=]z]", std::regex_constants::awk))); +assert(m.size() == 1); assert(!m.prefix().matched); assert(m.prefix().first == s); assert(m.prefix().second == m[0].first); @@ -632,8 +631,8 @@ int main() assert(m.length(0) == std::char_traits::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); -*/} -/*{ +} +{ std::cmatch m; const char s[] = "Ch"; assert(std::regex_match(s, m, std::regex("[a[.ch.]z]", @@ -1389,4 +1388,4 @@ int main() assert(m.position(0) == 0); assert(m.str(0) == s); } -*/} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D16541: [libc++] Renable test/std/re/re.alg/re.alg.match/awk.pass.cpp
mclow.lists accepted this revision. mclow.lists added a comment. This revision is now accepted and ready to land. committed as revision 299652 https://reviews.llvm.org/D16541 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector
This revision was automatically updated to reflect the committed changes. Closed by commit rL299653: [analyzer] Reland r299544 "Add a modular constraint system to the CloneDetector" (authored by dergachev). Changed prior to commit: https://reviews.llvm.org/D23418?vs=94337&id=94370#toc Repository: rL LLVM https://reviews.llvm.org/D23418 Files: cfe/trunk/include/clang/Analysis/CloneDetection.h cfe/trunk/lib/Analysis/CloneDetection.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp cfe/trunk/unittests/Analysis/CMakeLists.txt cfe/trunk/unittests/Analysis/CloneDetectionTest.cpp Index: cfe/trunk/lib/Analysis/CloneDetection.cpp === --- cfe/trunk/lib/Analysis/CloneDetection.cpp +++ cfe/trunk/lib/Analysis/CloneDetection.cpp @@ -24,27 +24,27 @@ using namespace clang; -StmtSequence::StmtSequence(const CompoundStmt *Stmt, ASTContext &Context, +StmtSequence::StmtSequence(const CompoundStmt *Stmt, const Decl *D, unsigned StartIndex, unsigned EndIndex) -: S(Stmt), Context(&Context), StartIndex(StartIndex), EndIndex(EndIndex) { +: S(Stmt), D(D), StartIndex(StartIndex), EndIndex(EndIndex) { assert(Stmt && "Stmt must not be a nullptr"); assert(StartIndex < EndIndex && "Given array should not be empty"); assert(EndIndex <= Stmt->size() && "Given array too big for this Stmt"); } -StmtSequence::StmtSequence(const Stmt *Stmt, ASTContext &Context) -: S(Stmt), Context(&Context), StartIndex(0), EndIndex(0) {} +StmtSequence::StmtSequence(const Stmt *Stmt, const Decl *D) +: S(Stmt), D(D), StartIndex(0), EndIndex(0) {} StmtSequence::StmtSequence() -: S(nullptr), Context(nullptr), StartIndex(0), EndIndex(0) {} +: S(nullptr), D(nullptr), StartIndex(0), EndIndex(0) {} bool StmtSequence::contains(const StmtSequence &Other) const { - // If both sequences reside in different translation units, they can never - // contain each other. - if (Context != Other.Context) + // If both sequences reside in different declarations, they can never contain + // each other. + if (D != Other.D) return false; - const SourceManager &SM = Context->getSourceManager(); + const SourceManager &SM = getASTContext().getSourceManager(); // Otherwise check if the start and end locations of the current sequence // surround the other sequence. @@ -76,6 +76,11 @@ return CS->body_begin() + EndIndex; } +ASTContext &StmtSequence::getASTContext() const { + assert(D); + return D->getASTContext(); +} + SourceLocation StmtSequence::getStartLoc() const { return front()->getLocStart(); } @@ -86,168 +91,8 @@ return SourceRange(getStartLoc(), getEndLoc()); } -namespace { - -/// \brief Analyzes the pattern of the referenced variables in a statement. -class VariablePattern { - - /// \brief Describes an occurence of a variable reference in a statement. - struct VariableOccurence { -/// The index of the associated VarDecl in the Variables vector. -size_t KindID; -/// The statement in the code where the variable was referenced. -const Stmt *Mention; - -VariableOccurence(size_t KindID, const Stmt *Mention) -: KindID(KindID), Mention(Mention) {} - }; - - /// All occurences of referenced variables in the order of appearance. - std::vector Occurences; - /// List of referenced variables in the order of appearance. - /// Every item in this list is unique. - std::vector Variables; - - /// \brief Adds a new variable referenced to this pattern. - /// \param VarDecl The declaration of the variable that is referenced. - /// \param Mention The SourceRange where this variable is referenced. - void addVariableOccurence(const VarDecl *VarDecl, const Stmt *Mention) { -// First check if we already reference this variable -for (size_t KindIndex = 0; KindIndex < Variables.size(); ++KindIndex) { - if (Variables[KindIndex] == VarDecl) { -// If yes, add a new occurence that points to the existing entry in -// the Variables vector. -Occurences.emplace_back(KindIndex, Mention); -return; - } -} -// If this variable wasn't already referenced, add it to the list of -// referenced variables and add a occurence that points to this new entry. -Occurences.emplace_back(Variables.size(), Mention); -Variables.push_back(VarDecl); - } - - /// \brief Adds each referenced variable from the given statement. - void addVariables(const Stmt *S) { -// Sometimes we get a nullptr (such as from IfStmts which often have nullptr -// children). We skip such statements as they don't reference any -// variables. -if (!S) - return; - -// Check if S is a reference to a variable. If yes, add it to the pattern. -if (auto D = dyn_cast(S)) { - if (auto VD = dyn_cast(D->getDecl()->getCanonicalDecl())) -addVariableOccurence(VD, D); -} - -// Recursively check all children of the
r299653 - [analyzer] Reland r299544 "Add a modular constraint system to the CloneDetector"
Author: dergachev Date: Thu Apr 6 09:34:07 2017 New Revision: 299653 URL: http://llvm.org/viewvc/llvm-project?rev=299653&view=rev Log: [analyzer] Reland r299544 "Add a modular constraint system to the CloneDetector" Hopefully fix crashes by unshadowing the variable. Original commit message: A big part of the clone detection code is functionality for filtering clones and clone groups based on different criteria. So far this filtering process was hardcoded into the CloneDetector class, which made it hard to understand and, ultimately, to extend. This patch splits the CloneDetector's logic into a sequence of reusable constraints that are used for filtering clone groups. These constraints can be turned on and off and reodreder at will, and new constraints are easy to implement if necessary. Unit tests are added for the new constraint interface. This is a refactoring patch - no functional change intended. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D23418 Added: cfe/trunk/unittests/Analysis/CloneDetectionTest.cpp Modified: cfe/trunk/include/clang/Analysis/CloneDetection.h cfe/trunk/lib/Analysis/CloneDetection.cpp cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp cfe/trunk/unittests/Analysis/CMakeLists.txt Modified: cfe/trunk/include/clang/Analysis/CloneDetection.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CloneDetection.h?rev=299653&r1=299652&r2=299653&view=diff == --- cfe/trunk/include/clang/Analysis/CloneDetection.h (original) +++ cfe/trunk/include/clang/Analysis/CloneDetection.h Thu Apr 6 09:34:07 2017 @@ -16,9 +16,7 @@ #define LLVM_CLANG_AST_CLONEDETECTION_H #include "clang/Basic/SourceLocation.h" -#include "llvm/ADT/Hashing.h" -#include "llvm/ADT/StringMap.h" - +#include "llvm/ADT/SmallVector.h" #include namespace clang { @@ -29,7 +27,7 @@ class VarDecl; class ASTContext; class CompoundStmt; -/// \brief Identifies a list of statements. +/// Identifies a list of statements. /// /// Can either identify a single arbitrary Stmt object, a continuous sequence of /// child statements inside a CompoundStmt or no statements at all. @@ -39,8 +37,8 @@ class StmtSequence { /// Stmt, then S is a pointer to this Stmt. const Stmt *S; - /// The related ASTContext for S. - ASTContext *Context; + /// The declaration that contains the statements. + const Decl *D; /// If EndIndex is non-zero, then S is a CompoundStmt and this StmtSequence /// instance is representing the CompoundStmt children inside the array @@ -49,7 +47,7 @@ class StmtSequence { unsigned EndIndex; public: - /// \brief Constructs a StmtSequence holding multiple statements. + /// Constructs a StmtSequence holding multiple statements. /// /// The resulting StmtSequence identifies a continuous sequence of statements /// in the body of the given CompoundStmt. Which statements of the body should @@ -57,20 +55,20 @@ public: /// that describe a non-empty sub-array in the body of the given CompoundStmt. /// /// \param Stmt A CompoundStmt that contains all statements in its body. - /// \param Context The ASTContext for the given CompoundStmt. + /// \param Decl The Decl containing this Stmt. /// \param StartIndex The inclusive start index in the children array of /// \p Stmt /// \param EndIndex The exclusive end index in the children array of \p Stmt. - StmtSequence(const CompoundStmt *Stmt, ASTContext &Context, - unsigned StartIndex, unsigned EndIndex); + StmtSequence(const CompoundStmt *Stmt, const Decl *D, unsigned StartIndex, + unsigned EndIndex); - /// \brief Constructs a StmtSequence holding a single statement. + /// Constructs a StmtSequence holding a single statement. /// /// \param Stmt An arbitrary Stmt. - /// \param Context The ASTContext for the given Stmt. - StmtSequence(const Stmt *Stmt, ASTContext &Context); + /// \param Decl The Decl containing this Stmt. + StmtSequence(const Stmt *Stmt, const Decl *D); - /// \brief Constructs an empty StmtSequence. + /// Constructs an empty StmtSequence. StmtSequence(); typedef const Stmt *const *iterator; @@ -110,9 +108,12 @@ public: bool empty() const { return size() == 0; } /// Returns the related ASTContext for the stored Stmts. - ASTContext &getASTContext() const { -assert(Context); -return *Context; + ASTContext &getASTContext() const; + + /// Returns the declaration that contains the stored Stmts. + const Decl *getContainingDecl() const { +assert(D); +return D; } /// Returns true if this objects holds a list of statements. @@ -150,106 +151,214 @@ public: bool contains(const StmtSequence &Other) const; }; -/// \brief Searches for clones in source code. +/// Searches for similar subtrees in the AST. /// -/// First, this class needs a translation uni
[PATCH] D29905: [OpenMP] Pass argument to device kernel by reference when map is used.
ABataev added inline comments. Comment at: lib/Sema/SemaOpenMP.cpp:358-360 + /// Do the check specified in \a Check to all component lists at a given level + /// and return true if any issue is found. + bool checkMappableExprComponentListsForDeclAtLevel( Could you join these 2 functions into one? Repository: rL LLVM https://reviews.llvm.org/D29905 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30087: [Driver] Unify linking of OpenMP runtime. NFCI.
Hahnfeld added inline comments. Comment at: lib/Driver/ToolChains/CommonArgs.cpp:430 +bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC, + const ArgList &Args, const JobAction &JA, + bool GompNeedsRT) { ABataev wrote: > Do you really need to pass a reference to `JobAction` here or it is enough to > pass a bool value for `JA.isHostOffloading()`? Good idea, this even allows this change to become fully NFC https://reviews.llvm.org/D30087 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30087: [Driver] Unify linking of OpenMP runtime. NFCI.
Hahnfeld updated this revision to Diff 94372. Hahnfeld marked 2 inline comments as done. Hahnfeld retitled this revision from "[Driver] Unify linking of OpenMP runtime" to "[Driver] Unify linking of OpenMP runtime. NFCI.". Hahnfeld edited the summary of this revision. https://reviews.llvm.org/D30087 Files: lib/Driver/ToolChains/CommonArgs.cpp lib/Driver/ToolChains/CommonArgs.h lib/Driver/ToolChains/Gnu.cpp test/Driver/fopenmp.c Index: test/Driver/fopenmp.c === --- test/Driver/fopenmp.c +++ test/Driver/fopenmp.c @@ -18,29 +18,33 @@ // CHECK-CC1-NO-OPENMP-NOT: "-fopenmp" // // RUN: %clang -target x86_64-linux-gnu -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-OMP -// RUN: %clang -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP +// RUN: %clang -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-RT // RUN: %clang -target x86_64-linux-gnu -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5 // // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5 // // RUN: %clang -target x86_64-darwin -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-OMP -// RUN: %clang -target x86_64-darwin -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP +// RUN: %clang -target x86_64-darwin -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT // RUN: %clang -target x86_64-darwin -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5 // // RUN: %clang -nostdlib -target x86_64-darwin -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP // RUN: %clang -nostdlib -target x86_64-darwin -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP // RUN: %clang -nostdlib -target x86_64-darwin -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5 // -// RUN: %clang -target x86_64-netbsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-OMP -// RUN: %clang -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP -// RUN: %clang -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5 +// RUN: %clang -target x86_64-freebsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-OMP +// RUN: %clang -target x86_64-freebsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT +// RUN: %clang -target x86_64-freebsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5 // // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5 // +// RUN: %clang -target x86_64-netbsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-OMP +// RUN: %clang -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT +// RUN: %clang -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5 +// // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5 @@ -50,6 +54,8 @@ // // CHECK-LD-GOMP: "{{.*}}ld{{(.exe)?}}" // CHECK-LD-GOMP: "-lgomp" +// CHECK-LD-GOMP-RT: "-lrt" +// CHECK-LD-GOMP-NO-RT-NOT: "-lrt" // // CHECK-LD-IOMP5: "{{.*}}ld{{(.exe)?}}" // CHECK-LD-IOMP5: "-liomp5" Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -586,37 +586,15 @@ bool WantPthread = Args.hasArg(options::OPT_pthread) || Args.hasArg(options::OPT_pthreads); - if (Args.hasFlag(options::OPT_fopenmp, options:
[PATCH] D29651: [OpenMP] Consider LIBRARY_PATH when selecting library paths for NVPTX targets in OpenMP mode.
tstellar added a comment. Why is this necessary? Repository: rL LLVM https://reviews.llvm.org/D29651 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer
yaxunl added a comment. Ping! Any further questions? Thanks. https://reviews.llvm.org/D31404 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D16541: [libc++] Renable test/std/re/re.alg/re.alg.match/awk.pass.cpp
mehdi_amini added a comment. This bot is broken: http://green.lab.llvm.org/green/job/libcxx_master_cmake_32/61/ https://reviews.llvm.org/D16541 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31765: Skip Unicode character expansion in assembly files
salari01 created this revision. When using the C preprocessor with assembly files, either with a capital `S` file extension, or with `-xassembler-with-cpp`, the Unicode escape sequence `\u` is ignored. The `\u` pattern can be used for expanding a macro argument that starts with `u`. https://reviews.llvm.org/D31765 Files: lib/Lex/Lexer.cpp test/Lexer/asm-preproc-no-unicode.s Index: test/Lexer/asm-preproc-no-unicode.s === --- /dev/null +++ test/Lexer/asm-preproc-no-unicode.s @@ -0,0 +1,13 @@ +// RUN: %clang --target=arm-arm-none-eabi -c -xassembler-with-cpp %s -o %t 2>&1 | FileCheck %s --check-prefix=WARNING +// RUN: llvm-objdump -s %t | FileCheck %s --check-prefix=DATA + +// WARNING-NOT: warning: \u used with no following hex digits +// DATA: Contents of section data: +// DATA-NEXT: efbeadde + +.warning // required to avoid FileCheck empty input error +.macro foo, u, name +.section \name, "a", %progbits +.word \u +.endm +foo 0xdeadbeef, data Index: lib/Lex/Lexer.cpp === --- lib/Lex/Lexer.cpp +++ lib/Lex/Lexer.cpp @@ -3603,17 +3603,19 @@ // UCNs (C99 6.4.3, C++11 [lex.charset]p2) case '\\': -if (uint32_t CodePoint = tryReadUCN(CurPtr, BufferPtr, &Result)) { - if (CheckUnicodeWhitespace(Result, CodePoint, CurPtr)) { -if (SkipWhitespace(Result, CurPtr, TokAtPhysicalStartOfLine)) - return true; // KeepWhitespaceMode +if (!LangOpts.AsmPreprocessor) { + if (uint32_t CodePoint = tryReadUCN(CurPtr, BufferPtr, &Result)) { +if (CheckUnicodeWhitespace(Result, CodePoint, CurPtr)) { + if (SkipWhitespace(Result, CurPtr, TokAtPhysicalStartOfLine)) +return true; // KeepWhitespaceMode + + // We only saw whitespace, so just try again with this lexer. + // (We manually eliminate the tail call to avoid recursion.) + goto LexNextToken; +} -// We only saw whitespace, so just try again with this lexer. -// (We manually eliminate the tail call to avoid recursion.) -goto LexNextToken; +return LexUnicode(Result, CodePoint, CurPtr); } - - return LexUnicode(Result, CodePoint, CurPtr); } Kind = tok::unknown; Index: test/Lexer/asm-preproc-no-unicode.s === --- /dev/null +++ test/Lexer/asm-preproc-no-unicode.s @@ -0,0 +1,13 @@ +// RUN: %clang --target=arm-arm-none-eabi -c -xassembler-with-cpp %s -o %t 2>&1 | FileCheck %s --check-prefix=WARNING +// RUN: llvm-objdump -s %t | FileCheck %s --check-prefix=DATA + +// WARNING-NOT: warning: \u used with no following hex digits +// DATA: Contents of section data: +// DATA-NEXT: efbeadde + +.warning // required to avoid FileCheck empty input error +.macro foo, u, name +.section \name, "a", %progbits +.word \u +.endm +foo 0xdeadbeef, data Index: lib/Lex/Lexer.cpp === --- lib/Lex/Lexer.cpp +++ lib/Lex/Lexer.cpp @@ -3603,17 +3603,19 @@ // UCNs (C99 6.4.3, C++11 [lex.charset]p2) case '\\': -if (uint32_t CodePoint = tryReadUCN(CurPtr, BufferPtr, &Result)) { - if (CheckUnicodeWhitespace(Result, CodePoint, CurPtr)) { -if (SkipWhitespace(Result, CurPtr, TokAtPhysicalStartOfLine)) - return true; // KeepWhitespaceMode +if (!LangOpts.AsmPreprocessor) { + if (uint32_t CodePoint = tryReadUCN(CurPtr, BufferPtr, &Result)) { +if (CheckUnicodeWhitespace(Result, CodePoint, CurPtr)) { + if (SkipWhitespace(Result, CurPtr, TokAtPhysicalStartOfLine)) +return true; // KeepWhitespaceMode + + // We only saw whitespace, so just try again with this lexer. + // (We manually eliminate the tail call to avoid recursion.) + goto LexNextToken; +} -// We only saw whitespace, so just try again with this lexer. -// (We manually eliminate the tail call to avoid recursion.) -goto LexNextToken; +return LexUnicode(Result, CodePoint, CurPtr); } - - return LexUnicode(Result, CodePoint, CurPtr); } Kind = tok::unknown; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31417: [OpenMP] Add support for omp simd pragmas without runtime
ABataev added inline comments. Comment at: lib/CodeGen/CodeGenModule.cpp:122-123 createOpenCLRuntime(); - if (LangOpts.OpenMP) + if (LangOpts.OpenMP || LangOpts.OpenMPSimd) createOpenMPRuntime(); if (LangOpts.CUDA) I don't think you need to create OpenMP runtime support object if you're not going to use it (and you're not going to use it because you don't want to link it). You'd better create your own OMPSIMDRuntime class, that supports emission of the simd code only. Comment at: lib/Parse/ParseOpenMP.cpp:174 + case OMPD_target_teams_distribute_simd: +DKind = OMPD_simd; +break; huntergr wrote: > rengolin wrote: > > I'd like @ABataev to confirm this is the right semantics. > Yes, would be good. I don't think there's a formal spec for this feature, but > it's possible that directives intended for a different target than the cpu > shouldn't apply with this flag. I don't think you need it here. Instead, you should keep an existing logic in Sema/Parsing code, but you need to create your own OpenMPRuntime support class, that supports only emission of simd part of the constructs. Comment at: lib/Parse/ParseOpenMP.cpp:1047 +// as the filter function will have switched the kind. +if (!getLangOpts().OpenMPSimd) + Diag(Tok, diag::err_omp_unknown_directive); huntergr wrote: > rengolin wrote: > > What if it's really unknown, even to `-fopenmp-simd`? > I did wonder about handling this case; I defaulted to ignoring it, since we > are already filtering out other non-simd constructs. > > If we do want to catch it, then I can think of two options: creating the > diagnostic right before the filter switch (possibly messy), or adding a new > enum value of OMPD_non_simd_construct (or a similar name) to represent > constructs we recognize but don't want to handle and differentiate against a > true unknown. I think the latter would be preferable. Leave it as is, we still have to report errors, even in simd-only mode https://reviews.llvm.org/D31417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31766: [Clang][X86][SSE] Update MOVNTDQA non-temporal loads to generic implementation
RKSimon created this revision. MOVNTDQA non-temporal aligned vector loads can be correctly represented using generic builtin loads, allowing us to remove the existing x86 intrinsics. The LLVM companion patch will be published shortly. Repository: rL LLVM https://reviews.llvm.org/D31766 Files: include/clang/Basic/BuiltinsX86.def lib/Headers/avx2intrin.h lib/Headers/avx512fintrin.h lib/Headers/smmintrin.h test/CodeGen/avx2-builtins.c test/CodeGen/avx512f-builtins.c test/CodeGen/sse41-builtins.c Index: test/CodeGen/sse41-builtins.c === --- test/CodeGen/sse41-builtins.c +++ test/CodeGen/sse41-builtins.c @@ -354,7 +354,7 @@ __m128i test_mm_stream_load_si128(__m128i const *a) { // CHECK-LABEL: test_mm_stream_load_si128 - // CHECK: call <2 x i64> @llvm.x86.sse41.movntdqa(i8* %{{.*}}) + // CHECK: load <2 x i64>, <2 x i64>* %{{.*}}, align 16, !nontemporal return _mm_stream_load_si128(a); } Index: test/CodeGen/avx512f-builtins.c === --- test/CodeGen/avx512f-builtins.c +++ test/CodeGen/avx512f-builtins.c @@ -6251,7 +6251,7 @@ __m512i test_mm512_stream_load_si512(void *__P) { // CHECK-LABEL: @test_mm512_stream_load_si512 - // CHECK: @llvm.x86.avx512.movntdqa + // CHECK: load <8 x i64>, <8 x i64>* %{{.*}}, align 64, !nontemporal return _mm512_stream_load_si512(__P); } Index: test/CodeGen/avx2-builtins.c === --- test/CodeGen/avx2-builtins.c +++ test/CodeGen/avx2-builtins.c @@ -1117,7 +1117,7 @@ __m256i test_mm256_stream_load_si256(__m256i const *a) { // CHECK-LABEL: test_mm256_stream_load_si256 - // CHECK: call <4 x i64> @llvm.x86.avx2.movntdqa(i8* %{{.*}}) + // CHECK: load <4 x i64>, <4 x i64>* %{{.*}}, align 32, !nontemporal return _mm256_stream_load_si256(a); } Index: lib/Headers/smmintrin.h === --- lib/Headers/smmintrin.h +++ lib/Headers/smmintrin.h @@ -691,7 +691,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_stream_load_si128 (__m128i const *__V) { - return (__m128i) __builtin_ia32_movntdqa ((const __v2di *) __V); + return (__m128i) __builtin_nontemporal_load ((const __v2di *) __V); } /* SSE4 Packed Integer Min/Max Instructions. */ Index: lib/Headers/avx512fintrin.h === --- lib/Headers/avx512fintrin.h +++ lib/Headers/avx512fintrin.h @@ -8931,7 +8931,7 @@ static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_stream_load_si512 (void *__P) { - return __builtin_ia32_movntdqa512 ((__v8di *)__P); + return (__m512i) __builtin_nontemporal_load((const __v8di *)__P); } static __inline__ void __DEFAULT_FN_ATTRS Index: lib/Headers/avx2intrin.h === --- lib/Headers/avx2intrin.h +++ lib/Headers/avx2intrin.h @@ -832,7 +832,7 @@ static __inline__ __m256i __DEFAULT_FN_ATTRS _mm256_stream_load_si256(__m256i const *__V) { - return (__m256i)__builtin_ia32_movntdqa256((const __v4di *)__V); + return (__m256i)__builtin_nontemporal_load((const __v4di *)__V); } static __inline__ __m128 __DEFAULT_FN_ATTRS Index: include/clang/Basic/BuiltinsX86.def === --- include/clang/Basic/BuiltinsX86.def +++ include/clang/Basic/BuiltinsX86.def @@ -391,7 +391,6 @@ TARGET_BUILTIN(__builtin_ia32_roundpd, "V2dV2dIi", "", "sse4.1") TARGET_BUILTIN(__builtin_ia32_dpps, "V4fV4fV4fIc", "", "sse4.1") TARGET_BUILTIN(__builtin_ia32_dppd, "V2dV2dV2dIc", "", "sse4.1") -TARGET_BUILTIN(__builtin_ia32_movntdqa, "V2LLiV2LLiC*", "", "sse4.1") TARGET_BUILTIN(__builtin_ia32_ptestz128, "iV2LLiV2LLi", "", "sse4.1") TARGET_BUILTIN(__builtin_ia32_ptestc128, "iV2LLiV2LLi", "", "sse4.1") TARGET_BUILTIN(__builtin_ia32_ptestnzc128, "iV2LLiV2LLi", "", "sse4.1") @@ -576,7 +575,6 @@ TARGET_BUILTIN(__builtin_ia32_psrld256, "V8iV8iV4i", "", "avx2") TARGET_BUILTIN(__builtin_ia32_psrlqi256, "V4LLiV4LLii", "", "avx2") TARGET_BUILTIN(__builtin_ia32_psrlq256, "V4LLiV4LLiV2LLi", "", "avx2") -TARGET_BUILTIN(__builtin_ia32_movntdqa256, "V4LLiV4LLiC*", "", "avx2") TARGET_BUILTIN(__builtin_ia32_permvarsi256, "V8iV8iV8i", "", "avx2") TARGET_BUILTIN(__builtin_ia32_permvarsf256, "V8fV8fV8i", "", "avx2") TARGET_BUILTIN(__builtin_ia32_permti256, "V4LLiV4LLiV4LLiIc", "", "avx2") @@ -1747,7 +1745,6 @@ TARGET_BUILTIN(__builtin_ia32_kunpckhi, "UsUsUs","","avx512f") TARGET_BUILTIN(__builtin_ia32_kxnorhi, "UsUsUs","","avx512f") TARGET_BUILTIN(__builtin_ia32_kxorhi, "UsUsUs","","avx512f") -TARGET_BUILTIN(__builtin_ia32_movntdqa512, "V8LLiV8LLi*","","avx512f") TARGET_BUILTIN(__builtin_ia32_palignr512_mask, "V64cV64cV64cIiV64cULLi","","avx512bw") TARGET_BUILTIN(__builtin_ia32_dbpsadbw128_mask, "V8sV16cV16cIiV8sUc","","avx512bw,avx512vl") TARGET_BUILTIN(__
[libcxx] r299656 - Revert "Restore Missing awk regex tests. Thanks to dexonsmith for noticing, and proposing this as https://reviews.llvm.org/D16541"
Author: mehdi_amini Date: Thu Apr 6 10:56:55 2017 New Revision: 299656 URL: http://llvm.org/viewvc/llvm-project?rev=299656&view=rev Log: Revert "Restore Missing awk regex tests. Thanks to dexonsmith for noticing, and proposing this as https://reviews.llvm.org/D16541"; This reverts commit r299652, 32bits MacOS is broken. Modified: libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp Modified: libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp?rev=299656&r1=299655&r2=299656&view=diff == --- libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp (original) +++ libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp Thu Apr 6 10:56:55 2017 @@ -26,7 +26,7 @@ int main() { -{ +/*{ std::cmatch m; const char s[] = "a"; assert(std::regex_match(s, m, std::regex("a", std::regex_constants::awk))); @@ -616,12 +616,13 @@ int main() assert(m.size() == 0); } std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2)); -{ +*/{ +/* std::cmatch m; const char s[] = "m"; -assert(std::regex_match(s, m, - std::regex("[a[=M=]z]", std::regex_constants::awk))); -assert(m.size() == 1); +assert(std::regex_match(s, m, std::regex("[a[=M=]z]", + std::regex_constants::awk); + assert(m.size() == 1); assert(!m.prefix().matched); assert(m.prefix().first == s); assert(m.prefix().second == m[0].first); @@ -631,8 +632,8 @@ int main() assert(m.length(0) == std::char_traits::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); -} -{ +*/} +/*{ std::cmatch m; const char s[] = "Ch"; assert(std::regex_match(s, m, std::regex("[a[.ch.]z]", @@ -1388,4 +1389,4 @@ int main() assert(m.position(0) == 0); assert(m.str(0) == s); } -} +*/} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r299657 - [clang-tidy] Temporarily disable a test-case that does not work on windows.
Author: xazax Date: Thu Apr 6 10:58:57 2017 New Revision: 299657 URL: http://llvm.org/viewvc/llvm-project?rev=299657&view=rev Log: [clang-tidy] Temporarily disable a test-case that does not work on windows. Modified: clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp Modified: clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp?rev=299657&r1=299656&r2=299657&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/misc-forwarding-reference-overload.cpp Thu Apr 6 10:58:57 2017 @@ -116,14 +116,15 @@ public: }; // Only the (compiler generated) copy constructor can be hidden. -class Test5 { -public: - template - Test5(T &&n); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy constructor [misc-forwarding-reference-overload] - - Test5(Test5 &&rhs) = delete; -}; +// FIXME: Temporarily disabled due to failer on windows build bots. +//class Test5 { +//public: +// template +// Test5(T &&n); +// // CM: :[[@LINE-1]]:3: warning: constructor accepting a forwarding reference can hide the copy constructor [misc-forwarding-reference-overload] +// +// Test5(Test5 &&rhs) = delete; +//}; // Only the move constructor can be hidden. class Test6 { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r299652 - Restore Missing awk regex tests. Thanks to dexonsmith for noticing, and proposing this as https://reviews.llvm.org/D16541
Hi, I reverted in r299656. MacOS bot is broken both on 64 and 32 bits: http://green.lab.llvm.org/green/job/libcxx_master_cmake/83/ http://green.lab.llvm.org/green/job/libcxx_master_cmake_32/61/ It shouldn’t be too hard to fix though, it is full of the same error: /Users/buildslave/jenkins/sharedspace/libcxx/libcxx.src/test/std/re/re.alg/re.alg.match/awk.pass.cpp:266:28: error: comparison of integers of different signs: 'difference_type' (aka 'long') and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare] assert(m.length(0) == std::char_traits::length(s)); ~~~ ^ ~ — Mehdi > On Apr 6, 2017, at 7:32 AM, Marshall Clow via cfe-commits > wrote: > > Author: marshall > Date: Thu Apr 6 09:32:42 2017 > New Revision: 299652 > > URL: http://llvm.org/viewvc/llvm-project?rev=299652&view=rev > Log: > Restore Missing awk regex tests. Thanks to dexonsmith for noticing, and > proposing this as https://reviews.llvm.org/D16541 > > Modified: >libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp > > Modified: libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp > URL: > http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp?rev=299652&r1=299651&r2=299652&view=diff > == > --- libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp (original) > +++ libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp Thu Apr 6 > 09:32:42 2017 > @@ -26,7 +26,7 @@ > > int main() > { > -/*{ > +{ > std::cmatch m; > const char s[] = "a"; > assert(std::regex_match(s, m, std::regex("a", > std::regex_constants::awk))); > @@ -616,13 +616,12 @@ int main() > assert(m.size() == 0); > } > std::locale::global(std::locale(LOCALE_cs_CZ_ISO8859_2)); > -*/{ > -/* > +{ > std::cmatch m; > const char s[] = "m"; > -assert(std::regex_match(s, m, std::regex("[a[=M=]z]", > - std::regex_constants::awk); > - assert(m.size() == 1); > +assert(std::regex_match(s, m, > + std::regex("[a[=M=]z]", std::regex_constants::awk))); > +assert(m.size() == 1); > assert(!m.prefix().matched); > assert(m.prefix().first == s); > assert(m.prefix().second == m[0].first); > @@ -632,8 +631,8 @@ int main() > assert(m.length(0) == std::char_traits::length(s)); > assert(m.position(0) == 0); > assert(m.str(0) == s); > -*/} > -/*{ > +} > +{ > std::cmatch m; > const char s[] = "Ch"; > assert(std::regex_match(s, m, std::regex("[a[.ch.]z]", > @@ -1389,4 +1388,4 @@ int main() > assert(m.position(0) == 0); > assert(m.str(0) == s); > } > -*/} > +} > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31769: Remove the binders `bind1st`, `bind2nd`, `men_fun`, etc from C++17
mclow.lists created this revision. As proposed in http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4190 I'm leaving `unary_function` and `binary_function` in place until I can figure out a non-ABI breaking way to remove them. To get them back in C++17, you can `-D _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS` on the command line. https://reviews.llvm.org/D31769 Files: include/__config include/functional test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.cxx1z.fail.cpp test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp test/std/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp test/std/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.p
[PATCH] D31771: [AMDGPU] Temporarily change constant address space from 4 to 2 for the new address space mapping
yaxunl created this revision. Herald added subscribers: tpr, dstuttard, nhaehnle, wdng, kzhuravl. Change constant address space from 4 to 2 for the new address space mapping in Clang. https://reviews.llvm.org/D31771 Files: lib/Basic/Targets.cpp test/CodeGenOpenCL/address-space-constant-initializers.cl test/CodeGenOpenCL/address-spaces.cl test/CodeGenOpenCL/amdgpu-env-amdgiz.cl test/CodeGenOpenCL/vla.cl Index: test/CodeGenOpenCL/vla.cl === --- test/CodeGenOpenCL/vla.cl +++ test/CodeGenOpenCL/vla.cl @@ -3,13 +3,11 @@ // RUN: %clang_cc1 -emit-llvm -triple amdgcn-amd-amdhsa-amdgizcl -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,GIZ %s constant int sz0 = 5; -// SPIR: @sz0 = addrspace(2) constant i32 5 -// GIZ: @sz0 = addrspace(4) constant i32 5 +// CHECK: @sz0 = addrspace(2) constant i32 5 const global int sz1 = 16; // CHECK: @sz1 = addrspace(1) constant i32 16 const constant int sz2 = 8; -// SPIR: @sz2 = addrspace(2) constant i32 8 -// GIZ: @sz2 = addrspace(4) constant i32 8 +// CHECK: @sz2 = addrspace(2) constant i32 8 // CHECK: @testvla.vla2 = internal addrspace(3) global [8 x i16] undef kernel void testvla() Index: test/CodeGenOpenCL/amdgpu-env-amdgiz.cl === --- test/CodeGenOpenCL/amdgpu-env-amdgiz.cl +++ test/CodeGenOpenCL/amdgpu-env-amdgiz.cl @@ -4,6 +4,6 @@ // RUN: %clang_cc1 %s -O0 -triple amdgcn---amdgizcl -emit-llvm -o - | FileCheck -check-prefix=GIZ %s // CHECK: target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" -// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5" +// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5" void foo(void) {} Index: test/CodeGenOpenCL/address-spaces.cl === --- test/CodeGenOpenCL/address-spaces.cl +++ test/CodeGenOpenCL/address-spaces.cl @@ -15,8 +15,7 @@ // CHECK: i32 addrspace(3)* %arg void f__l(__local int *arg) {} -// SPIR: i32 addrspace(2)* %arg -// GIZ: i32 addrspace(4)* %arg +// CHECK: i32 addrspace(2)* %arg void f__c(__constant int *arg) {} // SPIR: i32* %arg @@ -29,8 +28,7 @@ // CHECK: i32 addrspace(3)* %arg void fl(local int *arg) {} -// SPIR: i32 addrspace(2)* %arg -// GIZ: i32 addrspace(4)* %arg +// CHECK: i32 addrspace(2)* %arg void fc(constant int *arg) {} #ifdef CL20 Index: test/CodeGenOpenCL/address-space-constant-initializers.cl === --- test/CodeGenOpenCL/address-space-constant-initializers.cl +++ test/CodeGenOpenCL/address-space-constant-initializers.cl @@ -1,6 +1,6 @@ // RUN: %clang_cc1 %s -ffake-address-space-map -emit-llvm -o - | FileCheck %s // RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-opencl -emit-llvm -o - | FileCheck %s -// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-amdgizcl -emit-llvm -o - | FileCheck -check-prefix=GIZ %s +// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-amdgizcl -emit-llvm -o - | FileCheck %s typedef struct { int i; @@ -15,8 +15,6 @@ // CHECK: %struct.ConstantArrayPointerStruct = type { float addrspace(2)* } // CHECK: addrspace(2) constant %struct.ConstantArrayPointerStruct { float addrspace(2)* bitcast (i8 addrspace(2)* getelementptr (i8, i8 addrspace(2)* bitcast (%struct.ArrayStruct addrspace(2)* @constant_array_struct to i8 addrspace(2)*), i64 4) to float addrspace(2)*) } -// GIZ: %struct.ConstantArrayPointerStruct = type { float addrspace(4)* } -// GIZ: addrspace(4) constant %struct.ConstantArrayPointerStruct { float addrspace(4)* bitcast (i8 addrspace(4)* getelementptr (i8, i8 addrspace(4)* bitcast (%struct.ArrayStruct addrspace(4)* @constant_array_struct to i8 addrspace(4)*), i64 4) to float addrspace(4)*) } // Bug 18567 __constant ConstantArrayPointerStruct constant_array_pointer_struct = { &constant_array_struct.f Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -2045,10 +2045,10 @@ 0, // Default 1, // opencl_global 3, // opencl_local -4, // opencl_constant +2, // opencl_constant 0, // opencl_generic 1, // cuda_device -4, // cuda_constant +2, // cuda_constant 3 // cuda_shared }; @@ -2065,7 +2065,7 @@ "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"; static const char *const DataLayoutStringSIGenericIsZero = - "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32" + "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32
[PATCH] D31756: [cmake] Support Gentoo install for z3
ddcc accepted this revision. ddcc added a comment. This revision is now accepted and ready to land. Thanks! Repository: rL LLVM https://reviews.llvm.org/D31756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31771: [AMDGPU] Temporarily change constant address space from 4 to 2 for the new address space mapping
t-tye accepted this revision. t-tye added a comment. This revision is now accepted and ready to land. Other than one comment: LGTM Comment at: lib/Basic/Targets.cpp:2083 Local = 3; -Constant = 4; +Constant = 2; Private = 5; Since Constant is now the same regardless of the GIZ setting, should it be moved to be a literal constant like the other values that do not change? https://reviews.llvm.org/D31771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31771: [AMDGPU] Temporarily change constant address space from 4 to 2 for the new address space mapping
t-tye added a comment. LGTM Comment at: lib/Basic/Targets.cpp:2083 Local = 3; -Constant = 4; +Constant = 2; Private = 5; t-tye wrote: > Since Constant is now the same regardless of the GIZ setting, should it be > moved to be a literal constant like the other values that do not change? Disregard comment as was thinking of the LLVM way address spaces were being handled. https://reviews.llvm.org/D31771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer
Anastasia added inline comments. Comment at: include/clang/AST/ASTContext.h:2328 +return AddrSpaceMapMangling || + AS >= LangAS::target_first; } yaxunl wrote: > yaxunl wrote: > > Anastasia wrote: > > > Anastasia wrote: > > > > yaxunl wrote: > > > > > Anastasia wrote: > > > > > > So we couldn't use the LangAS::Count instead? > > > > > > > > > > > > I have the same comment in other places that use > > > > > > LangAS::target_first. Why couldn't we simply use LangAS::Count? It > > > > > > there any point in having two tags? > > > > > > > > > > > > Another comment is why do we need ASes specified by > > > > > > `__attribute__((address_space(n)))` to be unique enum number at the > > > > > > end of named ASes of OpenCL and CUDA? I think conceptually the full > > > > > > range of ASes can be used in C because the ASes from OpenCL and > > > > > > CUDA are not available there anyways. > > > > > I will use LangAS::Count instead and remove target_first, since their > > > > > values are the same. > > > > > > > > > > For your second question: the values for > > > > > `__attribute__((address_space(n)))` need to be different from the > > > > > language specific address space values because they are mapped to > > > > > target address space differently. > > > > > > > > > > For language specific address space, they are mapped through a target > > > > > defined mapping table. > > > > > > > > > > For `__attribute__((address_space(n)))`, the target address space > > > > > should be the same as n, without going through the mapping table. > > > > > > > > > > If they are defined in overlapping value ranges, they cannot be > > > > > handled in different ways. > > > > > > > > > > > > > > Target address space map currently corresponds to the named address > > > > spaces of OpenCL and CUDA only. So if the idea is to avoid overlapping > > > > with those we should extend the table? Although, I don't see how this > > > > can be done because it will require fixed semantic of address spaces in > > > > C which is currently undefined. > > > Perhaps I am missing something but I don't see any change here that makes > > > non-named address spaces follow different path for the target. > > > > > > Also does this change relate to alloca extension in some way? I still > > > struggle to understand this fully... > > > > > > All I can see is that this change restricts overlapping of named and > > > non-named address spaces but I can't clearly understand the motivation > > > for this. > > `__attribute__((address_space(n)))` is used in C and C++ to specify target > > address space for a variable. > > > > For example, > > https://github.com/llvm-mirror/clang/blob/master/test/Sema/address_spaces.c > > > > Many cases they just need to put a variable in certain target address space > > and do not need specific semantics for these address spaces. > In the definition of `ASTContext::getTargetAddressSpace()` you can see how > address space values below and above LangAS::Count are handled differently. > > The old definition of address space enum does not differentiate between the > default address space 0 (no address space qualifier) and > `__attribute__((address_space(0)))`. > > Before alloca API changes, this does not matter, since address space 0 in AST > is always mapped to target address space 0. > > However, after alloca API changes, default address space 0 is mapped to > target alloca address space, which may be non-zero. Therefore it is necessary > to differentiate between `__attribute__((address_space(0)))` and the default > address space 0. Otherwise, if a user specifies > `__attribute__((address_space(0)))`, it may not be mapped to target address > space 0. > > > However, after alloca API changes, default address space 0 is mapped to > target alloca address space, which may be non-zero. Therefore it is necessary > to differentiate between __attribute__((address_space(0))) and the default > address space 0. In your patch the default AS corresponds to value set in the target address space map and not taken from the alloca AS of the DataLayout. Comment at: include/clang/Basic/AddressSpaces.h:32 + // QualType represents private address space in OpenCL source code. + Default = 0, + The alloca AS is not taken from the target AS map but from the DataLayout. This keep me wonder whether the explicit Default item is actually needed here Comment at: lib/Basic/Targets.cpp:8382 static const unsigned SPIRAddrSpaceMap[] = { +4, // Default 1, // opencl_global This will break use case of compiling for SPIR from C which is needed by some frameworks. We can only use generic if compiled in OpenCL2.0 mode and only for pointer types. Comment at: lib/Sema/SemaExprCXX.cpp:3121 -if (unsigned AddressSpace = Pointee.getAddressSpace()) +if (Pointee
[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations
Eugene.Zelenko added a comment. Isn't such analysis is path-sensitive and should be implemented in Static Analyzer? Please mention this check in docs/ReleaseNotes.rst (in alphabetical order). Comment at: docs/clang-tidy/checks/performance-inefficient-vector-operation.rst:6 + +Finds possible inefficient vector push_back operation that causes unnecessary +memory reallocation. I think will be good idea to use std::vector, and enclose it and push_back in ``. https://reviews.llvm.org/D31757 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31417: [OpenMP] Add support for omp simd pragmas without runtime
kkwli0 added inline comments. Comment at: docs/ClangCommandLineReference.rst:1454 +.. option:: -fopenmp-simd, -fno-openmp-simd + I am not sure if it is target architecture specific or not. If it is, should we be under the target flag instead? https://reviews.llvm.org/D31417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31745: [OpenCL] Added diagnostic for implicit declaration of function in OpenCL
Anastasia added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8254 "%0 cannot be used as the type of a kernel parameter">; +def err_opencl_implicit_function_decl : Error< + "implicit declaration of function %0 is invalid in OpenCL">; Could this be in OpenCL group please? Comment at: test/SemaOpenCL/clang-builtin-version.cl:32 + work_group_reserve_write_pipe(tmp, tmp); // expected-error{{implicit declaration of function 'work_group_reserve_write_pipe' is invalid in OpenCL}} + // expected-note@-1{{did you mean 'work_group_reserve_read_pipe'?}} + // expected-note@-2{{'work_group_reserve_write_pipe' declared here}} Why do we get this note now? I believe work_group_reserve_read_pipe shouldn't be available either? https://reviews.llvm.org/D31745 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26794: [OpenCL] Blocks are allowed to capture arrays in OpenCL 2.0 and higher.
Anastasia added a comment. In https://reviews.llvm.org/D26794#598784, @Anastasia wrote: > I have created a bug to Khronos regarding this, but unfortunately I don't see > it being progressed yet. > https://cvs.khronos.org/bugzilla/show_bug.cgi?id=15659 > > The problem here is that I am not sure we should deviate from the ObjC > implementation because OpenCL blocks are largely taken from Clang ObjC > implementation. My issue is in particular that it's not clear what the > capture of array would mean and spec should either state it precisely or > disallow using this feature at all to avoid costly operations. In ObjC > community itself there were multiple interpretation of this in the past: > http://lists.llvm.org/pipermail/cfe-dev/2016-March/047849.html > > I am not sure we should go ahead with any implementation without further > clarifications. I will ping the Khronos bug to see if the documentation can > be improved. > > I think this issue has been seen in the OpenCL conformance tests, but was > fixed later on? Sure. Do you have an access to revision with an update? I will ask to publish it online too. Comment at: lib/Sema/SemaExpr.cpp:13481 + // Only if it's not OpenCL 2.0. + if (!(S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion >= 200)) { +if (CaptureType->isArrayType()) { Can we do this consistently for all OpenCL (Not just v2.0)! https://reviews.llvm.org/D26794 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] r299666 - Fix unused typedef. Follow up to r299575.
Author: krasin Date: Thu Apr 6 12:35:35 2017 New Revision: 299666 URL: http://llvm.org/viewvc/llvm-project?rev=299666&view=rev Log: Fix unused typedef. Follow up to r299575. Modified: libunwind/trunk/src/AddressSpace.hpp Modified: libunwind/trunk/src/AddressSpace.hpp URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=299666&r1=299665&r2=299666&view=diff == --- libunwind/trunk/src/AddressSpace.hpp (original) +++ libunwind/trunk/src/AddressSpace.hpp Thu Apr 6 12:35:35 2017 @@ -383,7 +383,7 @@ inline bool LocalAddressSpace::findUnwin #if !defined(Elf_Phdr) typedef ElfW(Phdr) Elf_Phdr; #endif -#if !defined(Elf_Addr) +#if !defined(Elf_Addr) && defined(__ANDROID__) typedef ElfW(Addr) Elf_Addr; #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r299671 - Fix unused lambda capture. Follow up to r299653.
Author: krasin Date: Thu Apr 6 12:42:05 2017 New Revision: 299671 URL: http://llvm.org/viewvc/llvm-project?rev=299671&view=rev Log: Fix unused lambda capture. Follow up to r299653. Modified: cfe/trunk/lib/Analysis/CloneDetection.cpp Modified: cfe/trunk/lib/Analysis/CloneDetection.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CloneDetection.cpp?rev=299671&r1=299670&r2=299671&view=diff == --- cfe/trunk/lib/Analysis/CloneDetection.cpp (original) +++ cfe/trunk/lib/Analysis/CloneDetection.cpp Thu Apr 6 12:42:05 2017 @@ -492,7 +492,7 @@ void RecursiveCloneTypeIIConstraint::con // Sort hash_codes in StmtsByHash. std::stable_sort(StmtsByHash.begin(), StmtsByHash.end(), - [this](std::pair LHS, + [](std::pair LHS, std::pair RHS) { return LHS.first < RHS.first; }); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29651: [OpenMP] Consider LIBRARY_PATH when selecting library paths for NVPTX targets in OpenMP mode.
ABataev added inline comments. Comment at: test/Driver/openmp-offload.c:622 +/// Check that the lib folder pointed to by the LIBRARY_PATH is correctly passsed to the loader script. +// RUN: LIBRARY_PATH=/a/b/c/lib %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-LIB-PATH %s Will it work on Windows? Repository: rL LLVM https://reviews.llvm.org/D29651 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer
yaxunl marked 11 inline comments as done. yaxunl added inline comments. Comment at: include/clang/AST/ASTContext.h:2328 +return AddrSpaceMapMangling || + AS >= LangAS::target_first; } Anastasia wrote: > yaxunl wrote: > > yaxunl wrote: > > > Anastasia wrote: > > > > Anastasia wrote: > > > > > yaxunl wrote: > > > > > > Anastasia wrote: > > > > > > > So we couldn't use the LangAS::Count instead? > > > > > > > > > > > > > > I have the same comment in other places that use > > > > > > > LangAS::target_first. Why couldn't we simply use LangAS::Count? > > > > > > > It there any point in having two tags? > > > > > > > > > > > > > > Another comment is why do we need ASes specified by > > > > > > > `__attribute__((address_space(n)))` to be unique enum number at > > > > > > > the end of named ASes of OpenCL and CUDA? I think conceptually > > > > > > > the full range of ASes can be used in C because the ASes from > > > > > > > OpenCL and CUDA are not available there anyways. > > > > > > I will use LangAS::Count instead and remove target_first, since > > > > > > their values are the same. > > > > > > > > > > > > For your second question: the values for > > > > > > `__attribute__((address_space(n)))` need to be different from the > > > > > > language specific address space values because they are mapped to > > > > > > target address space differently. > > > > > > > > > > > > For language specific address space, they are mapped through a > > > > > > target defined mapping table. > > > > > > > > > > > > For `__attribute__((address_space(n)))`, the target address space > > > > > > should be the same as n, without going through the mapping table. > > > > > > > > > > > > If they are defined in overlapping value ranges, they cannot be > > > > > > handled in different ways. > > > > > > > > > > > > > > > > > Target address space map currently corresponds to the named address > > > > > spaces of OpenCL and CUDA only. So if the idea is to avoid > > > > > overlapping with those we should extend the table? Although, I don't > > > > > see how this can be done because it will require fixed semantic of > > > > > address spaces in C which is currently undefined. > > > > Perhaps I am missing something but I don't see any change here that > > > > makes non-named address spaces follow different path for the target. > > > > > > > > Also does this change relate to alloca extension in some way? I still > > > > struggle to understand this fully... > > > > > > > > All I can see is that this change restricts overlapping of named and > > > > non-named address spaces but I can't clearly understand the motivation > > > > for this. > > > `__attribute__((address_space(n)))` is used in C and C++ to specify > > > target address space for a variable. > > > > > > For example, > > > https://github.com/llvm-mirror/clang/blob/master/test/Sema/address_spaces.c > > > > > > > > > Many cases they just need to put a variable in certain target address > > > space and do not need specific semantics for these address spaces. > > In the definition of `ASTContext::getTargetAddressSpace()` you can see how > > address space values below and above LangAS::Count are handled differently. > > > > The old definition of address space enum does not differentiate between the > > default address space 0 (no address space qualifier) and > > `__attribute__((address_space(0)))`. > > > > Before alloca API changes, this does not matter, since address space 0 in > > AST is always mapped to target address space 0. > > > > However, after alloca API changes, default address space 0 is mapped to > > target alloca address space, which may be non-zero. Therefore it is > > necessary to differentiate between `__attribute__((address_space(0)))` and > > the default address space 0. Otherwise, if a user specifies > > `__attribute__((address_space(0)))`, it may not be mapped to target address > > space 0. > > > > > > However, after alloca API changes, default address space 0 is mapped to > > target alloca address space, which may be non-zero. Therefore it is > > necessary to differentiate between __attribute__((address_space(0))) and > > the default address space 0. > In your patch the default AS corresponds to value set in the target address > space map and not taken from the alloca AS of the DataLayout. Addr space 0 is mapped to alloca addr space for OpenCL and mapped to target-specified addr space for other languages, which is done by ASTContext::getTargetAddressSpace. In either case, it may not be mapped to 0. Comment at: include/clang/Basic/AddressSpaces.h:32 + // QualType represents private address space in OpenCL source code. + Default = 0, + Anastasia wrote: > The alloca AS is not taken from the target AS map but from the DataLayout. > This keep me wonder whether the explicit Default item is actually needed > here For OpenCL, t
[PATCH] D31696: Automatically add include-what-you-use for when building in tree
zturner added reviewers: beanz, rnk, chandlerc. zturner added a comment. Not really sure who to add as a reviewer here, so + a few random people. BTW, kimgr@, is there any particular reason you haven't tried to upstream the tool? Maybe even as not a standalone tool but as a set of checks in `clang-tidy`. https://reviews.llvm.org/D31696 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer
yaxunl updated this revision to Diff 94399. yaxunl marked 5 inline comments as done. yaxunl added a comment. Revised by Anastasia's comments. https://reviews.llvm.org/D31404 Files: include/clang/AST/ASTContext.h include/clang/AST/Type.h include/clang/Basic/AddressSpaces.h lib/AST/ASTContext.cpp lib/AST/ExprClassification.cpp lib/AST/TypePrinter.cpp lib/Basic/Targets.cpp lib/CodeGen/CGCall.cpp lib/CodeGen/CGExpr.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaOverload.cpp lib/Sema/SemaType.cpp test/CodeGen/address-space.c test/CodeGen/default-address-space.c test/CodeGenOpenCL/address-space-constant-initializers.cl test/CodeGenOpenCL/address-spaces.cl test/CodeGenOpenCL/amdgpu-env-amdgiz.cl test/CodeGenOpenCL/vla.cl test/Sema/address_spaces.c test/Sema/invalid-assignment-constant-address-space.c test/SemaOpenCL/invalid-assignment-constant-address-space.cl Index: test/SemaOpenCL/invalid-assignment-constant-address-space.cl === --- /dev/null +++ test/SemaOpenCL/invalid-assignment-constant-address-space.cl @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only + +int constant c[3] = {0}; + +void foo() { + c[0] = 1; //expected-error{{read-only variable is not assignable}} +} Index: test/Sema/invalid-assignment-constant-address-space.c === --- test/Sema/invalid-assignment-constant-address-space.c +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only - -#define OPENCL_CONSTANT 8388354 -int __attribute__((address_space(OPENCL_CONSTANT))) c[3] = {0}; - -void foo() { - c[0] = 1; //expected-error{{read-only variable is not assignable}} -} Index: test/Sema/address_spaces.c === --- test/Sema/address_spaces.c +++ test/Sema/address_spaces.c @@ -20,7 +20,7 @@ _AS1 int arrarr[5][5]; // expected-error {{automatic variable qualified with an address space}} __attribute__((address_space(-1))) int *_boundsA; // expected-error {{address space is negative}} - __attribute__((address_space(0x7F))) int *_boundsB; + __attribute__((address_space(0x7F))) int *_boundsB; // expected-error {{address space is larger than the maximum supported}} __attribute__((address_space(0x100))) int *_boundsC; // expected-error {{address space is larger than the maximum supported}} // chosen specifically to overflow 32 bits and come out reasonable __attribute__((address_space(4294967500))) int *_boundsD; // expected-error {{address space is larger than the maximum supported}} Index: test/CodeGenOpenCL/vla.cl === --- test/CodeGenOpenCL/vla.cl +++ test/CodeGenOpenCL/vla.cl @@ -1,18 +1,26 @@ -// RUN: %clang_cc1 -emit-llvm -triple "spir-unknown-unknown" -O0 -cl-std=CL2.0 -o - %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -triple "spir-unknown-unknown" -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,SPIR %s +// RUN: %clang_cc1 -emit-llvm -triple amdgcn-amd-amdhsa-opencl -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,SPIR %s +// RUN: %clang_cc1 -emit-llvm -triple amdgcn-amd-amdhsa-amdgizcl -O0 -cl-std=CL2.0 -o - %s | FileCheck -check-prefixes=CHECK,GIZ %s constant int sz0 = 5; -// CHECK: @sz0 = addrspace(2) constant i32 5 +// SPIR: @sz0 = addrspace(2) constant i32 5 +// GIZ: @sz0 = addrspace(4) constant i32 5 const global int sz1 = 16; // CHECK: @sz1 = addrspace(1) constant i32 16 const constant int sz2 = 8; -// CHECK: @sz2 = addrspace(2) constant i32 8 +// SPIR: @sz2 = addrspace(2) constant i32 8 +// GIZ: @sz2 = addrspace(4) constant i32 8 // CHECK: @testvla.vla2 = internal addrspace(3) global [8 x i16] undef kernel void testvla() { int vla0[sz0]; -// CHECK: %vla0 = alloca [5 x i32] +// SPIR: %vla0 = alloca [5 x i32] +// SPIR-NOT: %vla0 = alloca [5 x i32]{{.*}}addrspace +// GIZ: %vla0 = alloca [5 x i32]{{.*}}addrspace(5) char vla1[sz1]; -// CHECK: %vla1 = alloca [16 x i8] +// SPIR: %vla1 = alloca [16 x i8] +// SPIR-NOT: %vla1 = alloca [16 x i8]{{.*}}addrspace +// GIZ: %vla1 = alloca [16 x i8]{{.*}}addrspace(5) local short vla2[sz2]; } Index: test/CodeGenOpenCL/amdgpu-env-amdgiz.cl === --- test/CodeGenOpenCL/amdgpu-env-amdgiz.cl +++ test/CodeGenOpenCL/amdgpu-env-amdgiz.cl @@ -4,6 +4,6 @@ // RUN: %clang_cc1 %s -O0 -triple amdgcn---amdgizcl -emit-llvm -o - | FileCheck -check-prefix=GIZ %s // CHECK: target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" -// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" +// GIZ: target datalayo
[PATCH] D31778: [Modules] Implement ODR-like semantics for tag types in C/ObjC
bruno created this revision. Allow ODR for ObjC/C in the sense that we won't keep more that one definition around (merge them). However, ensure the decl pass the structural compatibility check in C11 6.2.7/1, for that, reuse the structural equivalence checks used by the ASTImporter. Few other considerations: - Create error diagnostics for tag types mismatches and thread them into the structural equivalence checks. - Note that by doing this we only support redefinition between types that are considered "compatible types" by C11. This is mixed approach of the suggestions discussed in http://lists.llvm.org/pipermail/cfe-dev/2017-March/053257.html https://reviews.llvm.org/D31778 Files: include/clang/AST/ASTStructuralEquivalence.h include/clang/Basic/DiagnosticASTKinds.td include/clang/Parse/Parser.h include/clang/Sema/Sema.h lib/AST/ASTStructuralEquivalence.cpp lib/Parse/ParseDecl.cpp lib/Parse/ParseDeclCXX.cpp lib/Parse/ParseExpr.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaType.cpp test/Modules/Inputs/F.framework/Headers/F.h test/Modules/Inputs/F.framework/Modules/module.modulemap test/Modules/Inputs/F.framework/Modules/module.private.modulemap test/Modules/Inputs/F.framework/PrivateHeaders/NS.h test/Modules/elaborated-type-specifier-from-hidden-module.m test/Modules/redefinition-c-tagtypes.m Index: test/Modules/redefinition-c-tagtypes.m === --- /dev/null +++ test/Modules/redefinition-c-tagtypes.m @@ -0,0 +1,48 @@ +// RUN: rm -rf %t.cache +// RUN: %clang_cc1 -fsyntax-only %s -fmodules -fmodules-cache-path=%t.cache \ +// RUN: -fimplicit-module-maps -F%S/Inputs -verify +// RUN: %clang_cc1 -fsyntax-only %s -fmodules -fmodules-cache-path=%t.cache \ +// RUN: -fimplicit-module-maps -F%S/Inputs -DCHANGE_TAGS -verify +#include "F/F.h" + +#ifndef CHANGE_TAGS +// expected-no-diagnostics +#endif + +struct NS { + int a; +#ifndef CHANGE_TAGS + int b; +#else + int c; // expected-note {{field has name 'c' here}} + // expected-error@redefinition-c-tagtypes.m:12 {{type 'struct NS' has incompatible definitions}} + // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:3 {{field has name 'b' here}} +#endif +}; + +enum NSE { + FST = 22, +#ifndef CHANGE_TAGS + SND = 43, +#else + SND = 44, // expected-note {{enumerator 'SND' with value 44 here}} + // expected-error@redefinition-c-tagtypes.m:23 {{type 'enum NSE' has incompatible definitions}} + // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:8 {{enumerator 'SND' with value 43 here}} +#endif + TRD = 55 +}; + +#define NS_ENUM(_type, _name) \ + enum _name : _type _name; \ + enum _name : _type + +typedef NS_ENUM(int, NSMyEnum) { + MinX = 11, +#ifndef CHANGE_TAGS + MinXOther = MinX, +#else + MinXOther = TRD, // expected-note {{enumerator 'MinXOther' with value 55 here}} + // expected-error@redefinition-c-tagtypes.m:39 {{type 'enum NSMyEnum' has incompatible definitions}} + // expected-note@Inputs/F.framework/PrivateHeaders/NS.h:18 {{enumerator 'MinXOther' with value 11 here}} +#endif +}; Index: test/Modules/elaborated-type-specifier-from-hidden-module.m === --- test/Modules/elaborated-type-specifier-from-hidden-module.m +++ test/Modules/elaborated-type-specifier-from-hidden-module.m @@ -4,12 +4,11 @@ @import ElaboratedTypeStructs.Empty; // The structs are now hidden. struct S1 *x; struct S2 *y; -// FIXME: compatible definition should not be an error. -struct S2 { int x; }; // expected-error {{redefinition}} +struct S2 { int x; }; struct S3 *z; // Incompatible definition. -struct S3 { float y; }; // expected-error {{redefinition}} -// expected-note@elaborated-type-structs.h:* 2 {{previous definition is here}} +struct S3 { float y; }; // expected-error {{has incompatible definitions}} // expected-note {{field has name}} +// expected-note@Inputs/elaborated-type-structs.h:3 {{field has name}} @import ElaboratedTypeStructs.Structs; Index: test/Modules/Inputs/F.framework/PrivateHeaders/NS.h === --- /dev/null +++ test/Modules/Inputs/F.framework/PrivateHeaders/NS.h @@ -0,0 +1,19 @@ +struct NS { + int a; + int b; +}; + +enum NSE { + FST = 22, + SND = 43, + TRD = 55 +}; + +#define NS_ENUM(_type, _name) \ + enum _name : _type _name; \ + enum _name : _type + +typedef NS_ENUM(int, NSMyEnum) { + MinX = 11, + MinXOther = MinX, +}; Index: test/Modules/Inputs/F.framework/Modules/module.private.modulemap === --- /dev/null +++ test/Modules/Inputs/F.framework/Modules/module.private.modulemap @@ -0,0 +1,7 @@ +module F.Private [system] { + explicit module NS { + header "NS.h" + export * + } + export * +} Index: test/Modules/Inputs/F.framework/Modules/module.modulemap =
[PATCH] D31713: [Basic] getColumnNumber returns location of CR+LF on Windows
chh updated this revision to Diff 94402. chh marked an inline comment as done. https://reviews.llvm.org/D31713 Files: lib/Basic/SourceManager.cpp Index: lib/Basic/SourceManager.cpp === --- lib/Basic/SourceManager.cpp +++ lib/Basic/SourceManager.cpp @@ -1136,19 +1136,28 @@ return 1; } + const char *Buf = MemBuf->getBufferStart(); // See if we just calculated the line number for this FilePos and can use // that to lookup the start of the line instead of searching for it. if (LastLineNoFileIDQuery == FID && LastLineNoContentCache->SourceLineCache != nullptr && LastLineNoResult < LastLineNoContentCache->NumLines) { unsigned *SourceLineCache = LastLineNoContentCache->SourceLineCache; unsigned LineStart = SourceLineCache[LastLineNoResult - 1]; unsigned LineEnd = SourceLineCache[LastLineNoResult]; -if (FilePos >= LineStart && FilePos < LineEnd) +if (FilePos >= LineStart && FilePos < LineEnd) { + // LineEnd is the LineStart of the next line. + // A line ends with separator LF or CR+LF on Windows. + // FilePos might point to the last separator, + // but we need a column number at most 1 + the last column. + if (FilePos + 1 == LineEnd && FilePos > LineStart) { +if (Buf[FilePos - 1] == '\r' || Buf[FilePos - 1] == '\n') + --FilePos; + } return FilePos - LineStart + 1; +} } - const char *Buf = MemBuf->getBufferStart(); unsigned LineStart = FilePos; while (LineStart && Buf[LineStart-1] != '\n' && Buf[LineStart-1] != '\r') --LineStart; Index: lib/Basic/SourceManager.cpp === --- lib/Basic/SourceManager.cpp +++ lib/Basic/SourceManager.cpp @@ -1136,19 +1136,28 @@ return 1; } + const char *Buf = MemBuf->getBufferStart(); // See if we just calculated the line number for this FilePos and can use // that to lookup the start of the line instead of searching for it. if (LastLineNoFileIDQuery == FID && LastLineNoContentCache->SourceLineCache != nullptr && LastLineNoResult < LastLineNoContentCache->NumLines) { unsigned *SourceLineCache = LastLineNoContentCache->SourceLineCache; unsigned LineStart = SourceLineCache[LastLineNoResult - 1]; unsigned LineEnd = SourceLineCache[LastLineNoResult]; -if (FilePos >= LineStart && FilePos < LineEnd) +if (FilePos >= LineStart && FilePos < LineEnd) { + // LineEnd is the LineStart of the next line. + // A line ends with separator LF or CR+LF on Windows. + // FilePos might point to the last separator, + // but we need a column number at most 1 + the last column. + if (FilePos + 1 == LineEnd && FilePos > LineStart) { +if (Buf[FilePos - 1] == '\r' || Buf[FilePos - 1] == '\n') + --FilePos; + } return FilePos - LineStart + 1; +} } - const char *Buf = MemBuf->getBufferStart(); unsigned LineStart = FilePos; while (LineStart && Buf[LineStart-1] != '\n' && Buf[LineStart-1] != '\r') --LineStart; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31043: Update for lifetime intrinsic signature change
rjmccall accepted this revision. rjmccall added a comment. This revision is now accepted and ready to land. LGTM. https://reviews.llvm.org/D31043 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r299678 - [AMDGPU] Translate reqd_work_group_size into amdgpu_flat_work_group_size
Author: rampitec Date: Thu Apr 6 13:15:44 2017 New Revision: 299678 URL: http://llvm.org/viewvc/llvm-project?rev=299678&view=rev Log: [AMDGPU] Translate reqd_work_group_size into amdgpu_flat_work_group_size These two attributes specify the same info in a different way. AMGPU BE only checks the latter as a target specific attribute as opposed to language specific reqd_work_group_size. This change produces amdgpu_flat_work_group_size out of reqd_work_group_size if specified. Differential Revision: https://reviews.llvm.org/D31728 Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=299678&r1=299677&r2=299678&view=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Apr 6 13:15:44 2017 @@ -7302,9 +7302,14 @@ void AMDGPUTargetCodeGenInfo::setTargetA llvm::Function *F = cast(GV); - if (const auto *Attr = FD->getAttr()) { -unsigned Min = Attr->getMin(); -unsigned Max = Attr->getMax(); + const auto *ReqdWGS = M.getLangOpts().OpenCL ? +FD->getAttr() : nullptr; + const auto *FlatWGS = FD->getAttr(); + if (ReqdWGS || FlatWGS) { +unsigned Min = FlatWGS ? FlatWGS->getMin() : 0; +unsigned Max = FlatWGS ? FlatWGS->getMax() : 0; +if (ReqdWGS && Min == 0 && Max == 0) + Min = Max = ReqdWGS->getXDim() * ReqdWGS->getYDim() * ReqdWGS->getZDim(); if (Min != 0) { assert(Min <= Max && "Min must be less than or equal Max"); Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl?rev=299678&r1=299677&r2=299678&view=diff == --- cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl Thu Apr 6 13:15:44 2017 @@ -129,6 +129,16 @@ kernel void flat_work_group_size_32_64_w // CHECK: define amdgpu_kernel void @flat_work_group_size_32_64_waves_per_eu_2_4_num_sgpr_32_num_vgpr_64() [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4_NUM_SGPR_32_NUM_VGPR_64:#[0-9]+]] } +__attribute__((reqd_work_group_size(32, 2, 1))) // expected-no-diagnostics +kernel void reqd_work_group_size_32_2_1() { +// CHECK: define amdgpu_kernel void @reqd_work_group_size_32_2_1() [[FLAT_WORK_GROUP_SIZE_64_64:#[0-9]+]] +} +__attribute__((reqd_work_group_size(32, 2, 1), amdgpu_flat_work_group_size(16, 128))) // expected-no-diagnostics +kernel void reqd_work_group_size_32_2_1_flat_work_group_size_16_128() { +// CHECK: define amdgpu_kernel void @reqd_work_group_size_32_2_1_flat_work_group_size_16_128() [[FLAT_WORK_GROUP_SIZE_16_128:#[0-9]+]] +} + + // Make sure this is silently accepted on other targets. // X86-NOT: "amdgpu-flat-work-group-size" // X86-NOT: "amdgpu-waves-per-eu" @@ -142,6 +152,8 @@ kernel void flat_work_group_size_32_64_w // CHECK-NOT: "amdgpu-num-vgpr"="0" // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { noinline nounwind "amdgpu-flat-work-group-size"="32,64" +// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_64_64]] = { noinline nounwind "amdgpu-flat-work-group-size"="64,64" +// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_16_128]] = { noinline nounwind "amdgpu-flat-work-group-size"="16,128" // CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { noinline nounwind "amdgpu-waves-per-eu"="2" // CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { noinline nounwind "amdgpu-waves-per-eu"="2,4" // CHECK-DAG: attributes [[NUM_SGPR_32]] = { noinline nounwind "amdgpu-num-sgpr"="32" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31781: [Modules] Allow local submodule visibility without c++
bruno created this revision. Removing this restriction will make it handy to explore local submodule visibility without c++ being turned on. We're currently testing it out with C/ObjC. https://reviews.llvm.org/D31781 Files: lib/Frontend/CompilerInvocation.cpp Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -2113,12 +2113,6 @@ Args.hasFlag(OPT_fdeclspec, OPT_fno_declspec, (Opts.MicrosoftExt || Opts.Borland || Opts.CUDA)); - // For now, we only support local submodule visibility in C++ (because we - // heavily depend on the ODR for merging redefinitions). - if (Opts.ModulesLocalVisibility && !Opts.CPlusPlus) -Diags.Report(diag::err_drv_argument_not_allowed_with) -<< "-fmodules-local-submodule-visibility" << "C"; - if (Arg *A = Args.getLastArg(OPT_faddress_space_map_mangling_EQ)) { switch (llvm::StringSwitch(A->getValue()) .Case("target", LangOptions::ASMM_Target) Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -2113,12 +2113,6 @@ Args.hasFlag(OPT_fdeclspec, OPT_fno_declspec, (Opts.MicrosoftExt || Opts.Borland || Opts.CUDA)); - // For now, we only support local submodule visibility in C++ (because we - // heavily depend on the ODR for merging redefinitions). - if (Opts.ModulesLocalVisibility && !Opts.CPlusPlus) -Diags.Report(diag::err_drv_argument_not_allowed_with) -<< "-fmodules-local-submodule-visibility" << "C"; - if (Arg *A = Args.getLastArg(OPT_faddress_space_map_mangling_EQ)) { switch (llvm::StringSwitch(A->getValue()) .Case("target", LangOptions::ASMM_Target) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r299680 - Recommit awk tests with warnings removed. Initial commit r299652, reverted r299656.
Author: marshall Date: Thu Apr 6 13:34:36 2017 New Revision: 299680 URL: http://llvm.org/viewvc/llvm-project?rev=299680&view=rev Log: Recommit awk tests with warnings removed. Initial commit r299652, reverted r299656. Modified: libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp Modified: libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp?rev=299680&r1=299679&r2=299680&view=diff == --- libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp (original) +++ libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp Thu Apr 6 13:34:36 2017 @@ -26,7 +26,7 @@ int main() { -/*{ +{ std::cmatch m; const char s[] = "a"; assert(std::regex_match(s, m, std::regex("a", std::regex_constants::awk))); @@ -263,7 +263,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); -assert(m.length(0) == std::char_traits::length(s)); +assert((size_t)m.length(0) == std::char_traits::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -278,7 +278,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); -assert(m.length(0) == std::char_traits::length(s)); +assert((size_t)m.length(0) == std::char_traits::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -293,7 +293,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); -assert(m.length(0) == std::char_traits::length(s)); +assert((size_t)m.length(0) == std::char_traits::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -326,7 +326,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); -assert(m.length(0) == std::char_traits::length(s)); +assert((size_t)m.length(0) == std::char_traits::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -341,7 +341,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); -assert(m.length(0) == std::char_traits::length(s)); +assert((size_t)m.length(0) == std::char_traits::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -356,7 +356,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); -assert(m.length(0) == std::char_traits::length(s)); +assert((size_t)m.length(0) == std::char_traits::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -378,7 +378,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); -assert(m.length(0) == std::char_traits::length(s)); +assert((size_t)m.length(0) == std::char_traits::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -394,7 +394,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); -assert(m.length(0) == std::char_traits::length(s)); +assert((size_t)m.length(0) == std::char_traits::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -410,7 +410,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); -assert(m.length(0) == std::char_traits::length(s)); +assert((size_t)m.length(0) == std::char_traits::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); assert(m.length(1) == 4); @@ -434,7 +434,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); -assert(m.length(0) == std::char_traits::length(s)); +assert((size_t)m.length(0) == std::char_traits::length(s)); assert(m.position(0) == 0); assert(m.str(0) == s); } @@ -519,7 +519,7 @@ int main() assert(!m.suffix().matched); assert(m.suffix().first == m[0].second); assert(m.suffix().second == m[0].second); -assert(m.length(0) == std::char_traits::length(s)); +assert((size_t)m.length(0) == std::
r299681 - [Basic] getColumnNumber returns location of CR+LF on Windows
Author: chh Date: Thu Apr 6 13:36:50 2017 New Revision: 299681 URL: http://llvm.org/viewvc/llvm-project?rev=299681&view=rev Log: [Basic] getColumnNumber returns location of CR+LF on Windows When fixing a Clang-Tidy bug in D31406, reuse of FileID enabled the missing highlightRange function. Assertion in highlightRange failed because the end-of-range column number was 2 + the last column of a line on Windows. This fix is required to enable D31406. Differential Revision: https://reviews.llvm.org/D31713 Modified: cfe/trunk/lib/Basic/SourceManager.cpp Modified: cfe/trunk/lib/Basic/SourceManager.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=299681&r1=299680&r2=299681&view=diff == --- cfe/trunk/lib/Basic/SourceManager.cpp (original) +++ cfe/trunk/lib/Basic/SourceManager.cpp Thu Apr 6 13:36:50 2017 @@ -1136,6 +1136,7 @@ unsigned SourceManager::getColumnNumber( return 1; } + const char *Buf = MemBuf->getBufferStart(); // See if we just calculated the line number for this FilePos and can use // that to lookup the start of the line instead of searching for it. if (LastLineNoFileIDQuery == FID && @@ -1144,11 +1145,19 @@ unsigned SourceManager::getColumnNumber( unsigned *SourceLineCache = LastLineNoContentCache->SourceLineCache; unsigned LineStart = SourceLineCache[LastLineNoResult - 1]; unsigned LineEnd = SourceLineCache[LastLineNoResult]; -if (FilePos >= LineStart && FilePos < LineEnd) +if (FilePos >= LineStart && FilePos < LineEnd) { + // LineEnd is the LineStart of the next line. + // A line ends with separator LF or CR+LF on Windows. + // FilePos might point to the last separator, + // but we need a column number at most 1 + the last column. + if (FilePos + 1 == LineEnd && FilePos > LineStart) { +if (Buf[FilePos - 1] == '\r' || Buf[FilePos - 1] == '\n') + --FilePos; + } return FilePos - LineStart + 1; +} } - const char *Buf = MemBuf->getBufferStart(); unsigned LineStart = FilePos; while (LineStart && Buf[LineStart-1] != '\n' && Buf[LineStart-1] != '\r') --LineStart; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31713: [Basic] getColumnNumber returns location of CR+LF on Windows
This revision was automatically updated to reflect the committed changes. Closed by commit rL299681: [Basic] getColumnNumber returns location of CR+LF on Windows (authored by chh). Changed prior to commit: https://reviews.llvm.org/D31713?vs=94402&id=94410#toc Repository: rL LLVM https://reviews.llvm.org/D31713 Files: cfe/trunk/lib/Basic/SourceManager.cpp Index: cfe/trunk/lib/Basic/SourceManager.cpp === --- cfe/trunk/lib/Basic/SourceManager.cpp +++ cfe/trunk/lib/Basic/SourceManager.cpp @@ -1136,19 +1136,28 @@ return 1; } + const char *Buf = MemBuf->getBufferStart(); // See if we just calculated the line number for this FilePos and can use // that to lookup the start of the line instead of searching for it. if (LastLineNoFileIDQuery == FID && LastLineNoContentCache->SourceLineCache != nullptr && LastLineNoResult < LastLineNoContentCache->NumLines) { unsigned *SourceLineCache = LastLineNoContentCache->SourceLineCache; unsigned LineStart = SourceLineCache[LastLineNoResult - 1]; unsigned LineEnd = SourceLineCache[LastLineNoResult]; -if (FilePos >= LineStart && FilePos < LineEnd) +if (FilePos >= LineStart && FilePos < LineEnd) { + // LineEnd is the LineStart of the next line. + // A line ends with separator LF or CR+LF on Windows. + // FilePos might point to the last separator, + // but we need a column number at most 1 + the last column. + if (FilePos + 1 == LineEnd && FilePos > LineStart) { +if (Buf[FilePos - 1] == '\r' || Buf[FilePos - 1] == '\n') + --FilePos; + } return FilePos - LineStart + 1; +} } - const char *Buf = MemBuf->getBufferStart(); unsigned LineStart = FilePos; while (LineStart && Buf[LineStart-1] != '\n' && Buf[LineStart-1] != '\r') --LineStart; Index: cfe/trunk/lib/Basic/SourceManager.cpp === --- cfe/trunk/lib/Basic/SourceManager.cpp +++ cfe/trunk/lib/Basic/SourceManager.cpp @@ -1136,19 +1136,28 @@ return 1; } + const char *Buf = MemBuf->getBufferStart(); // See if we just calculated the line number for this FilePos and can use // that to lookup the start of the line instead of searching for it. if (LastLineNoFileIDQuery == FID && LastLineNoContentCache->SourceLineCache != nullptr && LastLineNoResult < LastLineNoContentCache->NumLines) { unsigned *SourceLineCache = LastLineNoContentCache->SourceLineCache; unsigned LineStart = SourceLineCache[LastLineNoResult - 1]; unsigned LineEnd = SourceLineCache[LastLineNoResult]; -if (FilePos >= LineStart && FilePos < LineEnd) +if (FilePos >= LineStart && FilePos < LineEnd) { + // LineEnd is the LineStart of the next line. + // A line ends with separator LF or CR+LF on Windows. + // FilePos might point to the last separator, + // but we need a column number at most 1 + the last column. + if (FilePos + 1 == LineEnd && FilePos > LineStart) { +if (Buf[FilePos - 1] == '\r' || Buf[FilePos - 1] == '\n') + --FilePos; + } return FilePos - LineStart + 1; +} } - const char *Buf = MemBuf->getBufferStart(); unsigned LineStart = FilePos; while (LineStart && Buf[LineStart-1] != '\n' && Buf[LineStart-1] != '\r') --LineStart; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r299686 - Some of Eric's buildbots don't like this test. Disable it while I figure out why.
Author: marshall Date: Thu Apr 6 13:54:37 2017 New Revision: 299686 URL: http://llvm.org/viewvc/llvm-project?rev=299686&view=rev Log: Some of Eric's buildbots don't like this test. Disable it while I figure out why. Modified: libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp Modified: libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp?rev=299686&r1=299685&r2=299686&view=diff == --- libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp (original) +++ libcxx/trunk/test/std/re/re.alg/re.alg.match/awk.pass.cpp Thu Apr 6 13:54:37 2017 @@ -26,6 +26,7 @@ int main() { +#if 0 { std::cmatch m; const char s[] = "a"; @@ -1388,4 +1389,5 @@ int main() assert(m.position(0) == 0); assert(m.str(0) == s); } +#endif } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r299691 - [AMDGPU] Temporarily change constant address space from 4 to 2 for the new address space mapping
Author: yaxunl Date: Thu Apr 6 14:18:36 2017 New Revision: 299691 URL: http://llvm.org/viewvc/llvm-project?rev=299691&view=rev Log: [AMDGPU] Temporarily change constant address space from 4 to 2 for the new address space mapping Change constant address space from 4 to 2 for the new address space mapping in Clang. Differential Revision: https://reviews.llvm.org/D31771 Modified: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=299691&r1=299690&r2=299691&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Thu Apr 6 14:18:36 2017 @@ -2042,10 +2042,10 @@ static const LangAS::Map AMDGPUPrivateIs static const LangAS::Map AMDGPUGenericIsZeroMap = { 1, // opencl_global 3, // opencl_local -4, // opencl_constant +2, // opencl_constant 0, // opencl_generic 1, // cuda_device -4, // cuda_constant +2, // cuda_constant 3 // cuda_shared }; @@ -2062,7 +2062,7 @@ static const char *const DataLayoutStrin "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"; static const char *const DataLayoutStringSIGenericIsZero = - "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32" + "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32" "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128" "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"; @@ -2077,7 +2077,7 @@ class AMDGPUTargetInfo final : public Ta Generic = 0; Global= 1; Local = 3; -Constant = 4; +Constant = 2; Private = 5; } else { Generic = 4; Modified: cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl?rev=299691&r1=299690&r2=299691&view=diff == --- cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl Thu Apr 6 14:18:36 2017 @@ -1,4 +1,6 @@ // RUN: %clang_cc1 %s -ffake-address-space-map -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-opencl -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-amdgizcl -emit-llvm -o - | FileCheck %s typedef struct { int i; Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl?rev=299691&r1=299690&r2=299691&view=diff == --- cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl Thu Apr 6 14:18:36 2017 @@ -4,6 +4,6 @@ // RUN: %clang_cc1 %s -O0 -triple amdgcn---amdgizcl -emit-llvm -o - | FileCheck -check-prefix=GIZ %s // CHECK: target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" -// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" +// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" void foo(void) {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31771: [AMDGPU] Temporarily change constant address space from 4 to 2 for the new address space mapping
This revision was automatically updated to reflect the committed changes. Closed by commit rL299691: [AMDGPU] Temporarily change constant address space from 4 to 2 for the new… (authored by yaxunl). Changed prior to commit: https://reviews.llvm.org/D31771?vs=94386&id=94418#toc Repository: rL LLVM https://reviews.llvm.org/D31771 Files: cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl Index: cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl === --- cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl +++ cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl @@ -1,4 +1,6 @@ // RUN: %clang_cc1 %s -ffake-address-space-map -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-opencl -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-amdgizcl -emit-llvm -o - | FileCheck %s typedef struct { int i; Index: cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl === --- cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl +++ cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl @@ -4,6 +4,6 @@ // RUN: %clang_cc1 %s -O0 -triple amdgcn---amdgizcl -emit-llvm -o - | FileCheck -check-prefix=GIZ %s // CHECK: target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" -// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" +// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" void foo(void) {} Index: cfe/trunk/lib/Basic/Targets.cpp === --- cfe/trunk/lib/Basic/Targets.cpp +++ cfe/trunk/lib/Basic/Targets.cpp @@ -2042,10 +2042,10 @@ static const LangAS::Map AMDGPUGenericIsZeroMap = { 1, // opencl_global 3, // opencl_local -4, // opencl_constant +2, // opencl_constant 0, // opencl_generic 1, // cuda_device -4, // cuda_constant +2, // cuda_constant 3 // cuda_shared }; @@ -2062,7 +2062,7 @@ "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"; static const char *const DataLayoutStringSIGenericIsZero = - "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32" + "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32" "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128" "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"; @@ -2077,7 +2077,7 @@ Generic = 0; Global= 1; Local = 3; -Constant = 4; +Constant = 2; Private = 5; } else { Generic = 4; Index: cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl === --- cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl +++ cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl @@ -1,4 +1,6 @@ // RUN: %clang_cc1 %s -ffake-address-space-map -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-opencl -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa-amdgizcl -emit-llvm -o - | FileCheck %s typedef struct { int i; Index: cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl === --- cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl +++ cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl @@ -4,6 +4,6 @@ // RUN: %clang_cc1 %s -O0 -triple amdgcn---amdgizcl -emit-llvm -o - | FileCheck -check-prefix=GIZ %s // CHECK: target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" -// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" +// GIZ: target datalayout = "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64" void foo(void) {} Index: cfe/trunk/lib/Basic/Targets.cpp === --- cfe/trunk/lib/Basic/Targets.cpp +++ cfe/trunk/lib/Basic/Targets.cpp @@ -2042,10 +2042,10 @@ static const LangAS::Map AMDGPUGenericIsZeroMap = { 1, // opencl_global 3, // opencl_local -4, // opencl_constant +2, // opencl_constant
[PATCH] D31696: Automatically add include-what-you-use for when building in tree
kimgr added a comment. > BTW, kimgr@, is there any particular reason you haven't tried to upstream the > tool? > Maybe even as not a standalone tool but as a set of checks in clang-tidy. Lack of time, mostly. IWYU was written before there was libtooling, and follows Google style, so we've felt it would be an odd bird in clang-tools-extra, for example. https://reviews.llvm.org/D31696 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30739: [OpenMP] "declare simd" for AArch64 Advanced SIMD.
ABataev added inline comments. Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:6818-6819 +ISAData); +} +if (CGM.getTriple().getArch() == llvm::Triple::aarch64) { + ISADataTy ISAData[] = { else if Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:6826 +ISAData); +} } Maybe it is better to create `SmallVector ISAData` and fill it for all architectures independently, but have just one call of `emitTargetDeclareSimdFunction()`? https://reviews.llvm.org/D30739 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31760: [lsan] Enable LSan on arm Linux, clang part
eugenis added inline comments. Comment at: lib/Driver/ToolChains/Linux.cpp:867 getTriple().getArch() == llvm::Triple::aarch64_be; + const bool IsArmArch = getTriple().getArch() == llvm::Triple::arm; SanitizerMask Res = ToolChain::getSupportedSanitizers(); I think we should also check for thumb. We allow asan on thumb, it would be surprising if lsan was not allowed. Repository: rL LLVM https://reviews.llvm.org/D31760 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31406: [clang-tidy] Reuse FileID in getLocation
This revision was automatically updated to reflect the committed changes. Closed by commit rL299700: [clang-tidy] Reuse FileID in getLocation (authored by chh). Repository: rL LLVM https://reviews.llvm.org/D31406 Files: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Index: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp === --- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp @@ -239,7 +239,7 @@ return SourceLocation(); const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath); -FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User); +FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User); return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset); } Index: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp === --- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp @@ -239,7 +239,7 @@ return SourceLocation(); const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath); -FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User); +FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User); return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r299700 - [clang-tidy] Reuse FileID in getLocation
Author: chh Date: Thu Apr 6 15:19:26 2017 New Revision: 299700 URL: http://llvm.org/viewvc/llvm-project?rev=299700&view=rev Log: [clang-tidy] Reuse FileID in getLocation One FileID per warning will increase and overflow NextLocalOffset when input file is large with many warnings. Reusing FileID avoids this problem. This requires changes in getColumnNumber, D31406, rL299681. Differential Revision: http://reviews.llvm.org/D31406 Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=299700&r1=299699&r2=299700&view=diff == --- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Apr 6 15:19:26 2017 @@ -239,7 +239,7 @@ private: return SourceLocation(); const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath); -FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User); +FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User); return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31736: Implement _interlockedbittestandset as a builtin
hans updated this revision to Diff 94433. hans added a comment. Add comment. https://reviews.llvm.org/D31736 Files: include/clang/Basic/Builtins.def lib/CodeGen/CGBuiltin.cpp lib/Headers/intrin.h test/CodeGen/ms-intrinsics.c Index: test/CodeGen/ms-intrinsics.c === --- test/CodeGen/ms-intrinsics.c +++ test/CodeGen/ms-intrinsics.c @@ -434,6 +434,17 @@ #endif +unsigned char test_interlockedbittestandset(volatile long *ptr, long bit) { + return _interlockedbittestandset(ptr, bit); +} +// CHECK-LABEL: define{{.*}} i8 @test_interlockedbittestandset +// CHECK: %0 = shl i32 1, %bit +// CHECK: %1 = atomicrmw or i32* %ptr, i32 %0 seq_cst +// CHECK: %2 = lshr i32 %1, %bit +// CHECK: %3 = trunc i32 %2 to i8 +// CHECK: %4 = and i8 %3, 1 +// CHECK: ret i8 %4 + void test__fastfail() { __fastfail(42); } Index: lib/Headers/intrin.h === --- lib/Headers/intrin.h +++ lib/Headers/intrin.h @@ -173,7 +173,6 @@ void __cdecl _enable(void); long _InterlockedAddLargeStatistic(__int64 volatile *_Addend, long _Value); unsigned char _interlockedbittestandreset(long volatile *, long); -static __inline__ unsigned char _interlockedbittestandset(long volatile *, long); long _InterlockedCompareExchange_HLEAcquire(long volatile *, long, long); long _InterlockedCompareExchange_HLERelease(long volatile *, long, long); @@ -369,11 +368,6 @@ *_BitBase = *_BitBase | (1 << _BitPos); return _Res; } -static __inline__ unsigned char __DEFAULT_FN_ATTRS -_interlockedbittestandset(long volatile *_BitBase, long _BitPos) { - long _PrevVal = __atomic_fetch_or(_BitBase, 1l << _BitPos, __ATOMIC_SEQ_CST); - return (_PrevVal >> _BitPos) & 1; -} #if defined(__arm__) || defined(__aarch64__) static __inline__ unsigned char __DEFAULT_FN_ATTRS _interlockedbittestandset_acq(long volatile *_BitBase, long _BitPos) { Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -492,6 +492,7 @@ _InterlockedIncrement, _InterlockedOr, _InterlockedXor, + _interlockedbittestandset, __fastfail, }; @@ -559,6 +560,22 @@ case MSVCIntrin::_InterlockedXor: return MakeBinaryAtomicValue(*this, AtomicRMWInst::Xor, E); + case MSVCIntrin::_interlockedbittestandset: { +llvm::Value *Addr = EmitScalarExpr(E->getArg(0)); +llvm::Value *Bit = EmitScalarExpr(E->getArg(1)); +AtomicRMWInst *RMWI = Builder.CreateAtomicRMW( +AtomicRMWInst::Or, Addr, +Builder.CreateShl(ConstantInt::get(Bit->getType(), 1), Bit), +llvm::AtomicOrdering::SequentiallyConsistent); +// Shift the relevant bit to the least significant position, truncate to +// the result type, and test the low bit. +llvm::Value *Shifted = Builder.CreateLShr(RMWI, Bit); +llvm::Value *Truncated = +Builder.CreateTrunc(Shifted, ConvertType(E->getType())); +return Builder.CreateAnd(Truncated, + ConstantInt::get(Truncated->getType(), 1)); + } + case MSVCIntrin::_InterlockedDecrement: { llvm::Type *IntTy = ConvertType(E->getType()); AtomicRMWInst *RMWI = Builder.CreateAtomicRMW( @@ -2238,6 +2255,9 @@ case Builtin::BI_InterlockedXor16: case Builtin::BI_InterlockedXor: return RValue::get(EmitMSVCBuiltinExpr(MSVCIntrin::_InterlockedXor, E)); + case Builtin::BI_interlockedbittestandset: +return RValue::get( +EmitMSVCBuiltinExpr(MSVCIntrin::_interlockedbittestandset, E)); case Builtin::BI__exception_code: case Builtin::BI_exception_code: @@ -2309,10 +2329,8 @@ break; } - case Builtin::BI__fastfail: { + case Builtin::BI__fastfail: return RValue::get(EmitMSVCBuiltinExpr(MSVCIntrin::__fastfail, E)); -break; - } case Builtin::BI__builtin_coro_size: { auto & Context = getContext(); Index: include/clang/Basic/Builtins.def === --- include/clang/Basic/Builtins.def +++ include/clang/Basic/Builtins.def @@ -756,6 +756,7 @@ LANGBUILTIN(_InterlockedXor8, "ccD*c", "n", ALL_MS_LANGUAGES) LANGBUILTIN(_InterlockedXor16, "ssD*s", "n", ALL_MS_LANGUAGES) LANGBUILTIN(_InterlockedXor, "LiLiD*Li","n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandset, "UcLiD*Li", "n", ALL_MS_LANGUAGES) LANGBUILTIN(__noop, "i.", "n", ALL_MS_LANGUAGES) LANGBUILTIN(__popcnt16, "UsUs", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__popcnt, "UiUi", "nc", ALL_MS_LANGUAGES) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31736: Implement _interlockedbittestandset as a builtin
hans added inline comments. Comment at: lib/CodeGen/CGBuiltin.cpp:570 +llvm::AtomicOrdering::SequentiallyConsistent); +llvm::Value *Shifted = Builder.CreateLShr(RMWI, Bit); +llvm::Value *Truncated = rnk wrote: > Can you comment that this shifts the relevant bit into the low bit, truncates > to i8, and then tests the low bit? At first I was thinking "of course, we > just do AND %old, $constant to test the bit". > > Do we successfully pattern match this idiom to `lock bts`? Is there a pattern > match we should target? Added the comment. No, we generate horrible code for this, but it's the same as we did for the inline version in intrin.h. We have BTS instructions in the .td file, but no patterns for them. I thought a bit about adding a pattern match for this, but I'm not sure it would be worth the effort. https://reviews.llvm.org/D31736 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31778: [Modules] Implement ODR-like semantics for tag types in C/ObjC
aprantl added a comment. Thanks! Added a couple of superficial coding style comments. I think there should also be a test for C99 and one for C11 (and potentially ObjC2). Comment at: include/clang/AST/ASTStructuralEquivalence.h:52 + /// \brief Whether warn or error on tag type mismatches. + bool ErrorOnTagTypeMismatch; No need to use \brief in new code any more. We are compiling with the Doxygen autobrief option. Comment at: lib/Parse/ParseDecl.cpp:4316 +!Actions.hasStructuralCompatLayout(TagDecl, CheckCompatTag.NewDef)) { + DS.SetTypeSpecError(); // Bail out... + return; I think the LLVM coding style wants this to be ``` { // Bail out. DS.SetTypeSpecError(); return; } ``` or ``` // Bail out. return DS.SetTypeSpecError(); ``` Comment at: lib/Parse/ParseDeclCXX.cpp:1913 +: TagOrTempResult.get(); + // Parse the definition body + ParseStructUnionBody(StartLoc, TagType, D); `.` Comment at: lib/Sema/SemaDecl.cpp:13386 + bool AllowODR = getLangOpts().CPlusPlus || getLangOpts().ObjC1 || + getLangOpts().C11; NamedDecl *Hidden = nullptr; Does `ObjC2` imply `ObjC1`? Comment at: lib/Sema/SemaType.cpp:7085 +/// \brief Determine if \p D abd \p Suggested have a structurally compatibale +///layout as described by C11 6.2.7/1. Comment should go on the declaration. https://reviews.llvm.org/D31778 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25866: [Sema] Support implicit scalar to vector conversions
sdardis updated this revision to Diff 94434. sdardis marked 7 inline comments as done. sdardis added a comment. Addressed review comments. I've changed InvalidVectorOperands() to not use InvalidOperands() after updating some tests. InvalidOperands() was receiving expressions with implicit casts, leading to misleading error messages. https://reviews.llvm.org/D25866 Files: include/clang/Basic/DiagnosticSemaKinds.td include/clang/Sema/Sema.h lib/Sema/SemaExpr.cpp test/Sema/vector-cast.c test/Sema/vector-gcc-compat.c test/Sema/vector-gcc-compat.cpp test/Sema/vector-ops.c test/Sema/zvector.c test/SemaCXX/vector-no-lax.cpp Index: test/SemaCXX/vector-no-lax.cpp === --- test/SemaCXX/vector-no-lax.cpp +++ test/SemaCXX/vector-no-lax.cpp @@ -4,6 +4,6 @@ vSInt32 foo (vUInt32 a) { vSInt32 b = { 0, 0, 0, 0 }; - b += a; // expected-error{{cannot convert between vector values}} + b += a; // expected-error{{cannot convert between vector type 'vUInt32' (vector of 4 'unsigned int' values) and vector type 'vSInt32' (vector of 4 'int' values) as implicit conversion would cause truncation}} return b; } Index: test/Sema/zvector.c === --- test/Sema/zvector.c +++ test/Sema/zvector.c @@ -326,14 +326,14 @@ bc = bc + sc2; // expected-error {{incompatible type}} bc = sc + bc2; // expected-error {{incompatible type}} - sc = sc + sc_scalar; // expected-error {{cannot convert}} - sc = sc + uc_scalar; // expected-error {{cannot convert}} - sc = sc_scalar + sc; // expected-error {{cannot convert}} - sc = uc_scalar + sc; // expected-error {{cannot convert}} - uc = uc + sc_scalar; // expected-error {{cannot convert}} - uc = uc + uc_scalar; // expected-error {{cannot convert}} - uc = sc_scalar + uc; // expected-error {{cannot convert}} - uc = uc_scalar + uc; // expected-error {{cannot convert}} + sc = sc + sc_scalar; + sc = sc + uc_scalar; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}} + sc = sc_scalar + sc; + sc = uc_scalar + sc; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}} + uc = uc + sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}} + uc = uc + uc_scalar; + uc = sc_scalar + uc; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}} + uc = uc_scalar + uc; ss = ss + ss2; us = us + us2; @@ -368,10 +368,10 @@ sc += sl2; // expected-error {{cannot convert}} sc += fd2; // expected-error {{cannot convert}} - sc += sc_scalar; // expected-error {{cannot convert}} - sc += uc_scalar; // expected-error {{cannot convert}} - uc += sc_scalar; // expected-error {{cannot convert}} - uc += uc_scalar; // expected-error {{cannot convert}} + sc += sc_scalar; + sc += uc_scalar; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}} + uc += sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}} + uc += uc_scalar; ss += ss2; us += us2; Index: test/Sema/vector-ops.c === --- test/Sema/vector-ops.c +++ test/Sema/vector-ops.c @@ -30,106 +30,108 @@ void testLogicalVecVec(v2u v2ua, v2s v2sa, v2f v2fa) { // Logical operators - v2ua = v2ua && v2ua; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int int' (vector of 2 'int' values)}} - v2ua = v2ua || v2ua; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int int' (vector of 2 'int' values)}} + v2ua = v2ua && v2ua; // expected-error {{invalid operands to binary expression ('v2u' (vector of 2 'unsigned int' values) and 'v2u')}} + v2ua = v2ua || v2ua; // expected-error {{invalid operands to binary expression ('v2u' (vector of 2 'unsigned int' values) and 'v2u')}} - v2ua = v2sa && v2ua; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int int' (vector of 2 'int' values)}} - v2ua = v2sa || v2ua; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attrib
[libcxx] r299711 - [CMake][libcxx] Use check_c_compiler_flag to check for nodefaultlibs
Author: phosek Date: Thu Apr 6 16:06:33 2017 New Revision: 299711 URL: http://llvm.org/viewvc/llvm-project?rev=299711&view=rev Log: [CMake][libcxx] Use check_c_compiler_flag to check for nodefaultlibs We're using -nodefaultlibs to avoid the dependency on C++ library when using check_cxx_compiler_flag, and as such we cannot use check_cxx_compiler_flag to check the availability of -nodefaultlibs itself. Modified: libcxx/trunk/cmake/config-ix.cmake Modified: libcxx/trunk/cmake/config-ix.cmake URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/config-ix.cmake?rev=299711&r1=299710&r2=299711&view=diff == --- libcxx/trunk/cmake/config-ix.cmake (original) +++ libcxx/trunk/cmake/config-ix.cmake Thu Apr 6 16:06:33 2017 @@ -1,4 +1,5 @@ include(CheckLibraryExists) +include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) if(WIN32 AND NOT MINGW) @@ -24,7 +25,7 @@ endif() # required during compilation (which has the -nodefaultlibs). libc is # required for the link to go through. We remove sanitizers from the # configuration checks to avoid spurious link errors. -check_cxx_compiler_flag(-nodefaultlibs LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) +check_c_compiler_flag(-nodefaultlibs LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) if (LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs") if (LIBCXX_HAS_C_LIB) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator
bradfier updated this revision to Diff 94438. bradfier edited the summary of this revision. bradfier added a comment. Switch to a more appropriate (and much simpler) method of identifying these Java-specific operators. Also removed any references to fictitious "logical left shifts", I think I made those up while tired... Repository: rL LLVM https://reviews.llvm.org/D31652 Files: lib/Format/FormatTokenLexer.cpp unittests/Format/FormatTestJava.cpp Index: unittests/Format/FormatTestJava.cpp === --- unittests/Format/FormatTestJava.cpp +++ unittests/Format/FormatTestJava.cpp @@ -522,5 +522,17 @@ " void f() {}")); } +TEST_F(FormatTestJava, RetainsLogicalShifts) { +verifyFormat("void f() {\n" + " int a = 1;\n" + " a >>>= 1;\n" + "}"); +verifyFormat("void f() {\n" + " int a = 1;\n" + " a = a >>> 1;\n" + "}"); +} + + } // end namespace tooling } // end namespace clang Index: lib/Format/FormatTokenLexer.cpp === --- lib/Format/FormatTokenLexer.cpp +++ lib/Format/FormatTokenLexer.cpp @@ -82,6 +82,19 @@ if (tryMergeTokens(JSRightArrow, TT_JsFatArrow)) return; } + + if (Style.Language == FormatStyle::LK_Java) { +static const tok::TokenKind JavaRightLogicalShift[] = {tok::greater, + tok::greater, + tok::greater}; +static const tok::TokenKind JavaRightLogicalShiftAssign[] = {tok::greater, + tok::greater, + tok::greaterequal}; +if (tryMergeTokens(JavaRightLogicalShift, TT_BinaryOperator)) + return; +if (tryMergeTokens(JavaRightLogicalShiftAssign, TT_BinaryOperator)) + return; + } } bool FormatTokenLexer::tryMergeLessLess() { Index: unittests/Format/FormatTestJava.cpp === --- unittests/Format/FormatTestJava.cpp +++ unittests/Format/FormatTestJava.cpp @@ -522,5 +522,17 @@ " void f() {}")); } +TEST_F(FormatTestJava, RetainsLogicalShifts) { +verifyFormat("void f() {\n" + " int a = 1;\n" + " a >>>= 1;\n" + "}"); +verifyFormat("void f() {\n" + " int a = 1;\n" + " a = a >>> 1;\n" + "}"); +} + + } // end namespace tooling } // end namespace clang Index: lib/Format/FormatTokenLexer.cpp === --- lib/Format/FormatTokenLexer.cpp +++ lib/Format/FormatTokenLexer.cpp @@ -82,6 +82,19 @@ if (tryMergeTokens(JSRightArrow, TT_JsFatArrow)) return; } + + if (Style.Language == FormatStyle::LK_Java) { +static const tok::TokenKind JavaRightLogicalShift[] = {tok::greater, + tok::greater, + tok::greater}; +static const tok::TokenKind JavaRightLogicalShiftAssign[] = {tok::greater, + tok::greater, + tok::greaterequal}; +if (tryMergeTokens(JavaRightLogicalShift, TT_BinaryOperator)) + return; +if (tryMergeTokens(JavaRightLogicalShiftAssign, TT_BinaryOperator)) + return; + } } bool FormatTokenLexer::tryMergeLessLess() { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator
bradfier added a comment. Thanks for that @thakis, that's a much better solution than the first attempt! Repository: rL LLVM https://reviews.llvm.org/D31652 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31736: Implement _interlockedbittestandset as a builtin
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. lgtm Comment at: lib/CodeGen/CGBuiltin.cpp:570 +llvm::AtomicOrdering::SequentiallyConsistent); +llvm::Value *Shifted = Builder.CreateLShr(RMWI, Bit); +llvm::Value *Truncated = hans wrote: > rnk wrote: > > Can you comment that this shifts the relevant bit into the low bit, > > truncates to i8, and then tests the low bit? At first I was thinking "of > > course, we just do AND %old, $constant to test the bit". > > > > Do we successfully pattern match this idiom to `lock bts`? Is there a > > pattern match we should target? > Added the comment. > > No, we generate horrible code for this, but it's the same as we did for the > inline version in intrin.h. We have BTS instructions in the .td file, but no > patterns for them. > > I thought a bit about adding a pattern match for this, but I'm not sure it > would be worth the effort. Let's file a bug for it and call it a day. https://reviews.llvm.org/D31736 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31673: Allow casting C pointers declared using extern "C" to ObjC pointer types
ahatanak added inline comments. Comment at: lib/Sema/SemaExprObjC.cpp:3358 var && - var->getStorageClass() == SC_Extern && + !var->isThisDeclarationADefinition() && var->getType().isConstQualified()) { rjmccall wrote: > Hmm. Come to think of it, I wonder if we actually care whether the variable > has a definition, given that it's const. > > Well, we can consider that later. I agree that this change is good. If we don't care whether the variable is a definition, it's possible to check whether the variable declaration is directly contained in a language linkage instead (using a function like isSingleLineLanguageLinkage in lib/AST/Decl.cpp). Comment at: test/SemaObjCXX/arc-bridged-cast.mm:59 +extern "C" const CFAnnotatedObjectRef r2; +extern "C" const CFAnnotatedObjectRef r3 = 0; + rjmccall wrote: > These examples are a little unfortunate because these values are known to be > null pointers. Changed the initializer to be the address of a __CFAnnotatedObject variable. https://reviews.llvm.org/D31673 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31673: Allow casting C pointers declared using extern "C" to ObjC pointer types
ahatanak updated this revision to Diff 94460. ahatanak marked an inline comment as done. https://reviews.llvm.org/D31673 Files: lib/Sema/SemaExprObjC.cpp test/SemaObjCXX/arc-bridged-cast.mm Index: test/SemaObjCXX/arc-bridged-cast.mm === --- test/SemaObjCXX/arc-bridged-cast.mm +++ test/SemaObjCXX/arc-bridged-cast.mm @@ -52,3 +52,19 @@ ref = (__bridge_retained CFAnnotatedObjectRef) CreateSomething(); ref = (__bridge_retained CFAnnotatedObjectRef) CreateNSString(); } + +struct __CFAnnotatedObject { +} cf0; + +extern const CFAnnotatedObjectRef r0; +extern const CFAnnotatedObjectRef r1 = &cf0; +extern "C" const CFAnnotatedObjectRef r2; +extern "C" const CFAnnotatedObjectRef r3 = &cf0; + +void testExternC() { + id obj; + obj = (id)r0; + obj = (id)r1; // expected-error{{cast of C pointer type 'CFAnnotatedObjectRef' (aka 'const __CFAnnotatedObject *') to Objective-C pointer type 'id' requires a bridged cast}} expected-note{{use __bridge to convert directly}} expected-note{{use __bridge_transfer to transfer ownership of a +1 'CFAnnotatedObjectRef'}} + obj = (id)r2; + obj = (id)r3; // expected-error{{cast of C pointer type 'CFAnnotatedObjectRef' (aka 'const __CFAnnotatedObject *') to Objective-C pointer type 'id' requires a bridged cast}} expected-note{{use __bridge to convert directly}} expected-note{{use __bridge_transfer to transfer ownership of a +1 'CFAnnotatedObjectRef'}} +} Index: lib/Sema/SemaExprObjC.cpp === --- lib/Sema/SemaExprObjC.cpp +++ lib/Sema/SemaExprObjC.cpp @@ -3355,7 +3355,7 @@ if (isAnyRetainable(TargetClass) && isAnyRetainable(SourceClass) && var && - var->getStorageClass() == SC_Extern && + !var->isThisDeclarationADefinition() && var->getType().isConstQualified()) { // In system headers, they can also be assumed to be immune to retains. Index: test/SemaObjCXX/arc-bridged-cast.mm === --- test/SemaObjCXX/arc-bridged-cast.mm +++ test/SemaObjCXX/arc-bridged-cast.mm @@ -52,3 +52,19 @@ ref = (__bridge_retained CFAnnotatedObjectRef) CreateSomething(); ref = (__bridge_retained CFAnnotatedObjectRef) CreateNSString(); } + +struct __CFAnnotatedObject { +} cf0; + +extern const CFAnnotatedObjectRef r0; +extern const CFAnnotatedObjectRef r1 = &cf0; +extern "C" const CFAnnotatedObjectRef r2; +extern "C" const CFAnnotatedObjectRef r3 = &cf0; + +void testExternC() { + id obj; + obj = (id)r0; + obj = (id)r1; // expected-error{{cast of C pointer type 'CFAnnotatedObjectRef' (aka 'const __CFAnnotatedObject *') to Objective-C pointer type 'id' requires a bridged cast}} expected-note{{use __bridge to convert directly}} expected-note{{use __bridge_transfer to transfer ownership of a +1 'CFAnnotatedObjectRef'}} + obj = (id)r2; + obj = (id)r3; // expected-error{{cast of C pointer type 'CFAnnotatedObjectRef' (aka 'const __CFAnnotatedObject *') to Objective-C pointer type 'id' requires a bridged cast}} expected-note{{use __bridge to convert directly}} expected-note{{use __bridge_transfer to transfer ownership of a +1 'CFAnnotatedObjectRef'}} +} Index: lib/Sema/SemaExprObjC.cpp === --- lib/Sema/SemaExprObjC.cpp +++ lib/Sema/SemaExprObjC.cpp @@ -3355,7 +3355,7 @@ if (isAnyRetainable(TargetClass) && isAnyRetainable(SourceClass) && var && - var->getStorageClass() == SC_Extern && + !var->isThisDeclarationADefinition() && var->getType().isConstQualified()) { // In system headers, they can also be assumed to be immune to retains. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31702: Append -w when LLVM_ENABLE_WARNINGS is Off.
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. lgtm https://reviews.llvm.org/D31702 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits