Re: r246985 - Compute and preserve alignment more faithfully in IR-generation.
> On Sep 27, 2015, at 5:56 PM, Joerg Sonnenberger > wrote: > On Tue, Sep 08, 2015 at 08:06:00AM -, John McCall via cfe-commits wrote: >> Author: rjmccall >> Date: Tue Sep 8 03:05:57 2015 >> New Revision: 246985 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=246985&view=rev >> Log: >> Compute and preserve alignment more faithfully in IR-generation. > > This seems to introduce an access-beyond-end on the attached input. Just > -c should be enough to reproduce. I’ll take a look. John. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13190: Addition of interfaces the FE to conform to Table A-2 of ELF V2 ABI V1.1
nemanjai updated this revision to Diff 35838. nemanjai added a comment. I forgot the test cases in the original upload. This patch contains the test cases and is ready for review. Repository: rL LLVM http://reviews.llvm.org/D13190 Files: include/clang/Basic/BuiltinsPPC.def lib/Headers/altivec.h test/CodeGen/builtins-ppc-altivec.c test/CodeGen/builtins-ppc-crypto.c test/CodeGen/builtins-ppc-p8vector.c Index: test/CodeGen/builtins-ppc-p8vector.c === --- test/CodeGen/builtins-ppc-p8vector.c +++ test/CodeGen/builtins-ppc-p8vector.c @@ -7,6 +7,13 @@ // (vec_cmpge, vec_cmple). Without this option, there is only one overload so // it is selected. +void dummy() { } +signed int si; +signed long long sll; +unsigned long long ull; +signed __int128 sx; +unsigned __int128 ux; +double d; vector signed char vsc = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 }; vector unsigned char vuc = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 }; vector bool char vbc = { 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1 }; @@ -23,10 +30,17 @@ vector unsigned long long vull = { 1, 2 }; vector bool long long vbll = { 1, 0 }; +vector signed __int128 vsx = { 1 }; +vector unsigned __int128 vux = { 1 }; + vector float vfa = { 1.e-4f, -132.23f, -22.1, 32.00f }; vector double vda = { 1.e-11, -132.23e10 }; int res_i; +double res_d; +signed long long res_sll; +unsigned long long res_ull; + vector signed char res_vsc; vector unsigned char res_vuc; vector bool char res_vbc; @@ -43,7 +57,10 @@ vector unsigned long long res_vull; vector bool long long res_vbll; -vector double res_vf; +vector signed __int128 res_vsx; +vector unsigned __int128 res_vux; + +vector float res_vf; vector double res_vd; // CHECK-LABEL: define void @test1 @@ -73,6 +90,37 @@ // CHECK-LE: add <2 x i64> // CHECK-PPC: error: call to 'vec_add' is ambiguous + /* vec_addc */ + res_vsi = vec_addc(vsi, vsi); +// CHECK: @llvm.ppc.altivec.vaddcuw +// CHECK-LE: @llvm.ppc.altivec.vaddcuw + + res_vui = vec_addc(vui, vui); +// CHECK: @llvm.ppc.altivec.vaddcuw +// CHECK-LE: @llvm.ppc.altivec.vaddcuw + + res_vsx = vec_addc(vsx, vsx); +// CHECK: @llvm.ppc.altivec.vaddcuq +// CHECK-LE: @llvm.ppc.altivec.vaddcuq + + res_vux = vec_addc(vux, vux); +// CHECK: @llvm.ppc.altivec.vaddcuq +// CHECK-LE: @llvm.ppc.altivec.vaddcuq + + /* vec_adde */ + res_vsx = vec_adde(vsx, vsx, vsx); +// CHECK: @llvm.ppc.altivec.vaddeuqm +// CHECK-LE: @llvm.ppc.altivec.vaddeuqm + + res_vux = vec_adde(vux, vux, vux); +// CHECK: @llvm.ppc.altivec.vaddeuqm +// CHECK-LE: @llvm.ppc.altivec.vaddeuqm + + /* vec_addec */ + res_vsx = vec_addec(vsx, vsx, vsx); +// CHECK: @llvm.ppc.altivec.vaddecuq +// CHECK-LE: @llvm.ppc.altivec.vaddecuq + /* vec_mergee */ res_vbi = vec_mergee(vbi, vbi); // CHECK: @llvm.ppc.altivec.vperm @@ -156,6 +204,15 @@ // CHECK-LE: call <2 x i64> @llvm.ppc.altivec.vcmpgtud(<2 x i64> %{{[0-9]*}}, <2 x i64> %{{[0-9]*}}) // CHECK-PPC: error: call to 'vec_cmplt' is ambiguous + /* vec_double */ + res_vd = vec_double(vsll); +// CHECK: sitofp i64 {{.+}} to double +// CHECK-BE: sitofp i64 {{.+}} to double + + res_vd = vec_double(vull); +// CHECK: uitofp i64 {{.+}} to double +// CHECK-BE: uitofp i64 {{.+}} to double + /* vec_eqv */ res_vsc = vec_eqv(vsc, vsc); // CHECK: [[T1:%.+]] = bitcast <16 x i8> {{.+}} to <4 x i32> @@ -168,18 +225,7 @@ // CHECK-LE: bitcast <4 x i32> [[T3]] to <16 x i8> // CHECK-PPC: error: assigning to - res_vsc = vec_eqv(vbc, vsc); -// CHECK: [[T1:%.+]] = bitcast <16 x i8> {{.+}} to <4 x i32> -// CHECK: [[T2:%.+]] = bitcast <16 x i8> {{.+}} to <4 x i32> -// CHECK: [[T3:%.+]] = call <4 x i32> @llvm.ppc.vsx.xxleqv(<4 x i32> [[T1]], <4 x i32> [[T2]]) -// CHECK: bitcast <4 x i32> [[T3]] to <16 x i8> -// CHECK-LE: [[T1:%.+]] = bitcast <16 x i8> {{.+}} to <4 x i32> -// CHECK-LE: [[T2:%.+]] = bitcast <16 x i8> {{.+}} to <4 x i32> -// CHECK-LE: [[T3:%.+]] = call <4 x i32> @llvm.ppc.vsx.xxleqv(<4 x i32> [[T1]], <4 x i32> [[T2]]) -// CHECK-LE: bitcast <4 x i32> [[T3]] to <16 x i8> -// CHECK-PPC: error: assigning to - - res_vsc = vec_eqv(vsc, vbc); + res_vsc = vec_eqv(vbc, vbc); // CHECK: [[T1:%.+]] = bitcast <16 x i8> {{.+}} to <4 x i32> // CHECK: [[T2:%.+]] = bitcast <16 x i8> {{.+}} to <4 x i32> // CHECK: [[T3:%.+]] = call <4 x i32> @llvm.ppc.vsx.xxleqv(<4 x i32> [[T1]], <4 x i32> [[T2]]) @@ -201,28 +247,6 @@ // CHECK-LE: bitcast <4 x i32> [[T3]] to <16 x i8> // CHECK-PPC: error: assigning to - res_vuc = vec_eqv(vbc, vuc); -// CHECK: [[T1:%.+]] = bitcast <16 x i8> {{.+}} to <4 x i32> -// CHECK: [[T2:%.+]] = bitcast <16 x i8> {{.+}} to <4 x i32> -// CHECK: [[T3:%.+]] = call <4 x i32> @llvm.ppc.vsx.xxleqv(<4 x i32> [[T1]], <4 x i32> [[T2]]) -// CHECK: bitcast <4 x i32> [[T3]] to <16 x i8> -// CHECK-LE: [[T1:%.+]] = bitcast <16 x i8> {{.+}} to <4 x i32> -// CHECK-LE: [[T2:%.+]] = bitcast <16 x i8> {{.+}} to <4 x i32> -// CHECK-LE: [
[PATCH] D13203: [Clang] - Massaging code to fix MSVS 2015 win32-release configuration
grimar created this revision. grimar added reviewers: rsmith, echristo. grimar added subscribers: cfe-commits, grimar. Microsoft Visual Studio Community 2015 Version 14.0.23107.0 D14REL When building in release mode, MSVS failed with: 57>c:\access_softek\llvm\tools\clang\lib\ast\astcontext.cpp(334): fatal error C1001: An internal error has occurred in the compiler. 57> (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 246) 57> To work around this problem, try simplifying or changing the program near the locations listed above. I little code simplification helped to workaround this. http://reviews.llvm.org/D13203 Files: ASTContext.cpp Index: ASTContext.cpp === --- ASTContext.cpp +++ ASTContext.cpp @@ -364,14 +364,14 @@ } else { RC = getRawCommentForDeclNoCache(I); OriginalDeclForRC = I; - RawCommentAndCacheFlags Raw; + RedeclComments[I] = RawCommentAndCacheFlags(); + RawCommentAndCacheFlags &Raw = RedeclComments[I]; if (RC) { Raw.setRaw(RC); Raw.setKind(RawCommentAndCacheFlags::FromDecl); } else Raw.setKind(RawCommentAndCacheFlags::NoCommentInDecl); Raw.setOriginalDecl(I); - RedeclComments[I] = Raw; if (RC) break; } Index: ASTContext.cpp === --- ASTContext.cpp +++ ASTContext.cpp @@ -364,14 +364,14 @@ } else { RC = getRawCommentForDeclNoCache(I); OriginalDeclForRC = I; - RawCommentAndCacheFlags Raw; + RedeclComments[I] = RawCommentAndCacheFlags(); + RawCommentAndCacheFlags &Raw = RedeclComments[I]; if (RC) { Raw.setRaw(RC); Raw.setKind(RawCommentAndCacheFlags::FromDecl); } else Raw.setKind(RawCommentAndCacheFlags::NoCommentInDecl); Raw.setOriginalDecl(I); - RedeclComments[I] = Raw; if (RC) break; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13166: Create modernize-make-unique check.
angelgarcia added inline comments. Comment at: clang-tidy/modernize/MakeUniqueCheck.cpp:25-27 @@ +24,5 @@ + +/// \brief Returns the length of the token that goes since the beggining of the +/// constructor call until the '<' of the template. This token should either be +/// 'unique_ptr' or 'std::unique_ptr'. In any other case, it returns 0. +static int getTokenLength(SourceLocation TokenStart, const SourceManager &SM, klimek wrote: > How can that ever return 0 if you have matchesName("::std::unique_ptr") below? Maybe using macros or something like that. As I said, it needs to be more carefully tested. http://reviews.llvm.org/D13166 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13166: Create modernize-make-unique check.
angelgarcia updated this revision to Diff 35839. angelgarcia marked an inline comment as done. angelgarcia added a comment. Remove 'hasCanonicalType'. http://reviews.llvm.org/D13166 Files: clang-tidy/modernize/CMakeLists.txt clang-tidy/modernize/MakeUniqueCheck.cpp clang-tidy/modernize/MakeUniqueCheck.h clang-tidy/modernize/ModernizeTidyModule.cpp test/clang-tidy/modernize-make-unique.cpp Index: test/clang-tidy/modernize-make-unique.cpp === --- /dev/null +++ test/clang-tidy/modernize-make-unique.cpp @@ -0,0 +1,92 @@ +// RUN: %python %S/check_clang_tidy.py %s modernize-make-unique %t + +namespace std { + +template +class unique_ptr { +public: + unique_ptr(type *ptr); + unique_ptr(const unique_ptr &t) = delete; + unique_ptr(unique_ptr &&t); + ~unique_ptr(); + type &operator*() { return *ptr; } + type *operator->() { return ptr; } + type *release(); + void reset(); + void reset(type *pt); + +private: + type *ptr; +}; + +} + +struct Base { + Base(); + Base(int, int); +}; + +struct Derived : public Base { + Derived(); + Derived(int, int); +}; + +struct Pair { + int a, b; +}; + +int g(std::unique_ptr P); + +std::unique_ptr getPointer() { + return std::unique_ptr(new Base); + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use std::make_unique instead + // CHECK-FIXES: return std::make_unique(); +} + +void f() { + std::unique_ptr P1 = std::unique_ptr(new int()); + // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique] + // CHECK-FIXES: std::unique_ptr P1 = std::make_unique(); + + // Without parenthesis + std::unique_ptr P2 = std::unique_ptr(new int); + // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique] + // CHECK-FIXES: std::unique_ptr P2 = std::make_unique(); + + // With auto. + auto P3 = std::unique_ptr(new int()); + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead + // CHECK-FIXES: auto P3 = std::make_unique(); + + { +// No std. +using namespace std; +unique_ptr Q = unique_ptr(new int()); +// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use std::make_unique instead +// CHECK-FIXES: unique_ptr Q = std::make_unique(); + } + + std::unique_ptr R(new int()); + + // Create the unique_ptr as a parameter to a function. + int T = g(std::unique_ptr(new int())); + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead + // CHECK-FIXES: int T = g(std::make_unique()); + + // Arguments are correctly handled. + std::unique_ptr Pbase = std::unique_ptr(new Base(5, T)); + // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: use std::make_unique instead + // CHECK-FIXES: std::unique_ptr Pbase = std::make_unique(5, T); + + // Works with init lists. + std::unique_ptr Ppair = std::unique_ptr(new Pair{T, 1}); + // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: use std::make_unique instead + // CHECK-FIXES: std::unique_ptr Ppair = std::make_unique({T, 1}); + + // Only replace if the type in the template is the same than the type returned + // by the new operator. + auto Pderived = std::unique_ptr(new Derived()); + + // The pointer is returned by the function, nothing to do. + std::unique_ptr RetPtr = getPointer(); +} Index: clang-tidy/modernize/ModernizeTidyModule.cpp === --- clang-tidy/modernize/ModernizeTidyModule.cpp +++ clang-tidy/modernize/ModernizeTidyModule.cpp @@ -11,6 +11,7 @@ #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" #include "LoopConvertCheck.h" +#include "MakeUniqueCheck.h" #include "PassByValueCheck.h" #include "ReplaceAutoPtrCheck.h" #include "ShrinkToFitCheck.h" @@ -28,6 +29,8 @@ public: void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { CheckFactories.registerCheck("modernize-loop-convert"); +CheckFactories.registerCheck( +"modernize-make-unique"); CheckFactories.registerCheck("modernize-pass-by-value"); CheckFactories.registerCheck( "modernize-replace-auto-ptr"); Index: clang-tidy/modernize/MakeUniqueCheck.h === --- /dev/null +++ clang-tidy/modernize/MakeUniqueCheck.h @@ -0,0 +1,41 @@ +//===--- MakeUniqueCheck.h - clang-tidy--*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_MAKE_UNIQUE_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_MAKE_UNIQUE_H + +#include "../ClangTidy.h" + +namespace clang { +namespace tidy { +namespace modernize { + +/// Replace the pattern: +/// \code +/// std::unique_ptr(new type(args...)) +///
Re: [PATCH] D13166: Create modernize-make-unique check.
klimek added inline comments. Comment at: clang-tidy/modernize/MakeUniqueCheck.cpp:26-28 @@ +25,5 @@ +/// \brief Returns the length of the token that goes since the beggining of the +/// constructor call until the '<' of the template. This token should either be +/// 'unique_ptr' or 'std::unique_ptr'. In any other case, it returns 0. +static int getTokenLength(SourceLocation TokenStart, const SourceManager &SM, + const LangOptions &LO) { That should not be possible for the spelling location. Generally, I'd avoid writing code that doesn't fix a breaking test. http://reviews.llvm.org/D13166 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13128: Fix backend crash on multiple close of stdout.
ABataev added a comment. The bad thing is that the same problem can be reproduced not only in frontend, but also in opt tool. The test I wrote (test/Other/empty.ll) also failed with the same message. And Yaron is right, I need to mix several outputs in stdout. What should I do in this case? http://reviews.llvm.org/D13128 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r248699 - [clang-tidy] Removed a stray empty line in the docs.
Author: alexfh Date: Mon Sep 28 03:52:55 2015 New Revision: 248699 URL: http://llvm.org/viewvc/llvm-project?rev=248699&view=rev Log: [clang-tidy] Removed a stray empty line in the docs. Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-explicit-make-pair.rst Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-explicit-make-pair.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-explicit-make-pair.rst?rev=248699&r1=248698&r2=248699&view=diff == --- clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-explicit-make-pair.rst (original) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-build-explicit-make-pair.rst Mon Sep 28 03:52:55 2015 @@ -1,7 +1,6 @@ google-build-explicit-make-pair === - Check that ``make_pair``'s template arguments are deduced. G++ 4.6 in C++11 mode fails badly if ``make_pair``'s template arguments are ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13166: Create modernize-make-unique check.
angelgarcia updated this revision to Diff 35841. angelgarcia added a comment. Two tests in which 'getTokenLength' returns 0. http://reviews.llvm.org/D13166 Files: clang-tidy/modernize/CMakeLists.txt clang-tidy/modernize/MakeUniqueCheck.cpp clang-tidy/modernize/MakeUniqueCheck.h clang-tidy/modernize/ModernizeTidyModule.cpp test/clang-tidy/modernize-make-unique.cpp Index: test/clang-tidy/modernize-make-unique.cpp === --- /dev/null +++ test/clang-tidy/modernize-make-unique.cpp @@ -0,0 +1,99 @@ +// RUN: %python %S/check_clang_tidy.py %s modernize-make-unique %t + +namespace std { + +template +class unique_ptr { +public: + unique_ptr(type *ptr); + unique_ptr(const unique_ptr &t) = delete; + unique_ptr(unique_ptr &&t); + ~unique_ptr(); + type &operator*() { return *ptr; } + type *operator->() { return ptr; } + type *release(); + void reset(); + void reset(type *pt); + +private: + type *ptr; +}; + +} + +struct Base { + Base(); + Base(int, int); +}; + +struct Derived : public Base { + Derived(); + Derived(int, int); +}; + +struct Pair { + int a, b; +}; + +int g(std::unique_ptr P); + +std::unique_ptr getPointer() { + return std::unique_ptr(new Base); + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use std::make_unique instead + // CHECK-FIXES: return std::make_unique(); +} + +void f() { + std::unique_ptr P1 = std::unique_ptr(new int()); + // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique] + // CHECK-FIXES: std::unique_ptr P1 = std::make_unique(); + + // Without parenthesis. + std::unique_ptr P2 = std::unique_ptr(new int); + // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique] + // CHECK-FIXES: std::unique_ptr P2 = std::make_unique(); + + // With auto. + auto P3 = std::unique_ptr(new int()); + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead + // CHECK-FIXES: auto P3 = std::make_unique(); + + { +// No std. +using namespace std; +unique_ptr Q = unique_ptr(new int()); +// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use std::make_unique instead +// CHECK-FIXES: unique_ptr Q = std::make_unique(); + } + + std::unique_ptr R(new int()); + + // Create the unique_ptr as a parameter to a function. + int T = g(std::unique_ptr(new int())); + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead + // CHECK-FIXES: int T = g(std::make_unique()); + + // Arguments are correctly handled. + std::unique_ptr Pbase = std::unique_ptr(new Base(5, T)); + // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: use std::make_unique instead + // CHECK-FIXES: std::unique_ptr Pbase = std::make_unique(5, T); + + // Works with init lists. + std::unique_ptr Ppair = std::unique_ptr(new Pair{T, 1}); + // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: use std::make_unique instead + // CHECK-FIXES: std::unique_ptr Ppair = std::make_unique({T, 1}); + + // Only replace if the type in the template is the same than the type returned + // by the new operator. + auto Pderived = std::unique_ptr(new Derived()); + + // The pointer is returned by the function, nothing to do. + std::unique_ptr RetPtr = getPointer(); + + typedef std::unique_ptr IntPtr; + IntPtr Ipt = IntPtr(new int); + +#define PTR unique_ptr + std::unique_ptr Macro = std::PTR(new int); +#undef PTR +} Index: clang-tidy/modernize/ModernizeTidyModule.cpp === --- clang-tidy/modernize/ModernizeTidyModule.cpp +++ clang-tidy/modernize/ModernizeTidyModule.cpp @@ -11,6 +11,7 @@ #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" #include "LoopConvertCheck.h" +#include "MakeUniqueCheck.h" #include "PassByValueCheck.h" #include "ReplaceAutoPtrCheck.h" #include "ShrinkToFitCheck.h" @@ -28,6 +29,8 @@ public: void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { CheckFactories.registerCheck("modernize-loop-convert"); +CheckFactories.registerCheck( +"modernize-make-unique"); CheckFactories.registerCheck("modernize-pass-by-value"); CheckFactories.registerCheck( "modernize-replace-auto-ptr"); Index: clang-tidy/modernize/MakeUniqueCheck.h === --- /dev/null +++ clang-tidy/modernize/MakeUniqueCheck.h @@ -0,0 +1,41 @@ +//===--- MakeUniqueCheck.h - clang-tidy--*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_MAKE_UNIQUE_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_MAKE_UNIQUE_H + +#include "../ClangTidy.h" + +namespace clang
[clang-tools-extra] r248700 - [clang-tidy] Code factorization and cleanup in IdentifierNamingCheck
Author: alexfh Date: Mon Sep 28 03:59:12 2015 New Revision: 248700 URL: http://llvm.org/viewvc/llvm-project?rev=248700&view=rev Log: [clang-tidy] Code factorization and cleanup in IdentifierNamingCheck This is to level the ground a little bit, in preparation for the changes in http://reviews.llvm.org/D13081. Code factorization replaces all insertions to NamingCheckFailures map with a unique addUsage function that does the job. There is also no more difference between the declaration and the references to a given identifier, both cases are treated as ranges in the Usage vector. There is also a check to avoid duplicated ranges to be inserted, which sometimes triggered erroneous replacements. References can now also be added before the declaration of the identifier is actually found; this looks to be the case for example when a templated class uses its parameters to specialize its templated base class. Patch by Beren Minor! Differential revision: http://reviews.llvm.org/D13079 Modified: clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.h clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp Modified: clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp?rev=248700&r1=248699&r2=248700&view=diff == --- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp Mon Sep 28 03:59:12 2015 @@ -21,6 +21,7 @@ namespace clang { namespace tidy { namespace readability { +// clang-format off #define NAMING_KEYS(m) \ m(Namespace) \ m(InlineNamespace) \ @@ -80,6 +81,7 @@ static StringRef const StyleNames[] = { }; #undef NAMING_KEYS +// clang-format on IdentifierNamingCheck::IdentifierNamingCheck(StringRef Name, ClangTidyContext *Context) @@ -134,10 +136,10 @@ void IdentifierNamingCheck::storeOptions } void IdentifierNamingCheck::registerMatchers(MatchFinder *Finder) { -// FIXME: For now, only Decl and DeclRefExpr nodes are visited for checking and -// replacement. There is a lot of missing cases, such as references to a class -// name (as in 'const int CMyClass::kClassConstant = 4;'), to an enclosing -// context (namespace, class, etc). + // FIXME: For now, only Decl and DeclRefExpr nodes are visited for checking + // and replacement. There is a lot of missing cases, such as references to a + // class name (as in 'const int CMyClass::kClassConstant = 4;'), to an + // enclosing context (namespace, class, etc). Finder->addMatcher(namedDecl().bind("decl"), this); Finder->addMatcher(declRefExpr().bind("declref"), this); @@ -499,23 +501,24 @@ static StyleKind findStyleKind( return SK_Invalid; } +static void addUsage(IdentifierNamingCheck::NamingCheckFailureMap &Failures, + const NamedDecl *Decl, SourceRange Range, + const SourceManager *SM) { + auto &Failure = Failures[Decl]; + if (!Failure.RawUsageLocs.insert(Range.getBegin().getRawEncoding()).second) +return; + + Failure.ShouldFix = Failure.ShouldFix && SM->isInMainFile(Range.getBegin()) && + SM->isInMainFile(Range.getEnd()) && + !Range.getBegin().isMacroID() && + !Range.getEnd().isMacroID(); +} + void IdentifierNamingCheck::check(const MatchFinder::MatchResult &Result) { if (const auto *DeclRef = Result.Nodes.getNodeAs("declref")) { -auto It = NamingCheckFailures.find(DeclRef->getDecl()); -if (It == NamingCheckFailures.end()) - return; - -NamingCheckFailure &Failure = It->second; SourceRange Range = DeclRef->getNameInfo().getSourceRange(); - -Failure.Usages.push_back(Range); -Failure.ShouldFix = Failure.ShouldFix && -Result.SourceManager->isInMainFile(Range.getBegin()) && -Result.SourceManager->isInMainFile(Range.getEnd()) && -!Range.getBegin().isMacroID() && -!Range.getEnd().isMacroID(); - -return; +return addUsage(NamingCheckFailures, DeclRef->getDecl(), Range, +Result.SourceManager); } if (const auto *Decl = Result.Nodes.getNodeAs("decl")) { @@ -550,11 +553,7 @@ void IdentifierNamingCheck::check(const Failure.Fixup = std::move(Fixup); Failure.KindName = std::move(KindName); - Failure.ShouldFix = - Failure.ShouldFix && - Result.SourceManager->isInMainFile(Range.getBegin()) && - Result.SourceManager->isInMainFile(Range.getEnd()) && - !Range.getBegin().isMacroID() && !Range.getEnd().isMacroID(); + addUsage(Nam
Re: [PATCH] D13079: [clang-tidy] Code factorization and cleanup in IdentifierNamingCheck
This revision was automatically updated to reflect the committed changes. Closed by commit rL248700: [clang-tidy] Code factorization and cleanup in IdentifierNamingCheck (authored by alexfh). Changed prior to commit: http://reviews.llvm.org/D13079?vs=35818&id=35842#toc Repository: rL LLVM http://reviews.llvm.org/D13079 Files: clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.h clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp Index: clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp === --- clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp +++ clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp @@ -68,6 +68,8 @@ // FIXME: name, declaration contexts, forward declarations, etc, are correctly // FIXME: checked and renamed +// clang-format off + namespace FOO_NS { // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: invalid case style for namespace 'FOO_NS' [readability-identifier-naming] // CHECK-FIXES: {{^}}namespace foo_ns {{{$}} Index: clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.h === --- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.h +++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.h @@ -62,20 +62,32 @@ } }; -private: - std::vector NamingStyles; - bool IgnoreFailedSplit; - + /// \brief Holds an identifier name check failure, tracking the kind of the + /// identifer, its possible fixup and the starting locations of all the + /// idenfiier usages. struct NamingCheckFailure { std::string KindName; std::string Fixup; + +/// \brief Whether the failure should be fixed or not. +/// +/// ie: if the identifier was used or declared within a macro we won't offer +/// a fixup for safety reasons. bool ShouldFix; -std::vector Usages; + +/// \brief A set of all the identifier usages starting SourceLocation, in +/// their encoded form. +llvm::DenseSet RawUsageLocs; NamingCheckFailure() : ShouldFix(true) {} }; + typedef llvm::DenseMap + NamingCheckFailureMap; - llvm::DenseMap NamingCheckFailures; +private: + std::vector NamingStyles; + bool IgnoreFailedSplit; + NamingCheckFailureMap NamingCheckFailures; }; } // namespace readability Index: clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -21,6 +21,7 @@ namespace tidy { namespace readability { +// clang-format off #define NAMING_KEYS(m) \ m(Namespace) \ m(InlineNamespace) \ @@ -80,6 +81,7 @@ }; #undef NAMING_KEYS +// clang-format on IdentifierNamingCheck::IdentifierNamingCheck(StringRef Name, ClangTidyContext *Context) @@ -134,10 +136,10 @@ } void IdentifierNamingCheck::registerMatchers(MatchFinder *Finder) { -// FIXME: For now, only Decl and DeclRefExpr nodes are visited for checking and -// replacement. There is a lot of missing cases, such as references to a class -// name (as in 'const int CMyClass::kClassConstant = 4;'), to an enclosing -// context (namespace, class, etc). + // FIXME: For now, only Decl and DeclRefExpr nodes are visited for checking + // and replacement. There is a lot of missing cases, such as references to a + // class name (as in 'const int CMyClass::kClassConstant = 4;'), to an + // enclosing context (namespace, class, etc). Finder->addMatcher(namedDecl().bind("decl"), this); Finder->addMatcher(declRefExpr().bind("declref"), this); @@ -499,23 +501,24 @@ return SK_Invalid; } +static void addUsage(IdentifierNamingCheck::NamingCheckFailureMap &Failures, + const NamedDecl *Decl, SourceRange Range, + const SourceManager *SM) { + auto &Failure = Failures[Decl]; + if (!Failure.RawUsageLocs.insert(Range.getBegin().getRawEncoding()).second) +return; + + Failure.ShouldFix = Failure.ShouldFix && SM->isInMainFile(Range.getBegin()) && + SM->isInMainFile(Range.getEnd()) && + !Range.getBegin().isMacroID() && + !Range.getEnd().isMacroID(); +} + void IdentifierNamingCheck::check(const MatchFinder::MatchResult &Result) { if (const auto *DeclRef = Result.Nodes.getNodeAs("declref")) { -auto It = NamingCheckFailures.find(DeclRef->getDecl()); -if (It == NamingCheckFailures.end()) - return; - -NamingCheckFailure &Failure = It->second; SourceRange Range = DeclRef->getNameInfo().getSourceRange(); - -Failure.Usages.push_b
Re: [PATCH] D13079: [clang-tidy] Code factorization and cleanup in IdentifierNamingCheck
alexfh added inline comments. Comment at: clang-tidy/readability/IdentifierNamingCheck.cpp:577-578 @@ -578,3 +576,4 @@ Diag << FixItHint::CreateReplacement( -CharSourceRange::getTokenRange(Range), Failure.Fixup); +SourceRange(SourceLocation::getFromRawEncoding(Loc)), +Failure.Fixup); } I'd like the comment to cover destructors, operator names and other cases where the actual name consists of multiple tokens (which are probably filtered out somewhere, as we don't need to fix naming for these). Fine for a follow-up. Repository: rL LLVM http://reviews.llvm.org/D13079 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13166: Create modernize-make-unique check.
klimek added a comment. In http://reviews.llvm.org/D13166#254520, @angelgarcia wrote: > Two tests in which 'getTokenLength' returns 0. Thanks for the tests - question is: I would have expected us to use something like Lexer::getSourceText, which should give us the full range in the first test (do we not want to replace it?) and tell us that we don't have the type in one consecutive range in the second case. http://reviews.llvm.org/D13166 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13054: [libc++] Un-guarded reference to uncaught_exception() in ostream header
rmaprath added a comment. Gentle ping. http://reviews.llvm.org/D13054 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12359: New warning -Wnonconst-parameter when a pointer parameter can be const
danielmarjamaki added a comment. Thanks! Very good comments. I will look at the comments asap. but unfortunately I don't have time right now. I expect that I can continue working on this warning in a few weeks. Comment at: include/clang/AST/DeclBase.h:279 @@ +278,3 @@ + /// be "const". + unsigned Written : 1; + aaron.ballman wrote: > Should this bit be sunk all the way down into Decl? What does it mean for a > TypedefNameDecl or LabelDecl to be written? This seems like it belongs more > with something like VarDecl (but you might need FieldDecl for C++ support, so > perhaps ValueDecl?), but I'm not certain. > > I'm still a bit confused by "written" in the name (here and with the > isWritten(), etc) -- It refers to is whether the declaration is used as a > non-const lvalue, not whether the variable is spelled out in code (as opposed > to an implicit variable, such as ones used by range-based for loops). Perhaps > HasNonConstUse, or something a bit more descriptive? I agree. I will investigate. I only want to warn about parameters and nothing more but maybe vardecl is a good place. Since you think 'NonConstUse' is better than 'Written' I will change.. I have no opinion. Comment at: include/clang/AST/DeclBase.h:545 @@ -540,1 +544,3 @@ + /// \brief Whether the declared symbol is written. + bool isWritten() const { return Written; } aaron.ballman wrote: > What does it mean for a declared symbol to be written? We have a > similar-sounding function in CXXCtorInitializer that means the initializer > was explicitly written, but I don't think the same applies here? I have changed this to: /// \brief Whether the declared symbol is written either directly or /// indirectly. A "written" declaration can't be const. Is this ok? Comment at: lib/Parse/ParseStmt.cpp:379 @@ +378,3 @@ + if (auto *B = dyn_cast(E)) { +if (B->isAdditiveOp()) { + // p + 2 aaron.ballman wrote: > Why does addition count as "writing?" see dontwarn13 and dontwarn16. if taking the address "p" is a "write" then taking the address "p+2" is also a "write". Comment at: lib/Parse/ParseStmt.cpp:401 @@ +400,3 @@ + } else if (auto *C = dyn_cast(E)) { +MarkWritten(C->getTrueExpr()); +MarkWritten(C->getFalseExpr()); aaron.ballman wrote: > Again, why? It's for code like dontwarn7 , dontwarn8, dontwarn9. If taking the address "p" is a "write" then "x?p:q" is a "write". Comment at: lib/Sema/SemaExpr.cpp:9518 @@ -9517,1 +9517,3 @@ +// Mark symbols in l-value expression as written. +static void MarkWritten(Expr *E) { aaron.ballman wrote: > Use \brief comments. Also, I don't see how this applies to lvalue expressions? > > Also, this function is almost identical to the one in SemaDecl.cpp, except > for array subscripts. Why the differences? > Also, I don't see how this applies to lvalue expressions? I wanted to indicate that this function is for instance used for LHS in assignments but not RHS. For instance there is no "address is taken". > Also, this function is almost identical to the one in SemaDecl.cpp, except > for array subscripts. Why the differences? I think that would cause FN in a testcase. but I'll need to recompile to know.. Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:3616 @@ -3615,2 +3615,3 @@ NewVar->setReferenced(OldVar->isReferenced()); +NewVar->setWritten(); } aaron.ballman wrote: > Should this rely on OldVar->isWritten()? Good catch. Yes I do think so, I will fix. Comment at: lib/Serialization/ASTReaderDecl.cpp:503 @@ -502,2 +502,3 @@ D->setReferenced(Record[Idx++]); + D->setWritten(); D->setTopLevelDeclInObjCContainer(Record[Idx++]); aaron.ballman wrote: > Why don't we need to read this value from the serialized AST? hmm.. I want to see a testcase. I am not sure how I use serialized ASTs. I added setWritten() after every setReferenced() where it would not cause FN in my testcases. Comment at: test/SemaCXX/warn-nonconst-parameter.cpp:1 @@ +1,2 @@ +// RUN: %clang_cc1 -fsyntax-only -Wnonconst-parameter -verify %s +// aaron.ballman wrote: > Missing test coverage for the template cases you handled in code. > > Also, I this doesn't warn in cases I would expect involving references, like: > > void f(int &r) { > int i = r; > } hmm.. yes references could be interesting too. I only use Clang on C code so handling references is low priority for me. but maybe it's just a 5 minutes hack. Comment at: test/SemaCXX/warn-nonconst-parameter.cpp:14 @@ +13,3 @@ + +class Derived /* : public Base */ { +public: aaron.ballman wrote: > Why is Base commented out? mistake. will be fixed. http://reviews.llvm.org/D12359 ___ cf
Re: [PATCH] D13166: Create modernize-make-unique check.
angelgarcia added a comment. How can Lexer::getSourceText give us the range? My problem precisely is that I couldn't find any way to obtain the range of the constructor call without the template arguments. http://reviews.llvm.org/D13166 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13206: Add clang-query tool to installation targets
foutrelis added a comment. Just a note that this change is specific to CMake since autotools already installs clang-query (along with some other tools). http://reviews.llvm.org/D13206 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D13206: Add clang-query tool to installation targets
foutrelis created this revision. foutrelis added a subscriber: cfe-commits. It has been requested in a bug report downstream in Arch Linux to include the clang-query tool as part of our clang-tools-extra package. [1] This point has also been brought up on the cfe-dev list and the LLVM bug tracker. [2] [3] This diff is an attempt at upstreaming this change. Note that it only deals with clang-query since I'm not sure what other tools would be useful to install. [1] https://bugs.archlinux.org/task/46392#comment139256 [2] http://lists.llvm.org/pipermail/cfe-dev/2015-June/043318.html [3] https://llvm.org/bugs/show_bug.cgi?id=24046 http://reviews.llvm.org/D13206 Files: clang-query/tool/CMakeLists.txt Index: clang-query/tool/CMakeLists.txt === --- clang-query/tool/CMakeLists.txt +++ clang-query/tool/CMakeLists.txt @@ -10,3 +10,5 @@ clangQuery clangTooling ) + +install(TARGETS clang-query RUNTIME DESTINATION bin) Index: clang-query/tool/CMakeLists.txt === --- clang-query/tool/CMakeLists.txt +++ clang-query/tool/CMakeLists.txt @@ -10,3 +10,5 @@ clangQuery clangTooling ) + +install(TARGETS clang-query RUNTIME DESTINATION bin) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13206: Add clang-query tool to installation targets
klimek added a subscriber: klimek. klimek accepted this revision. klimek added a reviewer: klimek. klimek added a comment. This revision is now accepted and ready to land. LG As we already a) install it from auto-tools and b) this tool is useful for non-llvm/clang devs http://reviews.llvm.org/D13206 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D13210: Make brace styles more configurable
djasper created this revision. djasper added a reviewer: klimek. djasper added a subscriber: cfe-commits. Herald added a subscriber: klimek. Add individual brace flags for the different aspects of wrapping braces and make Allman, GNU, etc. just presets for them. This patch isn't complete yet, still need to verify the individual presets some more (I think we don't have full test coverage there) and comment, etc. For now, I'd like a second opinion on whether the approach is sound. http://reviews.llvm.org/D13210 Files: include/clang/Format/Format.h lib/Format/Format.cpp lib/Format/TokenAnnotator.cpp lib/Format/UnwrappedLineFormatter.cpp lib/Format/UnwrappedLineParser.cpp Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -154,12 +154,10 @@ CompoundStatementIndenter(UnwrappedLineParser *Parser, const FormatStyle &Style, unsigned &LineLevel) : LineLevel(LineLevel), OldLineLevel(LineLevel) { -if (Style.BreakBeforeBraces == FormatStyle::BS_Allman) { - Parser->addUnwrappedLine(); -} else if (Style.BreakBeforeBraces == FormatStyle::BS_GNU) { +if (Style.BraceWrapping.AfterControlStatement) Parser->addUnwrappedLine(); +if (Style.BraceWrapping.IndentBraces) ++LineLevel; -} } ~CompoundStatementIndenter() { LineLevel = OldLineLevel; } @@ -456,17 +454,15 @@ static bool ShouldBreakBeforeBrace(const FormatStyle &Style, const FormatToken &InitialToken) { - switch (Style.BreakBeforeBraces) { - case FormatStyle::BS_Linux: -return InitialToken.isOneOf(tok::kw_namespace, tok::kw_class); - case FormatStyle::BS_Mozilla: -return InitialToken.isOneOf(tok::kw_class, tok::kw_struct, tok::kw_union); - case FormatStyle::BS_Allman: - case FormatStyle::BS_GNU: -return true; - default: -return false; - } + if (InitialToken.is(tok::kw_namespace)) +return Style.BraceWrapping.AfterNamespace; + if (InitialToken.is(tok::kw_class)) +return Style.BraceWrapping.AfterClass; + if (InitialToken.is(tok::kw_union)) +return Style.BraceWrapping.AfterUnion; + if (InitialToken.is(tok::kw_struct)) +return Style.BraceWrapping.AfterStruct; + return false; } void UnwrappedLineParser::parseChildBlock() { @@ -681,8 +677,7 @@ case tok::objc_autoreleasepool: nextToken(); if (FormatTok->Tok.is(tok::l_brace)) { -if (Style.BreakBeforeBraces == FormatStyle::BS_Allman || -Style.BreakBeforeBraces == FormatStyle::BS_GNU) +if (Style.BraceWrapping.AfterObjCDeclaration) addUnwrappedLine(); parseBlock(/*MustBeDeclaration=*/false); } @@ -871,7 +866,7 @@ // structural element. // FIXME: Figure out cases where this is not true, and add projections // for them (the one we know is missing are lambdas). -if (Style.BreakBeforeBraces != FormatStyle::BS_Attach) +if (Style.BraceWrapping.AfterFunction) addUnwrappedLine(); FormatTok->Type = TT_FunctionLBrace; parseBlock(/*MustBeDeclaration=*/false); @@ -1259,21 +1254,17 @@ if (FormatTok->Tok.is(tok::l_brace)) { CompoundStatementIndenter Indenter(this, Style, Line->Level); parseBlock(/*MustBeDeclaration=*/false); -if (Style.BreakBeforeBraces == FormatStyle::BS_Allman || -Style.BreakBeforeBraces == FormatStyle::BS_GNU) { +if (Style.BraceWrapping.BeforeElse) addUnwrappedLine(); -} else { +else NeedsUnwrappedLine = true; -} } else { addUnwrappedLine(); ++Line->Level; parseStructuralElement(); --Line->Level; } if (FormatTok->Tok.is(tok::kw_else)) { -if (Style.BreakBeforeBraces == FormatStyle::BS_Stroustrup) - addUnwrappedLine(); nextToken(); if (FormatTok->Tok.is(tok::l_brace)) { CompoundStatementIndenter Indenter(this, Style, Line->Level); @@ -1314,9 +1305,7 @@ if (FormatTok->is(tok::l_brace)) { CompoundStatementIndenter Indenter(this, Style, Line->Level); parseBlock(/*MustBeDeclaration=*/false); -if (Style.BreakBeforeBraces == FormatStyle::BS_Allman || -Style.BreakBeforeBraces == FormatStyle::BS_GNU || -Style.BreakBeforeBraces == FormatStyle::BS_Stroustrup) { +if (Style.BraceWrapping.BeforeCatch) { addUnwrappedLine(); } else { NeedsUnwrappedLine = true; @@ -1354,17 +1343,13 @@ NeedsUnwrappedLine = false; CompoundStatementIndenter Indenter(this, Style, Line->Level); parseBlock(/*MustBeDeclaration=*/false); -if (Style.BreakBeforeBraces == FormatStyle::BS_Allman || -Style.BreakBeforeBraces == FormatStyle::BS_GNU || -Style.BreakBeforeBraces == FormatStyle::BS_Stroustrup) { +if (Style.BraceWrapping.BeforeCatch) addUnwrappedLine(); -} else { +else NeedsU
[PATCH] D13211: clang-format: [JS] handle let (ES6).
mprobst created this revision. mprobst added reviewers: klimek, djasper. mprobst added a subscriber: cfe-commits. Herald added a subscriber: klimek. clang-format: [JS] handle let (ES6). http://reviews.llvm.org/D13211 Files: lib/Format/FormatToken.h lib/Format/TokenAnnotator.cpp lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTestJS.cpp Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -101,7 +101,9 @@ TEST_F(FormatTestJS, ES6DestructuringAssignment) { verifyFormat("var [a, b, c] = [1, 2, 3];"); + verifyFormat("let [a, b, c] = [1, 2, 3];"); verifyFormat("var {a, b} = {a: 1, b: 2};"); + verifyFormat("let {a, b} = {a: 1, b: 2};"); } TEST_F(FormatTestJS, ContainerLiterals) { Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -1782,7 +1782,7 @@ } if (FormatTok->isOneOf(tok::kw_const, tok::kw_class, tok::kw_enum, - Keywords.kw_var)) + Keywords.kw_let, Keywords.kw_var)) return; // Fall through to parsing the corresponding structure. if (FormatTok->is(tok::l_brace)) { Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -1951,7 +1951,7 @@ Left.isOneOf(Keywords.kw_returns, Keywords.kw_option)) return true; } else if (Style.Language == FormatStyle::LK_JavaScript) { -if (Left.isOneOf(Keywords.kw_var, TT_JsFatArrow)) +if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, TT_JsFatArrow)) return true; if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion)) return false; @@ -2082,8 +2082,9 @@ Left.Previous && Left.Previous->is(tok::equal) && Line.First->isOneOf(tok::identifier, Keywords.kw_import, tok::kw_export, tok::kw_const) && -// kw_var is a pseudo-token that's a tok::identifier, so matches above. -!Line.startsWith(Keywords.kw_var)) +// kw_var/kw_let are pseudo-tokens that are tok::identifier, so match +// above. +!Line.startsWith(Keywords.kw_var) && !Line.startsWith(Keywords.kw_let)) // Object literals on the top level of a file are treated as "enum-style". // Each key/value pair is put on a separate line, instead of bin-packing. return true; Index: lib/Format/FormatToken.h === --- lib/Format/FormatToken.h +++ lib/Format/FormatToken.h @@ -536,6 +536,7 @@ kw_finally = &IdentTable.get("finally"); kw_function = &IdentTable.get("function"); kw_import = &IdentTable.get("import"); +kw_let = &IdentTable.get("let"); kw_var = &IdentTable.get("var"); kw_abstract = &IdentTable.get("abstract"); @@ -577,6 +578,7 @@ IdentifierInfo *kw_finally; IdentifierInfo *kw_function; IdentifierInfo *kw_import; + IdentifierInfo *kw_let; IdentifierInfo *kw_var; // Java keywords. Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -101,7 +101,9 @@ TEST_F(FormatTestJS, ES6DestructuringAssignment) { verifyFormat("var [a, b, c] = [1, 2, 3];"); + verifyFormat("let [a, b, c] = [1, 2, 3];"); verifyFormat("var {a, b} = {a: 1, b: 2};"); + verifyFormat("let {a, b} = {a: 1, b: 2};"); } TEST_F(FormatTestJS, ContainerLiterals) { Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -1782,7 +1782,7 @@ } if (FormatTok->isOneOf(tok::kw_const, tok::kw_class, tok::kw_enum, - Keywords.kw_var)) + Keywords.kw_let, Keywords.kw_var)) return; // Fall through to parsing the corresponding structure. if (FormatTok->is(tok::l_brace)) { Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -1951,7 +1951,7 @@ Left.isOneOf(Keywords.kw_returns, Keywords.kw_option)) return true; } else if (Style.Language == FormatStyle::LK_JavaScript) { -if (Left.isOneOf(Keywords.kw_var, TT_JsFatArrow)) +if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, TT_JsFatArrow)) return true; if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion)) return false; @@ -2082,8 +2082,9 @@ Left.Previous && Left.Previous->is(tok::equal) && Line.First->isOneOf(tok::identifier, Keywords.kw_import, tok::kw_export,
Re: [PATCH] D13211: clang-format: [JS] handle let (ES6).
djasper accepted this revision. This revision is now accepted and ready to land. Comment at: lib/Format/TokenAnnotator.cpp:2087 @@ -2087,1 +2086,3 @@ +// above. +!Line.startsWith(Keywords.kw_var) && !Line.startsWith(Keywords.kw_let)) // Object literals on the top level of a file are treated as "enum-style". Hm.. Or Line.First->isOneOf(Keywords.kw_var, KeyWords.kw_let). I like that a bit better, but don't really care. http://reviews.llvm.org/D13211 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r248710 - Install clang-query by default.
Author: klimek Date: Mon Sep 28 08:26:39 2015 New Revision: 248710 URL: http://llvm.org/viewvc/llvm-project?rev=248710&view=rev Log: Install clang-query by default. It is already installed by the autotools build, and it is useful for developers who are not working on LLVM/Clang itself. Modified: clang-tools-extra/trunk/clang-query/tool/CMakeLists.txt Modified: clang-tools-extra/trunk/clang-query/tool/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/tool/CMakeLists.txt?rev=248710&r1=248709&r2=248710&view=diff == --- clang-tools-extra/trunk/clang-query/tool/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clang-query/tool/CMakeLists.txt Mon Sep 28 08:26:39 2015 @@ -10,3 +10,5 @@ target_link_libraries(clang-query clangQuery clangTooling ) + +install(TARGETS clang-query RUNTIME DESTINATION bin) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13206: Add clang-query tool to installation targets
klimek closed this revision. klimek added a comment. Submitted in r248710 http://reviews.llvm.org/D13206 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13206: Add clang-query tool to installation targets
foutrelis added a comment. Thanks for the review. Can you please commit the patch to `clang-tools-extra/trunk` (since I don't have commit rights)? http://reviews.llvm.org/D13206 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: Bug 23529: Add support for gcc's attribute abi_tag (needed for compatibility with gcc 5's libstdc++)
On Sun, Sep 27, 2015 at 2:45 PM Stefan Bühler via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Hi, > > it seems moderation didn't approve the phabricator mails for D12834. > (I have no intention to be subscribed to the list just to get > phabricator mails through. For now I am subscribed but disabled > mail delivery -.-) > > So the patch is available at http://reviews.llvm.org/D12834 > > I also added a test case which shows that substitution is not > working correctly right now. > > regards, > Stefan > > PS: I think contributing to llvm is way to complex. First I attatch > patches in the bug tracker, and it takes ages to get a reaction - and > them I'm simply told to send to the ML. Then you want me to use > phabricator, and then I get no feedback again - because moderation > blocked emails from an internal system, and it seems nobody is looking > at phabricator directly. > This is not something I look forward to go through again; my > motiviation to contribute further is rather low. > I'm very sorry you had a bad experience. That patches attached to bugs don't get answered is an unfortunate issue; the problem is that most patches are when sent out first not of a quality that they can be directly submitted, and require significant work (this is especially true for larger packages), which is why we have a code review process set up via the list. Could we perhaps help that with better documentation somewhere? Where would you have looked first? That the phab email was blocked without getting moderator approval is surprising to me. I'm going to figure out who moderates the email list these days, and why that didn't get unstuck. Also, note that phab is generally not required (but it will often get you code reviews faster, as especially large patches are harder to review for some people). > On Sat, 12 Sep 2015 12:36:19 -0700 > David Majnemer wrote: > > > Would you mind sticking abi-tag.patch in phabricator: > > http://llvm.org/docs/Phabricator.html ? > > Your patch is big enough that it would make it a little easier for me > > to review. > > > > On Sat, Sep 12, 2015 at 7:12 AM, Stefan Bühler via cfe-commits < > > cfe-commits@lists.llvm.org> wrote: > > > > > Hi all, > > > > > > I've been working on #23529. > > > > > > The abi tag mangling implemented by gcc is horrible, but I think my > > > patch covers most of the incompatibilities with gcc5. > > > > > > There might be some bugs with substitutions, although I have to > > > come up with a test case for that to see what gcc does... > > > > > > Test cases comparing gcc and patched clang++: > > > http://files.stbuehler.de/test-itanium-mangle.html > > > (generated with http://files.stbuehler.de/test-itanium-mangle.sh, > > > also attached) > ___ > 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
Re: [PATCH] D13166: Create modernize-make-unique check.
angelgarcia updated this revision to Diff 35864. angelgarcia added a comment. I think this is a bit better than before. http://reviews.llvm.org/D13166 Files: clang-tidy/modernize/CMakeLists.txt clang-tidy/modernize/MakeUniqueCheck.cpp clang-tidy/modernize/MakeUniqueCheck.h clang-tidy/modernize/ModernizeTidyModule.cpp test/clang-tidy/modernize-make-unique.cpp Index: test/clang-tidy/modernize-make-unique.cpp === --- /dev/null +++ test/clang-tidy/modernize-make-unique.cpp @@ -0,0 +1,116 @@ +// RUN: %python %S/check_clang_tidy.py %s modernize-make-unique %t + +namespace std { + +template +class unique_ptr { +public: + unique_ptr(type *ptr); + unique_ptr(const unique_ptr &t) = delete; + unique_ptr(unique_ptr &&t); + ~unique_ptr(); + type &operator*() { return *ptr; } + type *operator->() { return ptr; } + type *release(); + void reset(); + void reset(type *pt); + +private: + type *ptr; +}; + +} + +struct Base { + Base(); + Base(int, int); +}; + +struct Derived : public Base { + Derived(); + Derived(int, int); +}; + +struct Pair { + int a, b; +}; + +template using unique_ptr_ = std::unique_ptr; + +int g(std::unique_ptr P); + +std::unique_ptr getPointer() { + return std::unique_ptr(new Base); + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use std::make_unique instead + // CHECK-FIXES: return std::make_unique(); +} + +void f() { + std::unique_ptr P1 = std::unique_ptr(new int()); + // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique] + // CHECK-FIXES: std::unique_ptr P1 = std::make_unique(); + + // Without parenthesis. + std::unique_ptr P2 = std::unique_ptr(new int); + // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique] + // CHECK-FIXES: std::unique_ptr P2 = std::make_unique(); + + // With auto. + auto P3 = std::unique_ptr(new int()); + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead + // CHECK-FIXES: auto P3 = std::make_unique(); + + { +// No std. +using namespace std; +unique_ptr Q = unique_ptr(new int()); +// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use std::make_unique instead +// CHECK-FIXES: unique_ptr Q = std::make_unique(); + } + + std::unique_ptr R(new int()); + + // Create the unique_ptr as a parameter to a function. + int T = g(std::unique_ptr(new int())); + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead + // CHECK-FIXES: int T = g(std::make_unique()); + + // Arguments are correctly handled. + std::unique_ptr Pbase = std::unique_ptr(new Base(5, T)); + // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: use std::make_unique instead + // CHECK-FIXES: std::unique_ptr Pbase = std::make_unique(5, T); + + // Works with init lists. + std::unique_ptr Ppair = std::unique_ptr(new Pair{T, 1}); + // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: use std::make_unique instead + // CHECK-FIXES: std::unique_ptr Ppair = std::make_unique({T, 1}); + + // Only replace if the type in the template is the same than the type returned + // by the new operator. + auto Pderived = std::unique_ptr(new Derived()); + + // The pointer is returned by the function, nothing to do. + std::unique_ptr RetPtr = getPointer(); + + // Aliases. + typedef std::unique_ptr IntPtr; + IntPtr Typedef = IntPtr(new int); + +#define PTR unique_ptr + std::unique_ptr Macro = std::PTR(new int); +#undef PTR + + std::unique_ptr Using = unique_ptr_(new int); + + // This emulates std::move. + std::unique_ptr Move = static_cast&&>(P1); + + // Adding whitespaces. + auto Space = std::unique_ptr (new int()); + // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use std::make_unique instead + // CHECK-FIXES: auto Space = std::make_unique(); + + auto Spaces = std ::unique_ptr (new int()); + // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use std::make_unique instead + // CHECK-FIXES: auto Spaces = std::make_unique(); +} Index: clang-tidy/modernize/ModernizeTidyModule.cpp === --- clang-tidy/modernize/ModernizeTidyModule.cpp +++ clang-tidy/modernize/ModernizeTidyModule.cpp @@ -11,6 +11,7 @@ #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" #include "LoopConvertCheck.h" +#include "MakeUniqueCheck.h" #include "PassByValueCheck.h" #include "ReplaceAutoPtrCheck.h" #include "ShrinkToFitCheck.h" @@ -28,6 +29,8 @@ public: void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { CheckFactories.registerCheck("modernize-loop-convert"); +CheckFactories.registerCheck( +"modernize-make-unique"); CheckFactories.registerCheck("modernize-pass-by-value"); CheckFactories.registerCheck( "modernize-replace-auto-ptr"); Index: clang-tidy/modernize/MakeUniqueCheck.h === --- /dev/null +++ clang-ti
Re: [PATCH] D13166: Create modernize-make-unique check.
klimek added inline comments. Comment at: clang-tidy/modernize/MakeUniqueCheck.cpp:75-76 @@ +74,4 @@ + std::string Identifier = removeWhitespace(ExprStr.substr(0, LAngle)); + if (Identifier != "unique_ptr" && Identifier != "std::unique_ptr") +return; + SourceLocation ConstructCallEnd = ConstructCallStart.getLocWithOffset(LAngle); Comment what cases this can happen in, and why we don't want to replace in those cases... http://reviews.llvm.org/D13166 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D13213: clang-format: [JS] Support pseudo-keywords.
mprobst created this revision. mprobst added reviewers: djasper, klimek. mprobst added a subscriber: cfe-commits. Herald added a subscriber: klimek. JavaScript allows keywords to appear in IdenfierName positions, e.g. fields, or object literal members, but not as plain identifiers. http://reviews.llvm.org/D13213 Files: lib/Format/TokenAnnotator.cpp lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTestJS.cpp Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -99,6 +99,19 @@ verifyFormat("not.and.or.not_eq = 1;"); } +TEST_F(FormatTestJS, ReservedWords) { + // JavaScript reserved words (aka keywords) are only illegal when used as + // Identifiers, but are legal as IdentifierNames. + verifyFormat("x.class.struct = 1;"); + verifyFormat("x.case = 1;"); + verifyFormat("x.interface = 1;"); + verifyFormat("x = {\n" + " a: 12,\n" + " interface: 1,\n" + " switch: 1,\n" + "};"); +} + TEST_F(FormatTestJS, ES6DestructuringAssignment) { verifyFormat("var [a, b, c] = [1, 2, 3];"); verifyFormat("var {a, b} = {a: 1, b: 2};"); Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -844,6 +844,11 @@ if (Style.Language == FormatStyle::LK_Java && FormatTok && FormatTok->is(tok::kw_class)) nextToken(); + if (Style.Language == FormatStyle::LK_JavaScript && FormatTok && + FormatTok->Tok.getIdentifierInfo()) +// JavaScript only has pseudo keywords, all keywords are allowed to +// appear in "IdentifierName" positions. See http://es5.github.io/#x7.6 +nextToken(); break; case tok::semi: nextToken(); Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -374,7 +374,7 @@ FormatToken *Previous = CurrentToken->getPreviousNonComment(); if ((CurrentToken->is(tok::colon) || Style.Language == FormatStyle::LK_Proto) && - Previous->is(tok::identifier)) + Previous->Tok.getIdentifierInfo()) Previous->Type = TT_SelectorName; if (CurrentToken->is(tok::colon) || Style.Language == FormatStyle::LK_JavaScript) Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -99,6 +99,19 @@ verifyFormat("not.and.or.not_eq = 1;"); } +TEST_F(FormatTestJS, ReservedWords) { + // JavaScript reserved words (aka keywords) are only illegal when used as + // Identifiers, but are legal as IdentifierNames. + verifyFormat("x.class.struct = 1;"); + verifyFormat("x.case = 1;"); + verifyFormat("x.interface = 1;"); + verifyFormat("x = {\n" + " a: 12,\n" + " interface: 1,\n" + " switch: 1,\n" + "};"); +} + TEST_F(FormatTestJS, ES6DestructuringAssignment) { verifyFormat("var [a, b, c] = [1, 2, 3];"); verifyFormat("var {a, b} = {a: 1, b: 2};"); Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -844,6 +844,11 @@ if (Style.Language == FormatStyle::LK_Java && FormatTok && FormatTok->is(tok::kw_class)) nextToken(); + if (Style.Language == FormatStyle::LK_JavaScript && FormatTok && + FormatTok->Tok.getIdentifierInfo()) +// JavaScript only has pseudo keywords, all keywords are allowed to +// appear in "IdentifierName" positions. See http://es5.github.io/#x7.6 +nextToken(); break; case tok::semi: nextToken(); Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -374,7 +374,7 @@ FormatToken *Previous = CurrentToken->getPreviousNonComment(); if ((CurrentToken->is(tok::colon) || Style.Language == FormatStyle::LK_Proto) && - Previous->is(tok::identifier)) + Previous->Tok.getIdentifierInfo()) Previous->Type = TT_SelectorName; if (CurrentToken->is(tok::colon) || Style.Language == FormatStyle::LK_JavaScript) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13213: clang-format: [JS] Support pseudo-keywords.
djasper accepted this revision. djasper added a comment. This revision is now accepted and ready to land. Looks good. http://reviews.llvm.org/D13213 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12839: Extend MoveConstructorInitCheck to also flag constructor arguments passed by value and can be moved assigned to fields.
alexfh added a comment. In http://reviews.llvm.org/D12839#254384, @flx wrote: > I changed the check to also produce a fix that wraps the argument in > std::move(). > > When I modified the test include -isystem %S/Inputs/Headers it broke and only > produces warnings but no fixes anymore. Is there a subtle difference in how > tests with includes need to be invoked? Did you add the files you're including (`j.h`, `s.h`)? If not, this will result in compilation errors and clang-tidy by default won't apply fixes, if the code doesn't compile. In any case, they should be present in the patch as well. Comment at: clang-tidy/misc/MoveConstructorInitCheck.cpp:110 @@ +109,3 @@ + Result.SourceManager->getFileID(InitArg->getLocStart()), "utility", + true)) { +DiagOut << *IncludeFixit; `/*IsAngled=*/true)) {` Comment at: clang-tidy/modernize/PassByValueCheck.cpp:121 @@ -120,4 +120,3 @@ : ClangTidyCheck(Name, Context), - IncludeStyle(Options.get("IncludeStyle", "llvm") == "llvm" ? - IncludeSorter::IS_LLVM : IncludeSorter::IS_Google) {} + IncludeStyle(IncludeSorter::toIncludeStyle(Options.get("IncludeStyle", "llvm"))) {} clang-format? Comment at: clang-tidy/modernize/ReplaceAutoPtrCheck.cpp:191 @@ -190,5 +190,3 @@ : ClangTidyCheck(Name, Context), - IncludeStyle(Options.get("IncludeStyle", "llvm") == "llvm" - ? IncludeSorter::IS_LLVM - : IncludeSorter::IS_Google) {} + IncludeStyle(IncludeSorter::toIncludeStyle(Options.get("IncludeStyle", "llvm"))) {} clang-format? Comment at: clang-tidy/utils/IncludeSorter.h:29 @@ +28,3 @@ + // Converts "llvm" to IS_LLVM, otherwise returns IS_Google. + static IncludeStyle toIncludeStyle(const std::string &Value); + nit: The current name gives no hints at what is being converted to IncludeStyle, but `parseIncludeStyle` would make it clear that the source is a string. http://reviews.llvm.org/D12839 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13166: Create modernize-make-unique check.
angelgarcia added a comment. This raises a question. Do we want to do replacements when we use an alias for std::unique_ptr? That fact that something is an unique_ptr might be an implementation detail that should not be exposed, but it could also happen that the alias is there only for brevity. What do you think? http://reviews.llvm.org/D13166 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13211: clang-format: [JS] handle let (ES6).
mprobst updated this revision to Diff 35867. mprobst marked an inline comment as done. mprobst added a comment. Use isOneOf instead of startsWith. http://reviews.llvm.org/D13211 Files: lib/Format/FormatToken.h lib/Format/TokenAnnotator.cpp lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTestJS.cpp Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -101,7 +101,9 @@ TEST_F(FormatTestJS, ES6DestructuringAssignment) { verifyFormat("var [a, b, c] = [1, 2, 3];"); + verifyFormat("let [a, b, c] = [1, 2, 3];"); verifyFormat("var {a, b} = {a: 1, b: 2};"); + verifyFormat("let {a, b} = {a: 1, b: 2};"); } TEST_F(FormatTestJS, ContainerLiterals) { Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -1782,7 +1782,7 @@ } if (FormatTok->isOneOf(tok::kw_const, tok::kw_class, tok::kw_enum, - Keywords.kw_var)) + Keywords.kw_let, Keywords.kw_var)) return; // Fall through to parsing the corresponding structure. if (FormatTok->is(tok::l_brace)) { Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -1951,7 +1951,7 @@ Left.isOneOf(Keywords.kw_returns, Keywords.kw_option)) return true; } else if (Style.Language == FormatStyle::LK_JavaScript) { -if (Left.isOneOf(Keywords.kw_var, TT_JsFatArrow)) +if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, TT_JsFatArrow)) return true; if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion)) return false; @@ -2082,8 +2082,9 @@ Left.Previous && Left.Previous->is(tok::equal) && Line.First->isOneOf(tok::identifier, Keywords.kw_import, tok::kw_export, tok::kw_const) && -// kw_var is a pseudo-token that's a tok::identifier, so matches above. -!Line.startsWith(Keywords.kw_var)) +// kw_var/kw_let are pseudo-tokens that are tok::identifier, so match +// above. +!Line.First->isOneOf(Keywords.kw_var, Keywords.kw_let)) // Object literals on the top level of a file are treated as "enum-style". // Each key/value pair is put on a separate line, instead of bin-packing. return true; Index: lib/Format/FormatToken.h === --- lib/Format/FormatToken.h +++ lib/Format/FormatToken.h @@ -536,6 +536,7 @@ kw_finally = &IdentTable.get("finally"); kw_function = &IdentTable.get("function"); kw_import = &IdentTable.get("import"); +kw_let = &IdentTable.get("let"); kw_var = &IdentTable.get("var"); kw_abstract = &IdentTable.get("abstract"); @@ -577,6 +578,7 @@ IdentifierInfo *kw_finally; IdentifierInfo *kw_function; IdentifierInfo *kw_import; + IdentifierInfo *kw_let; IdentifierInfo *kw_var; // Java keywords. Index: unittests/Format/FormatTestJS.cpp === --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -101,7 +101,9 @@ TEST_F(FormatTestJS, ES6DestructuringAssignment) { verifyFormat("var [a, b, c] = [1, 2, 3];"); + verifyFormat("let [a, b, c] = [1, 2, 3];"); verifyFormat("var {a, b} = {a: 1, b: 2};"); + verifyFormat("let {a, b} = {a: 1, b: 2};"); } TEST_F(FormatTestJS, ContainerLiterals) { Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -1782,7 +1782,7 @@ } if (FormatTok->isOneOf(tok::kw_const, tok::kw_class, tok::kw_enum, - Keywords.kw_var)) + Keywords.kw_let, Keywords.kw_var)) return; // Fall through to parsing the corresponding structure. if (FormatTok->is(tok::l_brace)) { Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -1951,7 +1951,7 @@ Left.isOneOf(Keywords.kw_returns, Keywords.kw_option)) return true; } else if (Style.Language == FormatStyle::LK_JavaScript) { -if (Left.isOneOf(Keywords.kw_var, TT_JsFatArrow)) +if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, TT_JsFatArrow)) return true; if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion)) return false; @@ -2082,8 +2082,9 @@ Left.Previous && Left.Previous->is(tok::equal) && Line.First->isOneOf(tok::identifier, Keywords.kw_import, tok::kw_export, tok::kw_const) && -
Re: [PATCH] D13166: Create modernize-make-unique check.
klimek added a comment. In http://reviews.llvm.org/D13166#254730, @angelgarcia wrote: > This raises a question. Do we want to do replacements when we use an alias > for std::unique_ptr? That fact that something is an unique_ptr might be an > implementation detail that should not be exposed, but it could also happen > that the alias is there only for brevity. What do you think? Good question. Generally, it seems to me that aliasing unique_ptr wouldn't seem useful apart from having a shortcut; unique_ptr is special in a couple of ways, which would make it particularly weird as an "implementation detail". My take on it is that we want to replace those, until we find real use cases that warrant a more complex implementation. http://reviews.llvm.org/D13166 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r248713 - clang-format: [JS] handle let (ES6)
Author: djasper Date: Mon Sep 28 09:28:08 2015 New Revision: 248713 URL: http://llvm.org/viewvc/llvm-project?rev=248713&view=rev Log: clang-format: [JS] handle let (ES6) Patch by Martin Probst. Thank you! Modified: cfe/trunk/lib/Format/FormatToken.h cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/lib/Format/UnwrappedLineParser.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Modified: cfe/trunk/lib/Format/FormatToken.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=248713&r1=248712&r2=248713&view=diff == --- cfe/trunk/lib/Format/FormatToken.h (original) +++ cfe/trunk/lib/Format/FormatToken.h Mon Sep 28 09:28:08 2015 @@ -536,6 +536,7 @@ struct AdditionalKeywords { kw_finally = &IdentTable.get("finally"); kw_function = &IdentTable.get("function"); kw_import = &IdentTable.get("import"); +kw_let = &IdentTable.get("let"); kw_var = &IdentTable.get("var"); kw_abstract = &IdentTable.get("abstract"); @@ -577,6 +578,7 @@ struct AdditionalKeywords { IdentifierInfo *kw_finally; IdentifierInfo *kw_function; IdentifierInfo *kw_import; + IdentifierInfo *kw_let; IdentifierInfo *kw_var; // Java keywords. Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=248713&r1=248712&r2=248713&view=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Sep 28 09:28:08 2015 @@ -1951,7 +1951,7 @@ bool TokenAnnotator::spaceRequiredBefore Left.isOneOf(Keywords.kw_returns, Keywords.kw_option)) return true; } else if (Style.Language == FormatStyle::LK_JavaScript) { -if (Left.isOneOf(Keywords.kw_var, TT_JsFatArrow)) +if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, TT_JsFatArrow)) return true; if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion)) return false; @@ -2082,8 +2082,9 @@ bool TokenAnnotator::mustBreakBefore(con Left.Previous && Left.Previous->is(tok::equal) && Line.First->isOneOf(tok::identifier, Keywords.kw_import, tok::kw_export, tok::kw_const) && -// kw_var is a pseudo-token that's a tok::identifier, so matches above. -!Line.startsWith(Keywords.kw_var)) +// kw_var/kw_let are pseudo-tokens that are tok::identifier, so match +// above. +!Line.First->isOneOf(Keywords.kw_var, Keywords.kw_let)) // Object literals on the top level of a file are treated as "enum-style". // Each key/value pair is put on a separate line, instead of bin-packing. return true; Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=248713&r1=248712&r2=248713&view=diff == --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original) +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Sep 28 09:28:08 2015 @@ -1782,7 +1782,7 @@ void UnwrappedLineParser::parseJavaScrip } if (FormatTok->isOneOf(tok::kw_const, tok::kw_class, tok::kw_enum, - Keywords.kw_var)) + Keywords.kw_let, Keywords.kw_var)) return; // Fall through to parsing the corresponding structure. if (FormatTok->is(tok::l_brace)) { Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=248713&r1=248712&r2=248713&view=diff == --- cfe/trunk/unittests/Format/FormatTestJS.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Sep 28 09:28:08 2015 @@ -101,7 +101,9 @@ TEST_F(FormatTestJS, LiteralOperatorsCan TEST_F(FormatTestJS, ES6DestructuringAssignment) { verifyFormat("var [a, b, c] = [1, 2, 3];"); + verifyFormat("let [a, b, c] = [1, 2, 3];"); verifyFormat("var {a, b} = {a: 1, b: 2};"); + verifyFormat("let {a, b} = {a: 1, b: 2};"); } TEST_F(FormatTestJS, ContainerLiterals) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13211: clang-format: [JS] handle let (ES6).
djasper closed this revision. djasper added a comment. Submitted as r248713. http://reviews.llvm.org/D13211 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r248714 - clang-format: [JS] Support pseudo-keywords
Author: djasper Date: Mon Sep 28 09:29:45 2015 New Revision: 248714 URL: http://llvm.org/viewvc/llvm-project?rev=248714&view=rev Log: clang-format: [JS] Support pseudo-keywords JavaScript allows keywords to appear in IdenfierName positions, e.g. fields, or object literal members, but not as plain identifiers. Patch by Martin Probst. Thank you! Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/lib/Format/UnwrappedLineParser.cpp cfe/trunk/unittests/Format/FormatTestJS.cpp Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=248714&r1=248713&r2=248714&view=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Sep 28 09:29:45 2015 @@ -374,7 +374,7 @@ private: FormatToken *Previous = CurrentToken->getPreviousNonComment(); if ((CurrentToken->is(tok::colon) || Style.Language == FormatStyle::LK_Proto) && - Previous->is(tok::identifier)) + Previous->Tok.getIdentifierInfo()) Previous->Type = TT_SelectorName; if (CurrentToken->is(tok::colon) || Style.Language == FormatStyle::LK_JavaScript) Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=248714&r1=248713&r2=248714&view=diff == --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original) +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Sep 28 09:29:45 2015 @@ -844,6 +844,11 @@ void UnwrappedLineParser::parseStructura if (Style.Language == FormatStyle::LK_Java && FormatTok && FormatTok->is(tok::kw_class)) nextToken(); + if (Style.Language == FormatStyle::LK_JavaScript && FormatTok && + FormatTok->Tok.getIdentifierInfo()) +// JavaScript only has pseudo keywords, all keywords are allowed to +// appear in "IdentifierName" positions. See http://es5.github.io/#x7.6 +nextToken(); break; case tok::semi: nextToken(); Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=248714&r1=248713&r2=248714&view=diff == --- cfe/trunk/unittests/Format/FormatTestJS.cpp (original) +++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Sep 28 09:29:45 2015 @@ -99,6 +99,19 @@ TEST_F(FormatTestJS, LiteralOperatorsCan verifyFormat("not.and.or.not_eq = 1;"); } +TEST_F(FormatTestJS, ReservedWords) { + // JavaScript reserved words (aka keywords) are only illegal when used as + // Identifiers, but are legal as IdentifierNames. + verifyFormat("x.class.struct = 1;"); + verifyFormat("x.case = 1;"); + verifyFormat("x.interface = 1;"); + verifyFormat("x = {\n" + " a: 12,\n" + " interface: 1,\n" + " switch: 1,\n" + "};"); +} + TEST_F(FormatTestJS, ES6DestructuringAssignment) { verifyFormat("var [a, b, c] = [1, 2, 3];"); verifyFormat("let [a, b, c] = [1, 2, 3];"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13213: clang-format: [JS] Support pseudo-keywords.
djasper closed this revision. djasper added a comment. Submitted as r248714. http://reviews.llvm.org/D13213 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13190: Addition of interfaces the FE to conform to Table A-2 of ELF V2 ABI V1.1
wschmidt added a comment. Other than the FIXME removal, this LGTM! Very good and careful work. Thanks for taking care of this! Comment at: lib/Headers/altivec.h:13788 @@ -13416,3 +13787,3 @@ removed with -mno-crypto). This is under development. */ #ifdef __CRYPTO__ Please remove the above FIXME, since this has now been taken care of. Comment at: lib/Headers/altivec.h:13832 @@ -13450,2 +13831,3 @@ +((X), (Y), (Z)) #endif Nice use of _Generic. I wasn't aware of this feature. Repository: rL LLVM http://reviews.llvm.org/D13190 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13127: [ARM] Upgrade codegen for vld[234] and vst[234] to to communicate a 0 address space
jketema updated this revision to Diff 35871. jketema added a comment. Sync with updates to the llvm part of this patch http://reviews.llvm.org/D13127 Files: lib/CodeGen/CGBuiltin.cpp test/CodeGen/arm-neon-misc.c test/CodeGen/arm-vector-align.c test/CodeGen/vld_dup.c Index: test/CodeGen/vld_dup.c === --- test/CodeGen/vld_dup.c +++ test/CodeGen/vld_dup.c @@ -14,7 +14,7 @@ int64_t v7[4]; v1 = vld3_dup_s32(v0); -// CHECK: [[T168:%.*]] = call { <2 x i32>, <2 x i32>, <2 x i32> } @llvm.arm.neon.vld3lane.v2i32(i8* {{.*}}, <2 x i32> undef, <2 x i32> undef, <2 x i32> undef, i32 {{[0-9]+}}, i32 {{[0-9]+}}) +// CHECK: [[T168:%.*]] = call { <2 x i32>, <2 x i32>, <2 x i32> } @llvm.arm.neon.vld3lane.v2i32.p0i8(i8* {{.*}}, <2 x i32> undef, <2 x i32> undef, <2 x i32> undef, i32 {{[0-9]+}}, i32 {{[0-9]+}}) // CHECK-NEXT: [[T169:%.*]] = extractvalue { <2 x i32>, <2 x i32>, <2 x i32> } [[T168]], 0 // CHECK-NEXT: [[T170:%.*]] = shufflevector <2 x i32> [[T169]], <2 x i32> [[T169]], <2 x i32> zeroinitializer // CHECK-NEXT: [[T171:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32> } [[T168]], <2 x i32> [[T170]], 0 @@ -26,7 +26,7 @@ // CHECK-NEXT: [[T177:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32> } [[T174]], <2 x i32> [[T176]], 2 v3 = vld4_dup_s32(v2); -// CHECK: [[T178:%.*]] = call { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } @llvm.arm.neon.vld4lane.v2i32(i8* {{.*}}, <2 x i32> undef, <2 x i32> undef, <2 x i32> undef, <2 x i32> undef, i32 {{[0-9]+}}, i32 {{[0-9]+}}) +// CHECK: [[T178:%.*]] = call { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } @llvm.arm.neon.vld4lane.v2i32.p0i8(i8* {{.*}}, <2 x i32> undef, <2 x i32> undef, <2 x i32> undef, <2 x i32> undef, i32 {{[0-9]+}}, i32 {{[0-9]+}}) // CHECK-NEXT: [[T179:%.*]] = extractvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T178]], 0 // CHECK-NEXT: [[T180:%.*]] = shufflevector <2 x i32> [[T179]], <2 x i32> [[T179]], <2 x i32> zeroinitializer // CHECK-NEXT: [[T181:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T178]], <2 x i32> [[T180]], 0 @@ -41,10 +41,10 @@ // CHECK-NEXT: [[T190:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T187]], <2 x i32> [[T189]], 3 v4 = vld3_dup_s64(v6); -// CHECK: {{%.*}} = call { <1 x i64>, <1 x i64>, <1 x i64> } @llvm.arm.neon.vld3.v1i64(i8* {{.*}}, i32 {{[0-9]+}}) +// CHECK: {{%.*}} = call { <1 x i64>, <1 x i64>, <1 x i64> } @llvm.arm.neon.vld3.v1i64.p0i8(i8* {{.*}}, i32 {{[0-9]+}}) v5 = vld4_dup_s64(v7); -// CHECK: {{%.*}} = call { <1 x i64>, <1 x i64>, <1 x i64>, <1 x i64> } @llvm.arm.neon.vld4.v1i64(i8* {{.*}}, i32 {{[0-9]+}}) +// CHECK: {{%.*}} = call { <1 x i64>, <1 x i64>, <1 x i64>, <1 x i64> } @llvm.arm.neon.vld4.v1i64.p0i8(i8* {{.*}}, i32 {{[0-9]+}}) return 0; } Index: test/CodeGen/arm-vector-align.c === --- test/CodeGen/arm-vector-align.c +++ test/CodeGen/arm-vector-align.c @@ -14,9 +14,9 @@ typedef float AlignedAddr __attribute__ ((aligned (16))); void t1(AlignedAddr *addr1, AlignedAddr *addr2) { // CHECK: @t1 -// CHECK: call <4 x float> @llvm.arm.neon.vld1.v4f32(i8* %{{.*}}, i32 16) +// CHECK: call <4 x float> @llvm.arm.neon.vld1.v4f32.p0i8(i8* %{{.*}}, i32 16) float32x4_t a = vld1q_f32(addr1); -// CHECK: call void @llvm.arm.neon.vst1.v4f32(i8* %{{.*}}, <4 x float> %{{.*}}, i32 16) +// CHECK: call void @llvm.arm.neon.vst1.p0i8.v4f32(i8* %{{.*}}, <4 x float> %{{.*}}, i32 16) vst1q_f32(addr2, a); } Index: test/CodeGen/arm-neon-misc.c === --- test/CodeGen/arm-neon-misc.c +++ test/CodeGen/arm-neon-misc.c @@ -14,20 +14,20 @@ void t1(uint64_t *src, uint8_t *dst) { // CHECK: @t1 uint64x2_t q = vld1q_u64(src); -// CHECK: call <2 x i64> @llvm.arm.neon.vld1.v2i64 +// CHECK: call <2 x i64> @llvm.arm.neon.vld1.v2i64.p0i8 vst1q_lane_u64(dst, q, 1); // CHECK: bitcast <16 x i8> %{{.*}} to <2 x i64> // CHECK: shufflevector <2 x i64> -// CHECK: call void @llvm.arm.neon.vst1.v1i64 +// CHECK: call void @llvm.arm.neon.vst1.p0i8.v1i64 } void t2(uint64_t *src1, uint8_t *src2, uint64x2_t *dst) { // CHECK: @t2 uint64x2_t q = vld1q_u64(src1); -// CHECK: call <2 x i64> @llvm.arm.neon.vld1.v2i64 +// CHECK: call <2 x i64> @llvm.arm.neon.vld1.v2i64.p0i8 q = vld1q_lane_u64(src2, q, 0); // CHECK: shufflevector <2 x i64> -// CHECK: call <1 x i64> @llvm.arm.neon.vld1.v1i64 +// CHECK: call <1 x i64> @llvm.arm.neon.vld1.v1i64.p0i8 // CHECK: shufflevector <1 x i64> *dst = q; // CHECK: store <2 x i64> Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -2895,16 +2895,19 @@ return Builder.CreateCall(F, {Ops[1], Ops[2], Ops[0]}); } case NEON::BI__builtin_neon_vld1_v: - case NEON::BI__builtin_neon_vld1q_
Re: r248678 - Use llvm::makeArrayRef. NFC.
On Sat, Sep 26, 2015 at 8:44 PM, Craig Topper via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: ctopper > Date: Sat Sep 26 22:44:08 2015 > New Revision: 248678 > > URL: http://llvm.org/viewvc/llvm-project?rev=248678&view=rev > Log: > Use llvm::makeArrayRef. NFC. > > Modified: > cfe/trunk/include/clang/AST/Type.h > cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h > cfe/trunk/lib/AST/ASTImporter.cpp > cfe/trunk/lib/CodeGen/CodeGenModule.cpp > cfe/trunk/lib/Serialization/ASTWriterDecl.cpp > > Modified: cfe/trunk/include/clang/AST/Type.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=248678&r1=248677&r2=248678&view=diff > > == > --- cfe/trunk/include/clang/AST/Type.h (original) > +++ cfe/trunk/include/clang/AST/Type.h Sat Sep 26 22:44:08 2015 > @@ -4635,7 +4635,7 @@ public: >/// Retrieve the type arguments of this object type as they were >/// written. >ArrayRef getTypeArgsAsWritten() const { > -return ArrayRef(getTypeArgStorage(), > +return llvm::makeArrayRef(getTypeArgStorage(), >ObjCObjectTypeBits.NumTypeArgs); >} > > > Modified: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h?rev=248678&r1=248677&r2=248678&view=diff > > == > --- cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h (original) > +++ cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h Sat Sep 26 > 22:44:08 2015 > @@ -1395,7 +1395,7 @@ public: > >/// Return the list of basic blocks that this terminator can branch to. >ArrayRef successors() { > -return ArrayRef(&TargetBlock, 1); > +return llvm::makeArrayRef(TargetBlock); > I think this one might work even without makeArrayRef? (there's an implicit ctor in ArrayRef from T) >} > >template > @@ -1445,7 +1445,7 @@ public: > >/// Return the list of basic blocks that this terminator can branch to. >ArrayRef successors() { > -return ArrayRef(Branches, 2); > +return llvm::makeArrayRef(Branches); >} > >template > > Modified: cfe/trunk/lib/AST/ASTImporter.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=248678&r1=248677&r2=248678&view=diff > > == > --- cfe/trunk/lib/AST/ASTImporter.cpp (original) > +++ cfe/trunk/lib/AST/ASTImporter.cpp Sat Sep 26 22:44:08 2015 > @@ -5329,7 +5329,7 @@ Expr *ASTNodeImporter::VisitCallExpr(Cal > >return new (Importer.getToContext()) > CallExpr(Importer.getToContext(), ToCallee, > - ArrayRef(ToArgs_Copied, NumArgs), T, > E->getValueKind(), > + llvm::makeArrayRef(ToArgs_Copied, NumArgs), T, > E->getValueKind(), > Importer.Import(E->getRParenLoc())); > } > > > Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=248678&r1=248677&r2=248678&view=diff > > == > --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) > +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sat Sep 26 22:44:08 2015 > @@ -2825,7 +2825,7 @@ CodeGenModule::GetAddrOfConstantCFString >// String pointer. >llvm::Constant *C = nullptr; >if (isUTF16) { > -ArrayRef Arr = llvm::makeArrayRef( > +auto Arr = llvm::makeArrayRef( > reinterpret_cast(const_cast *>(Entry.first().data())), > Entry.first().size() / 2); > C = llvm::ConstantDataArray::get(VMContext, Arr); > > Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=248678&r1=248677&r2=248678&view=diff > > == > --- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original) > +++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Sat Sep 26 22:44:08 2015 > @@ -208,7 +208,7 @@ namespace clang { >auto &&PartialSpecializations = getPartialSpecializations(Common); >ArrayRef LazySpecializations; >if (auto *LS = Common->LazySpecializations) > -LazySpecializations = ArrayRef(LS + 1, LS + 1 + LS[0]); > +LazySpecializations = llvm::makeArrayRef(LS + 1, LS + 1 + LS[0]); > Maybe you could use LS[0] as the second arg (for a ptr+length rather than begin+end construction)? > >// Add a slot to the record for the number of specializations. >unsigned I = Record.size(); > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___
Re: [clang-tools-extra] r248438 - Fix loop-convert for trivially copyable types.
On Sat, Sep 26, 2015 at 11:21 PM, Manuel Klimek via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Yep. We'll make it better by limiting the size, but trivially copyable is > an improvement, as there are orders of magnitude more loops over small > copyable types than over large ones. > We seem to be growing repeated logic for these rules in many checks (suggesting pass by value, loop convert, maybe others) - could we centralize these rules somewhere so we apply consistent logic in all of them? (& call out any necessary variation there) > > On Sat, Sep 26, 2015, 9:02 PM comex wrote: > >> On Thu, Sep 24, 2015 at 7:28 AM, Manuel Klimek via cfe-commits >> wrote: >> > Fix loop-convert for trivially copyable types. >> >> If I'm not misunderstanding the patch, "trivially copyable" by itself >> seems like a suboptimal test. After all, "trivial" can still include >> an expensive memcpy of a large struct. >> > > ___ > 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
Re: [PATCH] D13071: [PATCH] New checker for mismatched operator new/operator delete definitions
aaron.ballman marked an inline comment as done. aaron.ballman added a comment. http://reviews.llvm.org/D13071 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13071: [PATCH] New checker for mismatched operator new/operator delete definitions
aaron.ballman updated this revision to Diff 35872. aaron.ballman added a comment. Added documentation, fixed else after return. ~Aaron http://reviews.llvm.org/D13071 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/MiscTidyModule.cpp clang-tidy/misc/NewDeleteOverloadsCheck.cpp clang-tidy/misc/NewDeleteOverloadsCheck.h docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/misc-new-delete-overloads.rst test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp test/clang-tidy/misc-new-delete-overloads.cpp Index: test/clang-tidy/misc-new-delete-overloads.cpp === --- test/clang-tidy/misc-new-delete-overloads.cpp +++ test/clang-tidy/misc-new-delete-overloads.cpp @@ -0,0 +1,77 @@ +// RUN: %python %S/check_clang_tidy.py %s misc-new-delete-overloads %t -- -std=c++14 + +typedef unsigned int size_t; + +struct S { + // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope + void *operator new(size_t size) noexcept; + // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new[]' has no matching declaration of 'operator delete[]' at the same scope + void *operator new[](size_t size) noexcept; +}; + +// CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope +void *operator new(size_t size) noexcept; + +struct T { + // Sized deallocations are not enabled by default, and so this new/delete pair + // does not match. However, we expect only one warning, for the new, because + // the operator delete is a placement delete and we do not warn on mismatching + // placement operations. + // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope + void *operator new(size_t size) noexcept; + void operator delete(void *ptr, size_t) noexcept; // ok only if sized deallocation is enabled +}; + +struct U { + void *operator new(size_t size) noexcept; + void operator delete(void *ptr) noexcept; + + void *operator new[](size_t) noexcept; + void operator delete[](void *) noexcept; +}; + +struct Z { + // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: declaration of 'operator delete' has no matching declaration of 'operator new' at the same scope + void operator delete(void *ptr) noexcept; + // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: declaration of 'operator delete[]' has no matching declaration of 'operator new[]' at the same scope + void operator delete[](void *ptr) noexcept; +}; + +struct A { + void *operator new(size_t size, Z) noexcept; // ok, placement new +}; + +struct B { + void operator delete(void *ptr, A) noexcept; // ok, placement delete +}; + +// It is okay to have a class with an inaccessible free store operator. +struct C { + void *operator new(size_t, A) noexcept; // ok, placement new +private: + void operator delete(void *) noexcept; +}; + +// It is also okay to have a class with a delete free store operator. +struct D { + void *operator new(size_t, A) noexcept; // ok, placement new + void operator delete(void *) noexcept = delete; +}; + +struct E : U { + void *operator new(size_t) noexcept; // okay, we inherit operator delete from U +}; + +struct F : S { + // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope + void *operator new(size_t) noexcept; +}; + +class G { + void operator delete(void *) noexcept; +}; + +struct H : G { + // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope + void *operator new(size_t) noexcept; // base class operator is inaccessible +}; Index: test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp === --- test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp +++ test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp @@ -0,0 +1,20 @@ +// RUN: %python %S/check_clang_tidy.py %s misc-new-delete-overloads %t -- -std=c++14 -fsized-deallocation + +typedef unsigned int size_t; + +struct S { + // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: declaration of 'operator delete' has no matching declaration of 'operator new' at the same scope + void operator delete(void *ptr, size_t) noexcept; // not a placement delete +}; + +struct T { + // Because we have enabled sized deallocations explicitly, this new/delete + // pair matches. + void *operator new(size_t size) noexcept; + void operator delete(void *ptr, size_t) noexcept; // ok because sized deallocation is enabled +}; + +// While we're here, check that global operator delete with no operator new +// is also matched. +// CHECK-MESSAGES: :[[@LINE+1]]:6: warning: declaration of 'operator delete' has no matching declaration of 'operator ne
Re: [PATCH] D13166: Create modernize-make-unique check.
angelgarcia updated this revision to Diff 35873. angelgarcia added a comment. Also replace on aliases. http://reviews.llvm.org/D13166 Files: clang-tidy/modernize/CMakeLists.txt clang-tidy/modernize/MakeUniqueCheck.cpp clang-tidy/modernize/MakeUniqueCheck.h clang-tidy/modernize/ModernizeTidyModule.cpp test/clang-tidy/modernize-make-unique.cpp Index: test/clang-tidy/modernize-make-unique.cpp === --- /dev/null +++ test/clang-tidy/modernize-make-unique.cpp @@ -0,0 +1,122 @@ +// RUN: %python %S/check_clang_tidy.py %s modernize-make-unique %t + +namespace std { + +template +class unique_ptr { +public: + unique_ptr(type *ptr); + unique_ptr(const unique_ptr &t) = delete; + unique_ptr(unique_ptr &&t); + ~unique_ptr(); + type &operator*() { return *ptr; } + type *operator->() { return ptr; } + type *release(); + void reset(); + void reset(type *pt); + +private: + type *ptr; +}; + +} + +struct Base { + Base(); + Base(int, int); +}; + +struct Derived : public Base { + Derived(); + Derived(int, int); +}; + +struct Pair { + int a, b; +}; + +template using unique_ptr_ = std::unique_ptr; + +int g(std::unique_ptr P); + +std::unique_ptr getPointer() { + return std::unique_ptr(new Base); + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use std::make_unique instead + // CHECK-FIXES: return std::make_unique(); +} + +void f() { + std::unique_ptr P1 = std::unique_ptr(new int()); + // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique] + // CHECK-FIXES: std::unique_ptr P1 = std::make_unique(); + + // Without parenthesis. + std::unique_ptr P2 = std::unique_ptr(new int); + // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique] + // CHECK-FIXES: std::unique_ptr P2 = std::make_unique(); + + // With auto. + auto P3 = std::unique_ptr(new int()); + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead + // CHECK-FIXES: auto P3 = std::make_unique(); + + { +// No std. +using namespace std; +unique_ptr Q = unique_ptr(new int()); +// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use std::make_unique instead +// CHECK-FIXES: unique_ptr Q = std::make_unique(); + } + + std::unique_ptr R(new int()); + + // Create the unique_ptr as a parameter to a function. + int T = g(std::unique_ptr(new int())); + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead + // CHECK-FIXES: int T = g(std::make_unique()); + + // Arguments are correctly handled. + std::unique_ptr Pbase = std::unique_ptr(new Base(5, T)); + // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: use std::make_unique instead + // CHECK-FIXES: std::unique_ptr Pbase = std::make_unique(5, T); + + // Works with init lists. + std::unique_ptr Ppair = std::unique_ptr(new Pair{T, 1}); + // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: use std::make_unique instead + // CHECK-FIXES: std::unique_ptr Ppair = std::make_unique({T, 1}); + + // Only replace if the type in the template is the same than the type returned + // by the new operator. + auto Pderived = std::unique_ptr(new Derived()); + + // The pointer is returned by the function, nothing to do. + std::unique_ptr RetPtr = getPointer(); + + // Aliases. + typedef std::unique_ptr IntPtr; + IntPtr Typedef = IntPtr(new int); + // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use std::make_unique instead + // CHECK-FIXES: IntPtr Typedef = std::make_unique(); + +#define PTR unique_ptr + std::unique_ptr Macro = std::PTR(new int); + // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use std::make_unique instead + // CHECK-FIXES: std::unique_ptr Macro = std::make_unique(); +#undef PTR + + std::unique_ptr Using = unique_ptr_(new int); + // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use std::make_unique instead + // CHECK-FIXES: std::unique_ptr Using = std::make_unique(); + + // This emulates std::move. + std::unique_ptr Move = static_cast&&>(P1); + + // Adding whitespaces. + auto Space = std::unique_ptr (new int()); + // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use std::make_unique instead + // CHECK-FIXES: auto Space = std::make_unique(); + + auto Spaces = std ::unique_ptr (new int()); + // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use std::make_unique instead + // CHECK-FIXES: auto Spaces = std::make_unique(); +} Index: clang-tidy/modernize/ModernizeTidyModule.cpp === --- clang-tidy/modernize/ModernizeTidyModule.cpp +++ clang-tidy/modernize/ModernizeTidyModule.cpp @@ -11,6 +11,7 @@ #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" #include "LoopConvertCheck.h" +#include "MakeUniqueCheck.h" #include "PassByValueCheck.h" #include "ReplaceAutoPtrCheck.h" #include "ShrinkToFitCheck.h" @@ -28,6 +29,8 @@ public: void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { CheckFa
Re: [PATCH] D12945: [PATCH] Add checker for objects that should not be value types
aaron.ballman added inline comments. Comment at: clang-tidy/misc/NonCopyableObjects.cpp:21 @@ +20,3 @@ + static const char *TypeNames[] = { +"::pthread_cond_t", +"::pthread_mutex_t", alexfh wrote: > How about making these lists configurable or adding a list for custom type > names that should be checked in a similar way? Do we have a helper function for making lists like these configurable? If so, I'll gladly use it. If not, perhaps we could make some helper functionality and then implement configurability at that time in a more comprehensive way? Comment at: clang-tidy/misc/NonCopyableObjects.cpp:81 @@ +80,3 @@ + if (D && BD) +diag(D->getLocation(), "'%0' declared as type '%1'; did you mean '%1 *'?") +<< D->getName() << BD->getName(); alexfh wrote: > I think, error messages should contain some explanation of why is this wrong. > Not sure if this can be fit into a reasonable number of words, but we have to > try. Excellent point! How about: '%0' declared as unsafely-copyable type '%1'; did you mean '%1 *' or '%0' declared as type '%1', which is unsafe to copy' did you mean '%1 *'? http://reviews.llvm.org/D12945 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13071: [PATCH] New checker for mismatched operator new/operator delete definitions
alexfh added inline comments. Comment at: clang-tidy/misc/NewDeleteOverloadsCheck.cpp:66 @@ +65,3 @@ +namespace { +OverloadedOperatorKind GetCorrespondingOverload(const FunctionDecl *FD) { + switch (FD->getOverloadedOperator()) { http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly > Function names [...] should be camel case, and start with a lower case letter > (e.g. openFile() or isFoo()). Comment at: clang-tidy/misc/NewDeleteOverloadsCheck.cpp:168 @@ +167,3 @@ + SmallVector Diagnose; + for (const auto *O : Overloads) { +const auto &OI = std::find_if( Please don't use "O", "l", "I" as variable names. Comment at: clang-tidy/misc/NewDeleteOverloadsCheck.cpp:170 @@ +169,3 @@ +const auto &OI = std::find_if( +Overloads.begin(), Overloads.end(), [&](const FunctionDecl *FD) { + if (FD == O) I just noticed that this will be an O(N^2) from all new/delete overloads in all classes in a TU. This should probably be not much usually, but I can imagine a corner-case, where this is going to be slooow. How about sharding these by the enclosing record declaration? Comment at: test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp:6 @@ +5,3 @@ +struct S { + // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: declaration of 'operator delete' has no matching declaration of 'operator new' at the same scope + void operator delete(void *ptr, size_t) noexcept; // not a placement delete nit: Let's include the check name in brackets to the check pattern once. http://reviews.llvm.org/D13071 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12945: [PATCH] Add checker for objects that should not be value types
alexfh added inline comments. Comment at: clang-tidy/misc/NonCopyableObjects.cpp:21 @@ +20,3 @@ + static const char *TypeNames[] = { +"::pthread_cond_t", +"::pthread_mutex_t", aaron.ballman wrote: > alexfh wrote: > > How about making these lists configurable or adding a list for custom type > > names that should be checked in a similar way? > Do we have a helper function for making lists like these configurable? If so, > I'll gladly use it. If not, perhaps we could make some helper functionality > and then implement configurability at that time in a more comprehensive way? I tried to make clang-tidy checks configurable in a more type-safe way (http://reviews.llvm.org/D5602), but never got time to complete this. So no, currently we don't have any facilities to make this kind of configuration easier. Making these lists configurable is also not a precondition to submitting this patch. It was just an idea of an improvement. Comment at: clang-tidy/misc/NonCopyableObjects.cpp:81 @@ +80,3 @@ + if (D && BD) +diag(D->getLocation(), "'%0' declared as type '%1'; did you mean '%1 *'?") +<< D->getName() << BD->getName(); aaron.ballman wrote: > alexfh wrote: > > I think, error messages should contain some explanation of why is this > > wrong. Not sure if this can be fit into a reasonable number of words, but > > we have to try. > Excellent point! How about: > > '%0' declared as unsafely-copyable type '%1'; did you mean '%1 *' > > or > > '%0' declared as type '%1', which is unsafe to copy' did you mean '%1 *'? The latter seems easier to read. Thanks! http://reviews.llvm.org/D12945 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13071: [PATCH] New checker for mismatched operator new/operator delete definitions
aaron.ballman added a comment. Thank you for the review! Comment at: clang-tidy/misc/NewDeleteOverloadsCheck.cpp:66 @@ +65,3 @@ +namespace { +OverloadedOperatorKind GetCorrespondingOverload(const FunctionDecl *FD) { + switch (FD->getOverloadedOperator()) { alexfh wrote: > http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly > > > Function names [...] should be camel case, and start with a lower case > > letter (e.g. openFile() or isFoo()). Ugh, I always get this backwards because of other parts of the code base that didn't follow the convention. I'll fix. Comment at: clang-tidy/misc/NewDeleteOverloadsCheck.cpp:168 @@ +167,3 @@ + SmallVector Diagnose; + for (const auto *O : Overloads) { +const auto &OI = std::find_if( alexfh wrote: > Please don't use "O", "l", "I" as variable names. I thought this was the correct style for identifiers that do not require descriptive names (we use it *everywhere* in Clang)? I'm not opposed, but I am wondering if clang-tidy has different style guides? Comment at: clang-tidy/misc/NewDeleteOverloadsCheck.cpp:170 @@ +169,3 @@ +const auto &OI = std::find_if( +Overloads.begin(), Overloads.end(), [&](const FunctionDecl *FD) { + if (FD == O) alexfh wrote: > I just noticed that this will be an O(N^2) from all new/delete overloads in > all classes in a TU. This should probably be not much usually, but I can > imagine a corner-case, where this is going to be slooow. How about sharding > these by the enclosing record declaration? Yes, the O(N^2) is unfortunate, sorry for not calling that out explicitly. I figured that N should be incredibly minimal, however (especially since we only care about *written* overloads that are not placement overloads). So realistically, the maximum that N can be here is 6: operator new(), operator new[](), operator delete(), operator delete[](), and sized operator delete()/operator delete[](). I figured that this wasn't worth complicating the code over since N is bounded. But I suppose the worry is if you have these operators defined in a a lot of classes in the same TU? In that case, I suppose I could replace SmallVector Overloads with MapVector Overloads? Comment at: test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp:6 @@ +5,3 @@ +struct S { + // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: declaration of 'operator delete' has no matching declaration of 'operator new' at the same scope + void operator delete(void *ptr, size_t) noexcept; // not a placement delete alexfh wrote: > nit: Let's include the check name in brackets to the check pattern once. Can do! http://reviews.llvm.org/D13071 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13071: [PATCH] New checker for mismatched operator new/operator delete definitions
alexfh added inline comments. Comment at: clang-tidy/misc/NewDeleteOverloadsCheck.cpp:168 @@ +167,3 @@ + SmallVector Diagnose; + for (const auto *O : Overloads) { +const auto &OI = std::find_if( aaron.ballman wrote: > alexfh wrote: > > Please don't use "O", "l", "I" as variable names. > I thought this was the correct style for identifiers that do not require > descriptive names (we use it *everywhere* in Clang)? I'm not opposed, but I > am wondering if clang-tidy has different style guides? I'm not opposed to single-character identifiers, as long as they don't use characters that are indistinguishable from some other characters in some fonts. E.g. I don't want ever to be confused about `map[O]` vs `map[0]` (same for "l", "I", and sometimes even "1"). Comment at: clang-tidy/misc/NewDeleteOverloadsCheck.cpp:170 @@ +169,3 @@ +const auto &OI = std::find_if( +Overloads.begin(), Overloads.end(), [&](const FunctionDecl *FD) { + if (FD == O) aaron.ballman wrote: > alexfh wrote: > > I just noticed that this will be an O(N^2) from all new/delete overloads in > > all classes in a TU. This should probably be not much usually, but I can > > imagine a corner-case, where this is going to be slooow. How about sharding > > these by the enclosing record declaration? > Yes, the O(N^2) is unfortunate, sorry for not calling that out explicitly. I > figured that N should be incredibly minimal, however (especially since we > only care about *written* overloads that are not placement overloads). So > realistically, the maximum that N can be here is 6: operator new(), operator > new[](), operator delete(), operator delete[](), and sized operator > delete()/operator delete[](). I figured that this wasn't worth complicating > the code over since N is bounded. > > But I suppose the worry is if you have these operators defined in a a lot of > classes in the same TU? In that case, I suppose I could replace > SmallVector Overloads with MapVector FunctionDecl *> Overloads? > But I suppose the worry is if you have these operators defined in a a lot of > classes in the same TU? In that case, I suppose I could replace > SmallVector Overloads with MapVector *, FunctionDecl *> Overloads? Yes, this is what I meant. Though I didn't know about `MapVector<>` before you told me ;) http://reviews.llvm.org/D13071 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13071: [PATCH] New checker for mismatched operator new/operator delete definitions
aaron.ballman added inline comments. Comment at: clang-tidy/misc/NewDeleteOverloadsCheck.cpp:168 @@ +167,3 @@ + SmallVector Diagnose; + for (const auto *O : Overloads) { +const auto &OI = std::find_if( alexfh wrote: > aaron.ballman wrote: > > alexfh wrote: > > > Please don't use "O", "l", "I" as variable names. > > I thought this was the correct style for identifiers that do not require > > descriptive names (we use it *everywhere* in Clang)? I'm not opposed, but I > > am wondering if clang-tidy has different style guides? > I'm not opposed to single-character identifiers, as long as they don't use > characters that are indistinguishable from some other characters in some > fonts. E.g. I don't want ever to be confused about `map[O]` vs `map[0]` (same > for "l", "I", and sometimes even "1"). Ah, this makes perfect sense. Can do. :-) http://reviews.llvm.org/D13071 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13071: [PATCH] New checker for mismatched operator new/operator delete definitions
aaron.ballman added inline comments. Comment at: clang-tidy/misc/NewDeleteOverloadsCheck.cpp:170 @@ +169,3 @@ +const auto &OI = std::find_if( +Overloads.begin(), Overloads.end(), [&](const FunctionDecl *FD) { + if (FD == O) alexfh wrote: > aaron.ballman wrote: > > alexfh wrote: > > > I just noticed that this will be an O(N^2) from all new/delete overloads > > > in all classes in a TU. This should probably be not much usually, but I > > > can imagine a corner-case, where this is going to be slooow. How about > > > sharding these by the enclosing record declaration? > > Yes, the O(N^2) is unfortunate, sorry for not calling that out explicitly. > > I figured that N should be incredibly minimal, however (especially since we > > only care about *written* overloads that are not placement overloads). So > > realistically, the maximum that N can be here is 6: operator new(), > > operator new[](), operator delete(), operator delete[](), and sized > > operator delete()/operator delete[](). I figured that this wasn't worth > > complicating the code over since N is bounded. > > > > But I suppose the worry is if you have these operators defined in a a lot > > of classes in the same TU? In that case, I suppose I could replace > > SmallVector Overloads with MapVector > FunctionDecl *> Overloads? > > But I suppose the worry is if you have these operators defined in a a lot > > of > > classes in the same TU? In that case, I suppose I could replace > > SmallVector Overloads with MapVector > *, FunctionDecl *> Overloads? > > Yes, this is what I meant. Though I didn't know about `MapVector<>` before > you told me ;) Er, not MapVector, but perhaps a std::map>, I guess. http://reviews.llvm.org/D13071 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang-tools-extra] r248438 - Fix loop-convert for trivially copyable types.
Yes that's already planned. On Mon, Sep 28, 2015, 5:10 PM David Blaikie wrote: > On Sat, Sep 26, 2015 at 11:21 PM, Manuel Klimek via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Yep. We'll make it better by limiting the size, but trivially copyable is >> an improvement, as there are orders of magnitude more loops over small >> copyable types than over large ones. >> > > We seem to be growing repeated logic for these rules in many checks > (suggesting pass by value, loop convert, maybe others) - could we > centralize these rules somewhere so we apply consistent logic in all of > them? (& call out any necessary variation there) > > >> >> On Sat, Sep 26, 2015, 9:02 PM comex wrote: >> >>> On Thu, Sep 24, 2015 at 7:28 AM, Manuel Klimek via cfe-commits >>> wrote: >>> > Fix loop-convert for trivially copyable types. >>> >>> If I'm not misunderstanding the patch, "trivially copyable" by itself >>> seems like a suboptimal test. After all, "trivial" can still include >>> an expensive memcpy of a large struct. >>> >> >> ___ >> 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
Re: [PATCH] D13071: [PATCH] New checker for mismatched operator new/operator delete definitions
aaron.ballman updated this revision to Diff 35881. aaron.ballman added a comment. Addressing review comments. http://reviews.llvm.org/D13071 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/MiscTidyModule.cpp clang-tidy/misc/NewDeleteOverloadsCheck.cpp clang-tidy/misc/NewDeleteOverloadsCheck.h docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/misc-new-delete-overloads.rst test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp test/clang-tidy/misc-new-delete-overloads.cpp Index: test/clang-tidy/misc-new-delete-overloads.cpp === --- test/clang-tidy/misc-new-delete-overloads.cpp +++ test/clang-tidy/misc-new-delete-overloads.cpp @@ -0,0 +1,77 @@ +// RUN: %python %S/check_clang_tidy.py %s misc-new-delete-overloads %t -- -std=c++14 + +typedef unsigned int size_t; + +struct S { + // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope [misc-new-delete-overloads] + void *operator new(size_t size) noexcept; + // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new[]' has no matching declaration of 'operator delete[]' at the same scope + void *operator new[](size_t size) noexcept; +}; + +// CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope +void *operator new(size_t size) noexcept; + +struct T { + // Sized deallocations are not enabled by default, and so this new/delete pair + // does not match. However, we expect only one warning, for the new, because + // the operator delete is a placement delete and we do not warn on mismatching + // placement operations. + // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope + void *operator new(size_t size) noexcept; + void operator delete(void *ptr, size_t) noexcept; // ok only if sized deallocation is enabled +}; + +struct U { + void *operator new(size_t size) noexcept; + void operator delete(void *ptr) noexcept; + + void *operator new[](size_t) noexcept; + void operator delete[](void *) noexcept; +}; + +struct Z { + // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: declaration of 'operator delete' has no matching declaration of 'operator new' at the same scope + void operator delete(void *ptr) noexcept; + // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: declaration of 'operator delete[]' has no matching declaration of 'operator new[]' at the same scope + void operator delete[](void *ptr) noexcept; +}; + +struct A { + void *operator new(size_t size, Z) noexcept; // ok, placement new +}; + +struct B { + void operator delete(void *ptr, A) noexcept; // ok, placement delete +}; + +// It is okay to have a class with an inaccessible free store operator. +struct C { + void *operator new(size_t, A) noexcept; // ok, placement new +private: + void operator delete(void *) noexcept; +}; + +// It is also okay to have a class with a delete free store operator. +struct D { + void *operator new(size_t, A) noexcept; // ok, placement new + void operator delete(void *) noexcept = delete; +}; + +struct E : U { + void *operator new(size_t) noexcept; // okay, we inherit operator delete from U +}; + +struct F : S { + // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope + void *operator new(size_t) noexcept; +}; + +class G { + void operator delete(void *) noexcept; +}; + +struct H : G { + // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope + void *operator new(size_t) noexcept; // base class operator is inaccessible +}; Index: test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp === --- test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp +++ test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp @@ -0,0 +1,20 @@ +// RUN: %python %S/check_clang_tidy.py %s misc-new-delete-overloads %t -- -std=c++14 -fsized-deallocation + +typedef unsigned int size_t; + +struct S { + // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: declaration of 'operator delete' has no matching declaration of 'operator new' at the same scope [misc-new-delete-overloads] + void operator delete(void *ptr, size_t) noexcept; // not a placement delete +}; + +struct T { + // Because we have enabled sized deallocations explicitly, this new/delete + // pair matches. + void *operator new(size_t size) noexcept; + void operator delete(void *ptr, size_t) noexcept; // ok because sized deallocation is enabled +}; + +// While we're here, check that global operator delete with no operator new +// is also matched. +// CHECK-MESSAGES: :[[@LINE+1]]:6: warning: declaration of 'operator delete' has no matchi
Re: [PATCH] D13071: [PATCH] New checker for mismatched operator new/operator delete definitions
aaron.ballman marked 4 inline comments as done. aaron.ballman added a comment. http://reviews.llvm.org/D13071 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13071: [PATCH] New checker for mismatched operator new/operator delete definitions
alexfh added inline comments. Comment at: clang-tidy/misc/NewDeleteOverloadsCheck.cpp:170 @@ +169,3 @@ +const auto &OI = std::find_if( +Overloads.begin(), Overloads.end(), [&](const FunctionDecl *FD) { + if (FD == O) aaron.ballman wrote: > alexfh wrote: > > aaron.ballman wrote: > > > alexfh wrote: > > > > I just noticed that this will be an O(N^2) from all new/delete > > > > overloads in all classes in a TU. This should probably be not much > > > > usually, but I can imagine a corner-case, where this is going to be > > > > slooow. How about sharding these by the enclosing record declaration? > > > Yes, the O(N^2) is unfortunate, sorry for not calling that out > > > explicitly. I figured that N should be incredibly minimal, however > > > (especially since we only care about *written* overloads that are not > > > placement overloads). So realistically, the maximum that N can be here is > > > 6: operator new(), operator new[](), operator delete(), operator > > > delete[](), and sized operator delete()/operator delete[](). I figured > > > that this wasn't worth complicating the code over since N is bounded. > > > > > > But I suppose the worry is if you have these operators defined in a a lot > > > of classes in the same TU? In that case, I suppose I could replace > > > SmallVector Overloads with MapVector > > FunctionDecl *> Overloads? > > > But I suppose the worry is if you have these operators defined in a a lot > > > of > > > classes in the same TU? In that case, I suppose I could replace > > > SmallVector Overloads with MapVector > > *, FunctionDecl *> Overloads? > > > > Yes, this is what I meant. Though I didn't know about `MapVector<>` before > > you told me ;) > Er, not MapVector, but perhaps a std::map std::vector>, I guess. Might be a `DenseMap>` as well. Or `std::map<..., SmallVector<,>>`. http://reviews.llvm.org/D13071 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13071: [PATCH] New checker for mismatched operator new/operator delete definitions
On Mon, Sep 28, 2015 at 12:36 PM, Alexander Kornienko via cfe-commits wrote: > alexfh added inline comments. > > > Comment at: clang-tidy/misc/NewDeleteOverloadsCheck.cpp:170 > @@ +169,3 @@ > +const auto &OI = std::find_if( > +Overloads.begin(), Overloads.end(), [&](const FunctionDecl *FD) { > + if (FD == O) > > aaron.ballman wrote: >> alexfh wrote: >> > aaron.ballman wrote: >> > > alexfh wrote: >> > > > I just noticed that this will be an O(N^2) from all new/delete >> > > > overloads in all classes in a TU. This should probably be not much >> > > > usually, but I can imagine a corner-case, where this is going to be >> > > > slooow. How about sharding these by the enclosing record declaration? >> > > Yes, the O(N^2) is unfortunate, sorry for not calling that out >> > > explicitly. I figured that N should be incredibly minimal, however >> > > (especially since we only care about *written* overloads that are not >> > > placement overloads). So realistically, the maximum that N can be here >> > > is 6: operator new(), operator new[](), operator delete(), operator >> > > delete[](), and sized operator delete()/operator delete[](). I figured >> > > that this wasn't worth complicating the code over since N is bounded. >> > > >> > > But I suppose the worry is if you have these operators defined in a a >> > > lot of classes in the same TU? In that case, I suppose I could replace >> > > SmallVector Overloads with MapVector> > > FunctionDecl *> Overloads? >> > > But I suppose the worry is if you have these operators defined in a a >> > > lot of >> > > classes in the same TU? In that case, I suppose I could replace >> > > SmallVector Overloads with MapVector> > > *, FunctionDecl *> Overloads? >> > >> > Yes, this is what I meant. Though I didn't know about `MapVector<>` before >> > you told me ;) >> Er, not MapVector, but perhaps a std::map> std::vector>, I guess. > Might be a `DenseMap>` as > well. Or `std::map<..., SmallVector<,>>`. I wound up going with std::map and llvm::SmallVector. The values seem too expensive for a DenseMap, but the lists should definitely be small. ~Aaron > > > http://reviews.llvm.org/D13071 > > > > ___ > 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] D13217: The Driver does not set the +strict-align flag when targeting armv6m + netbsd
labrinea created this revision. labrinea added reviewers: cfe-commits, rengolin. Herald added subscribers: rengolin, aemerson. Tests are misssing for armv6m + darwin as well. http://reviews.llvm.org/D13217 Files: lib/Basic/Targets.cpp lib/Driver/Tools.cpp test/Driver/arm-alignment.c Index: test/Driver/arm-alignment.c === --- test/Driver/arm-alignment.c +++ test/Driver/arm-alignment.c @@ -59,6 +59,12 @@ // RUN: %clang -target armv6-unknown-nacl-gnueabihf -### %s 2> %t // RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s +// RUN: %clang -target armv6m-apple-darwin -### %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s + +// RUN: %clang -target armv6m-netbsd-eabi -### %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s + // RUN: %clang -target aarch64-none-gnueabi -mno-unaligned-access -### %s 2> %t // RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -834,7 +834,8 @@ // The above behavior is consistent with GCC. int VersionNum = getARMSubArchVersionNumber(Triple); if (Triple.isOSDarwin() || Triple.isOSNetBSD()) { - if (VersionNum < 6) + if (VersionNum < 6 || + Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m) Features.push_back("+strict-align"); } else if (Triple.isOSLinux() || Triple.isOSNaCl()) { if (VersionNum < 7) Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -4453,10 +4453,6 @@ if (Feature[0] == '+') Features[Feature+1] = true; -if (ArchVersion < 6 || - (ArchVersion == 6 && ArchProfile == llvm::ARM::PK_M)) - Features["strict-align"] = true; - return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec); } Index: test/Driver/arm-alignment.c === --- test/Driver/arm-alignment.c +++ test/Driver/arm-alignment.c @@ -59,6 +59,12 @@ // RUN: %clang -target armv6-unknown-nacl-gnueabihf -### %s 2> %t // RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s +// RUN: %clang -target armv6m-apple-darwin -### %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s + +// RUN: %clang -target armv6m-netbsd-eabi -### %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s + // RUN: %clang -target aarch64-none-gnueabi -mno-unaligned-access -### %s 2> %t // RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -834,7 +834,8 @@ // The above behavior is consistent with GCC. int VersionNum = getARMSubArchVersionNumber(Triple); if (Triple.isOSDarwin() || Triple.isOSNetBSD()) { - if (VersionNum < 6) + if (VersionNum < 6 || + Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m) Features.push_back("+strict-align"); } else if (Triple.isOSLinux() || Triple.isOSNaCl()) { if (VersionNum < 7) Index: lib/Basic/Targets.cpp === --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -4453,10 +4453,6 @@ if (Feature[0] == '+') Features[Feature+1] = true; -if (ArchVersion < 6 || - (ArchVersion == 6 && ArchProfile == llvm::ARM::PK_M)) - Features["strict-align"] = true; - return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12793: Three new overflow builtins with generic argument types
rjmccall added a comment. LGTM, thanks. http://reviews.llvm.org/D12793 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] Change memcpy/memmove/memset to have dest and source alignment
Hey Hal Thanks for the review. I really appreciate it given the scale of this. > On Sep 25, 2015, at 1:13 PM, Hal Finkel wrote: > > Hi Pete, > > Thanks for working on this. > > + class IntegerAlignment { > + private: > +uint64_t Align; > > You explain in the patch summary why this is here, but please add a comment > with the explanation as well. Will do. Good catch. > > Regarding the auto-upgrade, are we going to run into problems if we separate > our the 'volatile' tag for the source and the destination as Lang had > suggested? If we're going to do that, should we do it all at the same time? > Does it change the need for the IntegerAlignment class? Luckily I think this will be easier as its just an addition, unlike this patch which is moving things around to attributes. I’m also pretty confident about using sed to auto-upgrade all the tests with the volatile flag. Its much easier to sed for the ‘i1 [true|false])’ at the end of the call and just duplicate that piece, than it is to extract the alignment out from the middle and print it back out as an attribute. Saying that, there will be similar churn on things like the IRBuilder, and we may want some way to (temporarily at the least) make sure that everyone is forced to consider whether they want to set both isVolatile flags given that they set one of them. A few possibilities are: // Bad, because we don’t know whether current users who set isDestVolatile to true also want source volatility too Create(..., bool isDestVolatile = false, bool isSrcVolatile = false) // Better, all current users will have to change anyway, and then we know they all care about src/dest volatility Create(…, std::pair isDestSrcVolatile = std::pair(false, false)) // Another option, and we would use an assert perhaps to make sure that if dest is set, then so is src Create(…, Optional isDestVolatile = None, Optional isSrcVolatile = None) { assert(isDestVolatile.hasValue() == isSrcVolatile.hasValue()); … Anyway, I think changes can come later, but just a few ideas there. > > Everything else looks good, and I like the cleanup in > AlignmentFromAssumptions :-) Thanks :) Can I take that as a LGTM, or... > > Thanks again, > Hal > > P.S. I find full-context patches in Phabricator much easier than diffs; this > does not matter for the automated regression-test updates, but for the code > changes, I appreciate patches there. … would you prefer to see the patch in phab first? I’m happy either way. I will leave the test case changes here though, and just put the code in phab if needed and if thats ok. Cheers, Pete > > - Original Message - >> From: "Pete Cooper" >> To: "Hal J. Finkel" >> Cc: "Lang Hames" , "LLVM Commits" >> , cfe-commits@lists.llvm.org >> Sent: Friday, August 28, 2015 5:59:18 PM >> Subject: [PATCH] Change memcpy/memmove/memset to have dest and source >> alignment >> >> >> >> Hi Hal/Lang >> >> This came out of a discussion here: >> http://lists.llvm.org/pipermail/llvm-dev/2015-August/089384.html >> >> We want to be able to provide alignment for both the source and dest >> of mem intrinsics, instead of the alignment argument which only >> provides the minimum of dest/src. >> >> Instead of adding another argument, I removed the alignment argument >> and added the align attributes to the src/dest pointer arguments. >> >> I’ve updated the MemIntrinsic definition to handle this, and all of >> the code to now call getDestAlignment/getSrcAlignment instead of >> getAlignment. For the few places where it wasn’t clear whether >> dest/src was the right choice, i’ve left a FIXME and I take the >> minimum of dest/src so as to match the current behavior. >> >> I’ve also updated the create methods in the IR builder. There is a >> (temporary) class there to handle the new source alignment >> parameter, as otherwise existing callers of this code could end up >> having the isVolatile bool implicitly converted to the source >> alignment. I’ll remove this once out-of-tree users have had a chance >> to update to this patch. >> >> Tests were updated to automatically strip out the alignment argument >> (the regex find/replace is in the patch). I then ran make check and >> explicitly added back in alignments to all tests which needed it. I >> tried to automatically update tests to transfer alignment to the >> attributes, but that wasn’t feasible due to constant expressions >> confusing regex (turns out regex doesn’t like recursion, which is >> more or less what you need to get balanced braces in gep(bit >> cast(inttoptr())) type expressions which we have in our tests). >> >> There’s also a commit which shows how auto upgrading bitcode is >> handled. There was already a test for llvm 3.2 which called memcpy >> so is used for this. I’ll add tests to upgrade memmove and memset >> prior to committing but just wanted to get the review process >> started. memmove/memset tests will be almost identical to the memcpy >> test we alread
[clang-tools-extra] r248723 - [clang-tidy] add option to specify build path
Author: papin_g Date: Mon Sep 28 12:53:04 2015 New Revision: 248723 URL: http://llvm.org/viewvc/llvm-project?rev=248723&view=rev Log: [clang-tidy] add option to specify build path Summary: compile_commands.json is usually generated in the build directory. Projects like LLVM/Clang enforce out-of-source builds. This option allow allow such projects to work out of the box, without moving the compilation database manually. The naming of the option is similar to the one use by other tools: clang-{check,modernize,query,rename,tidy} -p= <...> Reviewers: alexfh Differential Revision: http://reviews.llvm.org/D13199 Modified: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py Modified: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py?rev=248723&r1=248722&r2=248723&view=diff == --- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py (original) +++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py Mon Sep 28 12:53:04 2015 @@ -128,10 +128,21 @@ def main(): parser.add_argument('-fix', action='store_true', help='apply fix-its') parser.add_argument('-format', action='store_true', help='Reformat code ' 'after applying fixes') + parser.add_argument('-p', dest='build_path', + help='Path used to read a compile command database.') args = parser.parse_args() + db_path = 'compile_commands.json' + + if args.build_path is not None: +build_path = args.build_path + else: +# Find our database +build_path = find_compilation_database(db_path) + try: invocation = [args.clang_tidy_binary, '-list-checks'] +invocation.append('-p=' + build_path) if args.checks: invocation.append('-checks=' + args.checks) invocation.append('-') @@ -140,10 +151,6 @@ def main(): print >>sys.stderr, "Unable to run clang-tidy." sys.exit(1) - # Find our database. - db_path = 'compile_commands.json' - build_path = find_compilation_database(db_path) - # Load the database and extract all files. database = json.load(open(os.path.join(build_path, db_path))) files = [entry['file'] for entry in database] ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12652: [Static Analyzer] Lambda support.
zaks.anna added a comment. Looks like this patch is causing regressions: https://llvm.org/bugs/show_bug.cgi?id=24914 Repository: rL LLVM http://reviews.llvm.org/D12652 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D13221: Make CompilerInvocation's use of the debug options more understandable.
dougk created this revision. dougk added reviewers: chandlerc, jyknight. dougk added a subscriber: cfe-commits. Both the Driver and the cc1 frontend play games with various combinations of 'g' group options. It would be nice if at least the frontend could be sane, leaving the decision of what OS favors dwarf version N totally in the driver's hands. As such, the Driver never passes a bare '-g' option nor lets the CompilerInvocation assume a default dwarf level. Instead, an explicit choices of debug info kind is conveyed from the driver directly into the CodeGen options, and similarly the dwarf level. At present this breaks hundreds of driver tests because they're looking for particular strings, but if people think this is the right way to do things, those tests can be fixed (and perhaps there's a genuine breakage or two, which must be fixed). http://reviews.llvm.org/D13221 Files: include/clang/Driver/Options.td include/clang/Driver/ToolChain.h lib/Driver/ToolChains.h lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -393,37 +393,47 @@ Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name; } - if (Args.hasArg(OPT_gline_tables_only)) { -Opts.setDebugInfo(CodeGenOptions::DebugLineTablesOnly); - } else if (Args.hasArg(OPT_g_Flag) || Args.hasArg(OPT_gdwarf_2) || - Args.hasArg(OPT_gdwarf_3) || Args.hasArg(OPT_gdwarf_4)) { -bool Default = false; -// Until dtrace (via CTF) and LLDB can deal with distributed debug info, -// Darwin and FreeBSD default to standalone/full debug info. -if (llvm::Triple(TargetOpts.Triple).isOSDarwin() || -llvm::Triple(TargetOpts.Triple).isOSFreeBSD()) - Default = true; - -if (Args.hasFlag(OPT_fstandalone_debug, OPT_fno_standalone_debug, Default)) - Opts.setDebugInfo(CodeGenOptions::FullDebugInfo); -else - Opts.setDebugInfo(CodeGenOptions::LimitedDebugInfo); + // There are three levels of user-requestable debug info (aside from "none", + // and not counting "location tracking only" which isn't user-requested). + // Use the last of the flags that set any of the three interesting levels. + // In the Driver, "limit-debug-info" is synonymous with "no-standalone-debug", + // but the "no" option name is very confusing as part of a multiway switch. + // Read "limit_debug_info" as "LimitedDebugInfo" and it makes perfect sense. + if (Arg *A = Args.getLastArg(OPT_fstandalone_debug, OPT_flimit_debug_info, + OPT_gline_tables_only)) { +enum CodeGenOptions::DebugInfoKind Kind; +switch (A->getOption().getID()) { +case OPT_fstandalone_debug: + Kind = CodeGenOptions::FullDebugInfo; + break; +case OPT_flimit_debug_info: + Kind = CodeGenOptions::LimitedDebugInfo; + break; +default: + Kind = CodeGenOptions::DebugLineTablesOnly; + break; +} +Opts.setDebugInfo(Kind); } - Opts.DebugColumnInfo = Args.hasArg(OPT_dwarf_column_info); - if (Args.hasArg(OPT_gcodeview)) { -Opts.EmitCodeView = true; -Opts.DwarfVersion = 0; - } else if (Opts.getDebugInfo() != CodeGenOptions::NoDebugInfo) { -// Default Dwarf version is 4 if we are generating debug information. -Opts.DwarfVersion = 4; + // Dwarf Version is one of {0,2,3,4}. There is no explicit flag for 0. + // It is the assumed default regardless of whether debug info was requested, + // so the driver had better pick one if debug info is to be produced. + if (Arg *A = Args.getLastArg(OPT_gdwarf_4, OPT_gdwarf_3, OPT_gdwarf_2)) { +switch (A->getOption().getID()) { +case OPT_gdwarf_2: + Opts.DwarfVersion = 2; + break; +case OPT_gdwarf_3: + Opts.DwarfVersion = 3; + break; +default: + Opts.DwarfVersion = 4; + break; +} } + Opts.DebugColumnInfo = Args.hasArg(OPT_dwarf_column_info); + Opts.EmitCodeView = Args.hasArg(OPT_gcodeview); Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file); - if (Args.hasArg(OPT_gdwarf_2)) -Opts.DwarfVersion = 2; - else if (Args.hasArg(OPT_gdwarf_3)) -Opts.DwarfVersion = 3; - else if (Args.hasArg(OPT_gdwarf_4)) -Opts.DwarfVersion = 4; Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs); if (const Arg *A = Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -24,6 +24,7 @@ #include "clang/Driver/SanitizerArgs.h" #include "clang/Driver/ToolChain.h" #include "clang/Driver/Util.h" +#include "clang/Frontend/CodeGenOptions.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" @@ -3797,43 +3798,70 @@ : "-"); } - // Use the l
[clang-tools-extra] r248729 - Fixing a sphinx warning.
Author: aaronballman Date: Mon Sep 28 14:27:37 2015 New Revision: 248729 URL: http://llvm.org/viewvc/llvm-project?rev=248729&view=rev Log: Fixing a sphinx warning. Modified: clang-tools-extra/trunk/docs/modularize.rst Modified: clang-tools-extra/trunk/docs/modularize.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/modularize.rst?rev=248729&r1=248728&r2=248729&view=diff == --- clang-tools-extra/trunk/docs/modularize.rst (original) +++ clang-tools-extra/trunk/docs/modularize.rst Mon Sep 28 14:27:37 2015 @@ -210,7 +210,7 @@ The following module map will be generat An optional ``-root-module=`` option can be used to cause a root module to be created which encloses all the modules. -An optional ``-problem-files-list= can be used to input +An optional ``-problem-files-list=`` can be used to input a list of files to be excluded, perhaps as a temporary stop-gap measure until problem headers can be fixed. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12945: [PATCH] Add checker for objects that should not be value types
aaron.ballman updated this revision to Diff 35900. aaron.ballman marked 2 inline comments as done. aaron.ballman added a comment. Addresses review comments, also adds a documentation file. http://reviews.llvm.org/D12945 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/MiscTidyModule.cpp clang-tidy/misc/NonCopyableObjects.cpp clang-tidy/misc/NonCopyableObjects.h docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/misc-non-copyable-objects.rst test/clang-tidy/misc-non-copyable-objects.cpp Index: test/clang-tidy/misc-non-copyable-objects.cpp === --- test/clang-tidy/misc-non-copyable-objects.cpp +++ test/clang-tidy/misc-non-copyable-objects.cpp @@ -0,0 +1,26 @@ +// RUN: %python %S/check_clang_tidy.py %s misc-non-copyable-objects %t + +namespace std { +typedef struct FILE {} FILE; +} +using namespace std; + +// CHECK-MESSAGES: :[[@LINE+1]]:18: warning: 'f' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'? [misc-non-copyable-objects] +void g(std::FILE f); + +struct S { + // CHECK-MESSAGES: :[[@LINE+1]]:10: warning: 'f' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'? + ::FILE f; +}; + +void func(FILE *f) { + // CHECK-MESSAGES: :[[@LINE+1]]:13: warning: 'f1' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'? + std::FILE f1; // match + // CHECK-MESSAGES: :[[@LINE+2]]:10: warning: 'f2' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'? + // CHECK-MESSAGES: :[[@LINE+1]]:15: warning: expression has suspicious type 'FILE' + ::FILE f2 = *f; // match, match + // CHECK-MESSAGES: :[[@LINE+1]]:15: warning: 'f3' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'? + struct FILE f3; // match + // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: expression has suspicious type 'FILE' + (void)sizeof(*f); // match +} Index: docs/clang-tidy/checks/misc-non-copyable-objects.rst === --- docs/clang-tidy/checks/misc-non-copyable-objects.rst +++ docs/clang-tidy/checks/misc-non-copyable-objects.rst @@ -0,0 +1,6 @@ +misc-non-copyable-objects += + +The check flags dereferences and non-pointer declarations of objects that are +not meant to be passed by value, such as C FILE objects or POSIX +pthread_mutex_t objects. Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -31,6 +31,7 @@ misc-macro-repeated-side-effects misc-move-constructor-init misc-noexcept-move-constructor + misc-non-copyable-objects misc-sizeof-container misc-static-assert misc-swapped-arguments Index: clang-tidy/misc/NonCopyableObjects.h === --- clang-tidy/misc/NonCopyableObjects.h +++ clang-tidy/misc/NonCopyableObjects.h @@ -0,0 +1,31 @@ +//===--- NonCopyableObjects.h - clang-tidy---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTS_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTS_H + +#include "../ClangTidy.h" + +namespace clang { +namespace tidy { + +/// The check flags dereferences and non-pointer declarations of objects that +/// are not meant to be passed by value, such as C FILE objects. +class NonCopyableObjectsCheck : public ClangTidyCheck { +public: + NonCopyableObjectsCheck(StringRef Name, ClangTidyContext *Context) +: ClangTidyCheck(Name, Context) {} + void registerMatchers(ast_matchers::MatchFinder *Finder) override; + void check(const ast_matchers::MatchFinder::MatchResult &Result) override; +}; + +} // namespace tidy +} // namespace clang + +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONCOPYABLEOBJECTS_H Index: clang-tidy/misc/NonCopyableObjects.cpp === --- clang-tidy/misc/NonCopyableObjects.cpp +++ clang-tidy/misc/NonCopyableObjects.cpp @@ -0,0 +1,94 @@ +//===--- NonCopyableObjects.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 "NonCopyableObjects.h" +#include "clang/AST/ASTContext.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include + +using namespace clang::ast_matchers; + +namespace clang { +namespace { +// FIXME: it would be good to make a list that i
Re: [PATCH] D13221: Make CompilerInvocation's use of the debug options more understandable.
dougk added a comment. I think the best thing to do is introduce new cc1 arguments that control the Opts explicitly, and cease accepting the equivalent driver arguments in cc1. I would propose '-gdwarf-version={2|3|4}' and '-gdebug-info-kind={line-tables|limited|full}' http://reviews.llvm.org/D13221 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13171: [CUDA] Added a wrapper header for inclusion of stock CUDA headers.
The (vague) idea was to make clear that the header is *not* part of cuda distribution. That said, the file could use a better name. Do any of these sound better? * fix_cuda_headers.h * adapt_cuda_headers.h * cuda_shim.h --Artem On Sat, Sep 26, 2015 at 12:20 PM, Eric Christopher wrote: > echristo added a comment. > > Bikeshed: it's part of the clang headers, do we really need "clang" in the > header name? > > -eric > > > http://reviews.llvm.org/D13171 > > > > -- --Artem Belevich ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D13223: Generate assume loads only with -fstrict-vtable-pointers
Prazek created this revision. Prazek added reviewers: rsmith, samsonov, majnemer. Prazek added a subscriber: cfe-commits. Temporary fix till InstCombine and other possible passes will be efficient to handle multiple assumes. http://reviews.llvm.org/D13223 Files: lib/CodeGen/CGClass.cpp test/CodeGenCXX/vtable-assume-load.cpp Index: test/CodeGenCXX/vtable-assume-load.cpp === --- test/CodeGenCXX/vtable-assume-load.cpp +++ test/CodeGenCXX/vtable-assume-load.cpp @@ -1,5 +1,6 @@ -// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o %t.ll -O1 -disable-llvm-optzns -fms-extensions -// RUN: %clang_cc1 %s -triple i686-pc-win32 -emit-llvm -o %t.ms.ll -O1 -disable-llvm-optzns -fms-extensions +// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o %t.ll -O1 -disable-llvm-optzns -fms-extensions -fstrict-vtable-pointers +// RUN: %clang_cc1 %s -triple i686-pc-win32 -emit-llvm -o %t.ms.ll -O1 -disable-llvm-optzns -fms-extensions -fstrict-vtable-pointers +// FIXME: Assume load should not require -fstrict-vtable-pointers // RUN: FileCheck --check-prefix=CHECK1 --input-file=%t.ll %s // RUN: FileCheck --check-prefix=CHECK2 --input-file=%t.ll %s Index: lib/CodeGen/CGClass.cpp === --- lib/CodeGen/CGClass.cpp +++ lib/CodeGen/CGClass.cpp @@ -2107,9 +2107,12 @@ // FIXME: If vtable is used by ctor/dtor, or if vtable is external and we are // sure that definition of vtable is not hidden, // then we are always safe to refer to it. + // FIXME: It looks like InstCombine is very inefficient on dealing with + // assumes. Assumption loads requires -fstrict-vtable-pointers temporary. if (CGM.getCodeGenOpts().OptimizationLevel > 0 && ClassDecl->isDynamicClass() && Type != Ctor_Base && - CGM.getCXXABI().canSpeculativelyEmitVTable(ClassDecl)) + CGM.getCXXABI().canSpeculativelyEmitVTable(ClassDecl) && + CGM.getCodeGenOpts().StrictVTablePointers) EmitVTableAssumptionLoads(ClassDecl, This); } Index: test/CodeGenCXX/vtable-assume-load.cpp === --- test/CodeGenCXX/vtable-assume-load.cpp +++ test/CodeGenCXX/vtable-assume-load.cpp @@ -1,5 +1,6 @@ -// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o %t.ll -O1 -disable-llvm-optzns -fms-extensions -// RUN: %clang_cc1 %s -triple i686-pc-win32 -emit-llvm -o %t.ms.ll -O1 -disable-llvm-optzns -fms-extensions +// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o %t.ll -O1 -disable-llvm-optzns -fms-extensions -fstrict-vtable-pointers +// RUN: %clang_cc1 %s -triple i686-pc-win32 -emit-llvm -o %t.ms.ll -O1 -disable-llvm-optzns -fms-extensions -fstrict-vtable-pointers +// FIXME: Assume load should not require -fstrict-vtable-pointers // RUN: FileCheck --check-prefix=CHECK1 --input-file=%t.ll %s // RUN: FileCheck --check-prefix=CHECK2 --input-file=%t.ll %s Index: lib/CodeGen/CGClass.cpp === --- lib/CodeGen/CGClass.cpp +++ lib/CodeGen/CGClass.cpp @@ -2107,9 +2107,12 @@ // FIXME: If vtable is used by ctor/dtor, or if vtable is external and we are // sure that definition of vtable is not hidden, // then we are always safe to refer to it. + // FIXME: It looks like InstCombine is very inefficient on dealing with + // assumes. Assumption loads requires -fstrict-vtable-pointers temporary. if (CGM.getCodeGenOpts().OptimizationLevel > 0 && ClassDecl->isDynamicClass() && Type != Ctor_Base && - CGM.getCXXABI().canSpeculativelyEmitVTable(ClassDecl)) + CGM.getCXXABI().canSpeculativelyEmitVTable(ClassDecl) && + CGM.getCodeGenOpts().StrictVTablePointers) EmitVTableAssumptionLoads(ClassDecl, This); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13223: Generate assume loads only with -fstrict-vtable-pointers
rnk added a subscriber: rnk. rnk accepted this revision. rnk added a reviewer: rnk. rnk added a comment. This revision is now accepted and ready to land. lgtm http://reviews.llvm.org/D13223 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13223: Generate assume loads only with -fstrict-vtable-pointers
echristo added a subscriber: echristo. echristo accepted this revision. echristo added a reviewer: echristo. echristo added a comment. One inline comment reword. Comment at: lib/CodeGen/CGClass.cpp:2111 @@ -2110,1 +2110,3 @@ + // FIXME: It looks like InstCombine is very inefficient on dealing with + // assumes. Assumption loads requires -fstrict-vtable-pointers temporary. if (CGM.getCodeGenOpts().OptimizationLevel > 0 && "Make assumption loads require -fstrict-vtable-pointers temporarily." http://reviews.llvm.org/D13223 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r248734 - Generate assume loads only with -fstrict-vtable-pointers
Author: prazek Date: Mon Sep 28 15:30:22 2015 New Revision: 248734 URL: http://llvm.org/viewvc/llvm-project?rev=248734&view=rev Log: Generate assume loads only with -fstrict-vtable-pointers Temporary fix till InstCombine and other possible passes will be efficient to handle multiple assumes. Modified: cfe/trunk/lib/CodeGen/CGClass.cpp cfe/trunk/test/CodeGenCXX/vtable-assume-load.cpp Modified: cfe/trunk/lib/CodeGen/CGClass.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=248734&r1=248733&r2=248734&view=diff == --- cfe/trunk/lib/CodeGen/CGClass.cpp (original) +++ cfe/trunk/lib/CodeGen/CGClass.cpp Mon Sep 28 15:30:22 2015 @@ -2107,9 +2107,12 @@ void CodeGenFunction::EmitCXXConstructor // FIXME: If vtable is used by ctor/dtor, or if vtable is external and we are // sure that definition of vtable is not hidden, // then we are always safe to refer to it. + // FIXME: It looks like InstCombine is very inefficient on dealing with + // assumes. Make assumption loads require -fstrict-vtable-pointers temporarily. if (CGM.getCodeGenOpts().OptimizationLevel > 0 && ClassDecl->isDynamicClass() && Type != Ctor_Base && - CGM.getCXXABI().canSpeculativelyEmitVTable(ClassDecl)) + CGM.getCXXABI().canSpeculativelyEmitVTable(ClassDecl) && + CGM.getCodeGenOpts().StrictVTablePointers) EmitVTableAssumptionLoads(ClassDecl, This); } Modified: cfe/trunk/test/CodeGenCXX/vtable-assume-load.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vtable-assume-load.cpp?rev=248734&r1=248733&r2=248734&view=diff == --- cfe/trunk/test/CodeGenCXX/vtable-assume-load.cpp (original) +++ cfe/trunk/test/CodeGenCXX/vtable-assume-load.cpp Mon Sep 28 15:30:22 2015 @@ -1,5 +1,6 @@ -// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o %t.ll -O1 -disable-llvm-optzns -fms-extensions -// RUN: %clang_cc1 %s -triple i686-pc-win32 -emit-llvm -o %t.ms.ll -O1 -disable-llvm-optzns -fms-extensions +// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o %t.ll -O1 -disable-llvm-optzns -fms-extensions -fstrict-vtable-pointers +// RUN: %clang_cc1 %s -triple i686-pc-win32 -emit-llvm -o %t.ms.ll -O1 -disable-llvm-optzns -fms-extensions -fstrict-vtable-pointers +// FIXME: Assume load should not require -fstrict-vtable-pointers // RUN: FileCheck --check-prefix=CHECK1 --input-file=%t.ll %s // RUN: FileCheck --check-prefix=CHECK2 --input-file=%t.ll %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12652: [Static Analyzer] Lambda support.
xazax.hun added a comment. I will look into it. Do you prefer to revert the patch this it is fixed? Repository: rL LLVM http://reviews.llvm.org/D12652 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13190: Addition of interfaces the FE to conform to Table A-2 of ELF V2 ABI V1.1
wschmidt accepted this revision. wschmidt added a comment. This revision is now accepted and ready to land. Sorry, forgot to accept. Repository: rL LLVM http://reviews.llvm.org/D13190 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D13228: clang-format: Extend #include sorting functionality
djasper created this revision. djasper added a reviewer: klimek. djasper added a subscriber: cfe-commits. Herald added a subscriber: klimek. Recognize main module header as well as different #include categories. This should now mimic the behavior of llvm/utils/sort_includes.py as well as clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp very closely. http://reviews.llvm.org/D13228 Files: include/clang/Format/Format.h lib/Format/Format.cpp tools/clang-format/ClangFormat.cpp unittests/Format/SortIncludesTest.cpp Index: unittests/Format/SortIncludesTest.cpp === --- unittests/Format/SortIncludesTest.cpp +++ unittests/Format/SortIncludesTest.cpp @@ -20,13 +20,15 @@ class SortIncludesTest : public ::testing::Test { protected: - std::string sort(llvm::StringRef Code) { + std::string sort(llvm::StringRef Code, StringRef FileName = "input.cpp") { std::vector Ranges(1, tooling::Range(0, Code.size())); -std::string Sorted = applyAllReplacements( -Code, sortIncludes(getLLVMStyle(), Code, Ranges, "input.cpp")); -return applyAllReplacements( -Sorted, reformat(getLLVMStyle(), Sorted, Ranges, "input.cpp")); +std::string Sorted = +applyAllReplacements(Code, sortIncludes(Style, Code, Ranges, FileName)); +return applyAllReplacements(Sorted, +reformat(Style, Sorted, Ranges, FileName)); } + + FormatStyle Style = getLLVMStyle(); }; TEST_F(SortIncludesTest, BasicSorting) { @@ -76,13 +78,23 @@ "#include \"c.h\"\n" "\n" "#include \"b.h\"\n", -sort("#include \"c.h\"\n" - "#include \"a.h\"\n" +sort("#include \"a.h\"\n" + "#include \"c.h\"\n" "\n" "#include \"b.h\"\n")); } TEST_F(SortIncludesTest, HandlesAngledIncludesAsSeparateBlocks) { + EXPECT_EQ("#include \"a.h\"\n" +"#include \"c.h\"\n" +"#include \n" +"#include \n", +sort("#include \n" + "#include \n" + "#include \"c.h\"\n" + "#include \"a.h\"\n")); + + Style = getGoogleStyle(FormatStyle::LK_Cpp); EXPECT_EQ("#include \n" "#include \n" "#include \"a.h\"\n" @@ -103,6 +115,24 @@ "#include \"b.h\"\n")); } +TEST_F(SortIncludesTest, LeavesMainHeaderFirst) { + EXPECT_EQ("#include \"llvm/a.h\"\n" +"#include \"b.h\"\n" +"#include \"c.h\"\n", +sort("#include \"llvm/a.h\"\n" + "#include \"c.h\"\n" + "#include \"b.h\"\n")); + + // Don't do this in headers. + EXPECT_EQ("#include \"b.h\"\n" +"#include \"c.h\"\n" +"#include \"llvm/a.h\"\n", +sort("#include \"llvm/a.h\"\n" + "#include \"c.h\"\n" + "#include \"b.h\"\n", + "some_header.h")); +} + } // end namespace } // end namespace format } // end namespace clang Index: tools/clang-format/ClangFormat.cpp === --- tools/clang-format/ClangFormat.cpp +++ tools/clang-format/ClangFormat.cpp @@ -73,7 +73,7 @@ cl::init("LLVM"), cl::cat(ClangFormatCategory)); static cl::opt -AssumeFilename("assume-filename", +AssumeFileName("assume-filename", cl::desc("When reading from stdin, clang-format assumes this\n" "filename to look for a style config file (with\n" "-style=file) and to determine the language."), @@ -239,13 +239,13 @@ std::vector Ranges; if (fillRanges(Code.get(), Ranges)) return true; - FormatStyle FormatStyle = getStyle( - Style, (FileName == "-") ? AssumeFilename : FileName, FallbackStyle); + StringRef AssumedFileName = (FileName == "-") ? AssumeFileName : FileName; + FormatStyle FormatStyle = getStyle(Style, AssumedFileName, FallbackStyle); Replacements Replaces; std::string ChangedCode; if (SortIncludes) { Replaces = -sortIncludes(FormatStyle, Code->getBuffer(), Ranges, FileName); +sortIncludes(FormatStyle, Code->getBuffer(), Ranges, AssumedFileName); ChangedCode = tooling::applyAllReplacements(Code->getBuffer(), Replaces); for (const auto &R : Replaces) Ranges.push_back({R.getOffset(), R.getLength()}); @@ -324,7 +324,7 @@ if (DumpConfig) { std::string Config = clang::format::configurationAsText(clang::format::getStyle( -Style, FileNames.empty() ? AssumeFilename : FileNames[0], +Style, FileNames.empty() ? AssumeFileName : FileNames[0], FallbackStyle)); llvm::outs() << Config << "\n"; return 0; Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -13,15 +13,15 @@ ///
[PATCH] D13229: Add -Wc, option
hintonda created this revision. hintonda added a subscriber: cfe-commits. Add -Wc, option (similar to -Wl,) to go along with -Xclang. This makes it easier to pass multiple options to cc1. http://reviews.llvm.org/D13229 Files: include/clang/Driver/Options.td lib/Driver/Tools.cpp Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -5080,9 +5080,9 @@ A->claim(); } - // Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option - // parser. - Args.AddAllArgValues(CmdArgs, options::OPT_Xclang); + // Forward -Xclang, and -Wc, arguments to -cc1, and -mllvm arguments to the + // LLVM option parser. + Args.AddAllArgValues(CmdArgs, options::OPT_Xclang, options::OPT_Wc_COMMA); for (const Arg *A : Args.filtered(options::OPT_mllvm)) { A->claim(); Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -298,6 +298,9 @@ def Wdeprecated : Flag<["-"], "Wdeprecated">, Group, Flags<[CC1Option]>; def Wno_deprecated : Flag<["-"], "Wno-deprecated">, Group, Flags<[CC1Option]>; def Wextra : Flag<["-"], "Wextra">, Group, Flags<[CC1Option]>; +def Wc_COMMA : CommaJoined<["-"], "Wc,">, Flags<[DriverOption, CoreOption]>, + HelpText<"Pass the comma separated arguments in to the clang compiler">, + MetaVarName<"">; def Wl_COMMA : CommaJoined<["-"], "Wl,">, Flags<[LinkerInput, RenderAsInput]>, HelpText<"Pass the comma separated arguments in to the linker">, MetaVarName<"">; Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -5080,9 +5080,9 @@ A->claim(); } - // Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option - // parser. - Args.AddAllArgValues(CmdArgs, options::OPT_Xclang); + // Forward -Xclang, and -Wc, arguments to -cc1, and -mllvm arguments to the + // LLVM option parser. + Args.AddAllArgValues(CmdArgs, options::OPT_Xclang, options::OPT_Wc_COMMA); for (const Arg *A : Args.filtered(options::OPT_mllvm)) { A->claim(); Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -298,6 +298,9 @@ def Wdeprecated : Flag<["-"], "Wdeprecated">, Group, Flags<[CC1Option]>; def Wno_deprecated : Flag<["-"], "Wno-deprecated">, Group, Flags<[CC1Option]>; def Wextra : Flag<["-"], "Wextra">, Group, Flags<[CC1Option]>; +def Wc_COMMA : CommaJoined<["-"], "Wc,">, Flags<[DriverOption, CoreOption]>, + HelpText<"Pass the comma separated arguments in to the clang compiler">, + MetaVarName<"">; def Wl_COMMA : CommaJoined<["-"], "Wl,">, Flags<[LinkerInput, RenderAsInput]>, HelpText<"Pass the comma separated arguments in to the linker">, MetaVarName<"">; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13229: Add -Wc, option
On Mon, Sep 28, 2015 at 09:54:53PM +, don hinton via cfe-commits wrote: > Add -Wc, option (similar to -Wl,) to go along with -Xclang. > This makes it easier to pass multiple options to cc1. How is this better than -mllvm and -Xclang? There is no precendence case for this with GCC really and I don't see a good reason for wanting this, frankly. Joerg ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r248753 - [CUDA] 32-bit NVPTX should have 32-bit long type.
Author: tra Date: Mon Sep 28 17:54:08 2015 New Revision: 248753 URL: http://llvm.org/viewvc/llvm-project?rev=248753&view=rev Log: [CUDA] 32-bit NVPTX should have 32-bit long type. Currently it's 64-bit which will lead to mismatch between host and device code if we compile for i386. Differential Revision: http://reviews.llvm.org/D13181 Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/CodeGen/builtins-nvptx.c cfe/trunk/test/CodeGen/nvptx-inlineasm-ptx.c cfe/trunk/test/Preprocessor/init.c Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def?rev=248753&r1=248752&r2=248753&view=diff == --- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def Mon Sep 28 17:54:08 2015 @@ -50,7 +50,7 @@ BUILTIN(__builtin_ptx_read_lanemask_ge, BUILTIN(__builtin_ptx_read_lanemask_gt, "i", "nc") BUILTIN(__builtin_ptx_read_clock, "i", "n") -BUILTIN(__builtin_ptx_read_clock64, "Li", "n") +BUILTIN(__builtin_ptx_read_clock64, "LLi", "n") BUILTIN(__builtin_ptx_read_pm0, "i", "n") BUILTIN(__builtin_ptx_read_pm1, "i", "n") Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=248753&r1=248752&r2=248753&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Mon Sep 28 17:54:08 2015 @@ -1716,6 +1716,7 @@ void NVPTXTargetInfo::getGCCRegNames(con class NVPTX32TargetInfo : public NVPTXTargetInfo { public: NVPTX32TargetInfo(const llvm::Triple &Triple) : NVPTXTargetInfo(Triple) { +LongWidth = LongAlign = 32; PointerWidth = PointerAlign = 32; SizeType = TargetInfo::UnsignedInt; PtrDiffType = TargetInfo::SignedInt; Modified: cfe/trunk/test/CodeGen/builtins-nvptx.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-nvptx.c?rev=248753&r1=248752&r2=248753&view=diff == --- cfe/trunk/test/CodeGen/builtins-nvptx.c (original) +++ cfe/trunk/test/CodeGen/builtins-nvptx.c Mon Sep 28 17:54:08 2015 @@ -109,16 +109,15 @@ __device__ int read_lanemasks() { } -__device__ long read_clocks() { +__device__ long long read_clocks() { // CHECK: call i32 @llvm.ptx.read.clock() // CHECK: call i64 @llvm.ptx.read.clock64() int a = __builtin_ptx_read_clock(); - long b = __builtin_ptx_read_clock64(); - - return (long)a + b; + long long b = __builtin_ptx_read_clock64(); + return a + b; } __device__ int read_pms() { Modified: cfe/trunk/test/CodeGen/nvptx-inlineasm-ptx.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/nvptx-inlineasm-ptx.c?rev=248753&r1=248752&r2=248753&view=diff == --- cfe/trunk/test/CodeGen/nvptx-inlineasm-ptx.c (original) +++ cfe/trunk/test/CodeGen/nvptx-inlineasm-ptx.c Mon Sep 28 17:54:08 2015 @@ -8,8 +8,8 @@ void constraints() { unsigned short us; inti; unsigned int ui; - long l; - unsigned long ul; + long long ll; + unsigned long long ull; float f; double d; @@ -29,9 +29,9 @@ void constraints() { asm volatile ("mov.b32 %0, %1;" : "=r"(ui) : "r"(ui)); // CHECK: i64 asm sideeffect "mov.b64 $0, $1;", "=l,l" - asm volatile ("mov.b64 %0, %1;" : "=l"(l) : "l"(l)); + asm volatile ("mov.b64 %0, %1;" : "=l"(ll) : "l"(ll)); // CHECK: i64 asm sideeffect "mov.b64 $0, $1;", "=l,l" - asm volatile ("mov.b64 %0, %1;" : "=l"(ul) : "l"(ul)); + asm volatile ("mov.b64 %0, %1;" : "=l"(ull) : "l"(ull)); // CHECK: float asm sideeffect "mov.b32 $0, $1;", "=f,f" asm volatile ("mov.b32 %0, %1;" : "=f"(f) : "f"(f)); Modified: cfe/trunk/test/Preprocessor/init.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=248753&r1=248752&r2=248753&view=diff == --- cfe/trunk/test/Preprocessor/init.c (original) +++ cfe/trunk/test/Preprocessor/init.c Mon Sep 28 17:54:08 2015 @@ -4737,10 +4737,10 @@ // NVPTX32:#define __INT_FAST32_FMTi__ "i" // NVPTX32:#define __INT_FAST32_MAX__ 2147483647 // NVPTX32:#define __INT_FAST32_TYPE__ int -// NVPTX32:#define __INT_FAST64_FMTd__ "ld" -// NVPTX32:#define __INT_FAST64_FMTi__ "li" +// NVPTX32:#define __INT_FAST64_FMTd__ "lld" +// NVPTX32:#define __INT_FAST64_FMTi__ "lli" // NVPTX32:#define __INT_FAST64_MAX__ 9223372036854775807L -// NVPTX32:#define __INT_FAST64_TYPE__ long int +// NVPTX32:#define __INT_FAST64_TYPE__ long long int // NVPTX32:#define __INT_FAST8_FMTd__ "hhd" // NVPTX32:#define __INT_FAST8_FMTi__ "hhi" // NVPTX32:#
Re: [PATCH] D13181: [CUDA] 32-bit NVPTX: long should be 32bit
This revision was automatically updated to reflect the committed changes. Closed by commit rL248753: [CUDA] 32-bit NVPTX should have 32-bit long type. (authored by tra). Changed prior to commit: http://reviews.llvm.org/D13181?vs=35772&id=35918#toc Repository: rL LLVM http://reviews.llvm.org/D13181 Files: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/CodeGen/builtins-nvptx.c cfe/trunk/test/CodeGen/nvptx-inlineasm-ptx.c cfe/trunk/test/Preprocessor/init.c Index: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def === --- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def +++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def @@ -50,7 +50,7 @@ BUILTIN(__builtin_ptx_read_lanemask_gt, "i", "nc") BUILTIN(__builtin_ptx_read_clock, "i", "n") -BUILTIN(__builtin_ptx_read_clock64, "Li", "n") +BUILTIN(__builtin_ptx_read_clock64, "LLi", "n") BUILTIN(__builtin_ptx_read_pm0, "i", "n") BUILTIN(__builtin_ptx_read_pm1, "i", "n") Index: cfe/trunk/test/CodeGen/nvptx-inlineasm-ptx.c === --- cfe/trunk/test/CodeGen/nvptx-inlineasm-ptx.c +++ cfe/trunk/test/CodeGen/nvptx-inlineasm-ptx.c @@ -8,8 +8,8 @@ unsigned short us; inti; unsigned int ui; - long l; - unsigned long ul; + long long ll; + unsigned long long ull; float f; double d; @@ -29,9 +29,9 @@ asm volatile ("mov.b32 %0, %1;" : "=r"(ui) : "r"(ui)); // CHECK: i64 asm sideeffect "mov.b64 $0, $1;", "=l,l" - asm volatile ("mov.b64 %0, %1;" : "=l"(l) : "l"(l)); + asm volatile ("mov.b64 %0, %1;" : "=l"(ll) : "l"(ll)); // CHECK: i64 asm sideeffect "mov.b64 $0, $1;", "=l,l" - asm volatile ("mov.b64 %0, %1;" : "=l"(ul) : "l"(ul)); + asm volatile ("mov.b64 %0, %1;" : "=l"(ull) : "l"(ull)); // CHECK: float asm sideeffect "mov.b32 $0, $1;", "=f,f" asm volatile ("mov.b32 %0, %1;" : "=f"(f) : "f"(f)); Index: cfe/trunk/test/CodeGen/builtins-nvptx.c === --- cfe/trunk/test/CodeGen/builtins-nvptx.c +++ cfe/trunk/test/CodeGen/builtins-nvptx.c @@ -109,16 +109,15 @@ } -__device__ long read_clocks() { +__device__ long long read_clocks() { // CHECK: call i32 @llvm.ptx.read.clock() // CHECK: call i64 @llvm.ptx.read.clock64() int a = __builtin_ptx_read_clock(); - long b = __builtin_ptx_read_clock64(); - - return (long)a + b; + long long b = __builtin_ptx_read_clock64(); + return a + b; } __device__ int read_pms() { Index: cfe/trunk/test/Preprocessor/init.c === --- cfe/trunk/test/Preprocessor/init.c +++ cfe/trunk/test/Preprocessor/init.c @@ -4737,10 +4737,10 @@ // NVPTX32:#define __INT_FAST32_FMTi__ "i" // NVPTX32:#define __INT_FAST32_MAX__ 2147483647 // NVPTX32:#define __INT_FAST32_TYPE__ int -// NVPTX32:#define __INT_FAST64_FMTd__ "ld" -// NVPTX32:#define __INT_FAST64_FMTi__ "li" +// NVPTX32:#define __INT_FAST64_FMTd__ "lld" +// NVPTX32:#define __INT_FAST64_FMTi__ "lli" // NVPTX32:#define __INT_FAST64_MAX__ 9223372036854775807L -// NVPTX32:#define __INT_FAST64_TYPE__ long int +// NVPTX32:#define __INT_FAST64_TYPE__ long long int // NVPTX32:#define __INT_FAST8_FMTd__ "hhd" // NVPTX32:#define __INT_FAST8_FMTi__ "hhi" // NVPTX32:#define __INT_FAST8_MAX__ 127 @@ -4753,10 +4753,10 @@ // NVPTX32:#define __INT_LEAST32_FMTi__ "i" // NVPTX32:#define __INT_LEAST32_MAX__ 2147483647 // NVPTX32:#define __INT_LEAST32_TYPE__ int -// NVPTX32:#define __INT_LEAST64_FMTd__ "ld" -// NVPTX32:#define __INT_LEAST64_FMTi__ "li" +// NVPTX32:#define __INT_LEAST64_FMTd__ "lld" +// NVPTX32:#define __INT_LEAST64_FMTi__ "lli" // NVPTX32:#define __INT_LEAST64_MAX__ 9223372036854775807L -// NVPTX32:#define __INT_LEAST64_TYPE__ long int +// NVPTX32:#define __INT_LEAST64_TYPE__ long long int // NVPTX32:#define __INT_LEAST8_FMTd__ "hhd" // NVPTX32:#define __INT_LEAST8_FMTi__ "hhi" // NVPTX32:#define __INT_LEAST8_MAX__ 127 @@ -4777,7 +4777,7 @@ // NVPTX32:#define __LDBL_MIN__ 2.2250738585072014e-308L // NVPTX32:#define __LITTLE_ENDIAN__ 1 // NVPTX32:#define __LONG_LONG_MAX__ 9223372036854775807LL -// NVPTX32:#define __LONG_MAX__ 9223372036854775807L +// NVPTX32:#define __LONG_MAX__ 2147483647L // NVPTX32-NOT:#define __LP64__ // NVPTX32:#define __NVPTX__ 1 // NVPTX32:#define __POINTER_WIDTH__ 32 @@ -4794,7 +4794,7 @@ // NVPTX32:#define __SIZEOF_INT__ 4 // NVPTX32:#define __SIZEOF_LONG_DOUBLE__ 8 // NVPTX32:#define __SIZEOF_LONG_LONG__ 8 -// NVPTX32:#define __SIZEOF_LONG__ 8 +// NVPTX32:#define __SIZEOF_LONG__ 4 // NVPTX32:#define __SIZEOF_POINTER__ 4 // NVPTX32:#define __SIZEOF_PTRDIFF_T__ 4 // NVPTX32:#define __SIZEOF_SHORT__ 2 @@ -4828,15 +4828,15 @@ // NVPTX32:#define __UINT_FAST32_MAX__ 4294967295U // NVPTX32:#define __UINT_FAST32_TYPE__ unsigned int // NVPTX32:#define __UI
Re: [PATCH] D13229: Add -Wc, option
Hi Joerg: This change would allow users to pass multiple options, or options with arguments, to cc1 without having to use -Xclang multiple times. Recently, the -load option was added, at least partly, because passing -Xclang multiple times was cumbersome. (I like that change btw) Had -Wc, been available, perhaps that wouldn't have been that much of an issue. But I'll defer to your better judgement on this -- I certainly wouldn't advocate an explosion of new options. Thanks for concidering it... Don On Sep 28, 2015 6:13 PM, "Joerg Sonnenberger" wrote: > On Mon, Sep 28, 2015 at 09:54:53PM +, don hinton via cfe-commits wrote: > > Add -Wc, option (similar to -Wl,) to go along with -Xclang. > > This makes it easier to pass multiple options to cc1. > > How is this better than -mllvm and -Xclang? There is no precendence case > for > this with GCC really and I don't see a good reason for wanting this, > frankly. > > Joerg > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r241035 - Pass HeaderSearchOptions and PreprocessorOptions into CodeGenModule.
Actually using the right list now... On Mon, Sep 28, 2015 at 4:39 PM Eric Christopher wrote: > Hi Adrian, > > >>: CGO(new CodeGenOptions), >> -CGM(new CodeGen::CodeGenModule(C, *CGO, M, TD, C.getDiagnostics(), >> +HSO(new HeaderSearchOptions), >> +PPO(new PreprocessorOptions), >> +CGM(new CodeGen::CodeGenModule(C, *HSO, *PPO, *CGO, >> + M, TD, C.getDiagnostics(), >> CoverageInfo)) { >> } >> >> >> > Sorry to do archaeology on this thread, but I see you added these as "new" > here, but didn't use delete on them a few lines down. Any reason? > > Also, might want to make them use unique_ptr while you're at it :) > > -eric > > >> Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=241035&r1=241034&r2=241035&view=diff >> >> == >> --- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original) >> +++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Mon Jun 29 21:26:03 2015 >> @@ -57,6 +57,8 @@ namespace clang { >> >>public: >> BackendConsumer(BackendAction Action, DiagnosticsEngine &Diags, >> +const HeaderSearchOptions &HeaderSearchOpts, >> +const PreprocessorOptions &PPOpts, >> const CodeGenOptions &CodeGenOpts, >> const TargetOptions &TargetOpts, >> const LangOptions &LangOpts, bool TimePasses, >> @@ -66,7 +68,8 @@ namespace clang { >> : Diags(Diags), Action(Action), CodeGenOpts(CodeGenOpts), >>TargetOpts(TargetOpts), LangOpts(LangOpts), AsmOutStream(OS), >>Context(nullptr), LLVMIRGeneration("LLVM IR Generation Time"), >> - Gen(CreateLLVMCodeGen(Diags, InFile, CodeGenOpts, C, >> CoverageInfo)), >> + Gen(CreateLLVMCodeGen(Diags, InFile, HeaderSearchOpts, PPOpts, >> +CodeGenOpts, C, CoverageInfo)), >>LinkModule(LinkModule) { >>llvm::TimePassesIsEnabled = TimePasses; >> } >> @@ -667,7 +670,8 @@ CodeGenAction::CreateASTConsumer(Compile >> >> std::unique_ptr(CoverageInfo)); >>} >>std::unique_ptr Result(new BackendConsumer( >> - BA, CI.getDiagnostics(), CI.getCodeGenOpts(), CI.getTargetOpts(), >> + BA, CI.getDiagnostics(), CI.getHeaderSearchOpts(), >> + CI.getPreprocessorOpts(), CI.getCodeGenOpts(), CI.getTargetOpts(), >>CI.getLangOpts(), CI.getFrontendOpts().ShowTimers, InFile, >>LinkModuleToUse, OS, *VMContext, CoverageInfo)); >>BEConsumer = Result.get(); >> >> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=241035&r1=241034&r2=241035&view=diff >> >> == >> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) >> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Jun 29 21:26:03 2015 >> @@ -74,16 +74,19 @@ static CGCXXABI *createCXXABI(CodeGenMod >>llvm_unreachable("invalid C++ ABI kind"); >> } >> >> -CodeGenModule::CodeGenModule(ASTContext &C, const CodeGenOptions &CGO, >> - llvm::Module &M, const llvm::DataLayout &TD, >> +CodeGenModule::CodeGenModule(ASTContext &C, const HeaderSearchOptions >> &HSO, >> + const PreprocessorOptions &PPO, >> + const CodeGenOptions &CGO, llvm::Module &M, >> + const llvm::DataLayout &TD, >> DiagnosticsEngine &diags, >> CoverageSourceInfo *CoverageInfo) >> -: Context(C), LangOpts(C.getLangOpts()), CodeGenOpts(CGO), >> TheModule(M), >> - Diags(diags), TheDataLayout(TD), Target(C.getTargetInfo()), >> - ABI(createCXXABI(*this)), VMContext(M.getContext()), TBAA(nullptr), >> - TheTargetCodeGenInfo(nullptr), Types(*this), VTables(*this), >> - ObjCRuntime(nullptr), OpenCLRuntime(nullptr), >> OpenMPRuntime(nullptr), >> - CUDARuntime(nullptr), DebugInfo(nullptr), ARCData(nullptr), >> +: Context(C), LangOpts(C.getLangOpts()), HeaderSearchOpts(HSO), >> + PreprocessorOpts(PPO), CodeGenOpts(CGO), TheModule(M), >> Diags(diags), >> + TheDataLayout(TD), Target(C.getTargetInfo()), >> ABI(createCXXABI(*this)), >> + VMContext(M.getContext()), TBAA(nullptr), >> TheTargetCodeGenInfo(nullptr), >> + Types(*this), VTables(*this), ObjCRuntime(nullptr), >> + OpenCLRuntime(nullptr), OpenMPRuntime(nullptr), >> CUDARuntime(nullptr), >> + DebugInfo(nullptr), ARCData(nullptr), >>NoObjCARCExceptionsMetadata(nullptr), RRData(nullptr), >> PGOReader(nullptr), >>CFConstantStringClassRef(nullptr), ConstantStringClassRef(nullptr), >>NSConstantStringType(nullptr), NSConcreteGlobalBlock(nullptr), >> >> Modif
r248761 - Remove the only use of LookupResult's implicit copy ctor
Author: dblaikie Date: Mon Sep 28 18:48:55 2015 New Revision: 248761 URL: http://llvm.org/viewvc/llvm-project?rev=248761&view=rev Log: Remove the only use of LookupResult's implicit copy ctor LookupResult should not be copyable, it's not readily copyable and can only be copied when it's in specific states (in a query state, without any results, basically). Instead, just extract the /query/ state and pass that across the copy boundary, then build a new LookupResult on the other side. I wonder if a better API (one in which the query state is separate from the result state - essentialyl making QueryState a first class part of the Lookup API - pass a QueryState, get a LookupResult, rather than mutating the LookupResult in place (LookupResult could contain a QueryState if it's particularly helpful to be able to observe the query parameters while also examining the result)) might be a good idea here. Future patches will probably make LookupResult actually non-copyable (transition the CXXBasePaths to unique_ptr, for example) and hopefully we'll enable -Wdeprecated in LLVM soon to avoid issues like this. Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=248761&r1=248760&r2=248761&view=diff == --- cfe/trunk/lib/Sema/SemaExprMember.cpp (original) +++ cfe/trunk/lib/Sema/SemaExprMember.cpp Mon Sep 28 18:48:55 2015 @@ -632,6 +632,16 @@ static bool LookupMemberExprInRecord(Sem DeclarationName Typo = R.getLookupName(); SourceLocation TypoLoc = R.getNameLoc(); + + struct QueryState { +Sema &SemaRef; +DeclarationNameInfo NameInfo; +Sema::LookupNameKind LookupKind; +Sema::RedeclarationKind Redecl; + }; + QueryState Q = {R.getSema(), R.getLookupNameInfo(), R.getLookupKind(), + R.isForRedeclaration() ? Sema::ForRedeclaration + : Sema::NotForRedeclaration}; TE = SemaRef.CorrectTypoDelayed( R.getLookupNameInfo(), R.getLookupKind(), nullptr, &SS, llvm::make_unique(RTy), @@ -650,6 +660,7 @@ static bool LookupMemberExprInRecord(Sem } }, [=](Sema &SemaRef, TypoExpr *TE, TypoCorrection TC) mutable { +LookupResult R(Q.SemaRef, Q.NameInfo, Q.LookupKind, Q.Redecl); R.clear(); // Ensure there's no decls lingering in the shared state. R.suppressDiagnostics(); R.setLookupName(TC.getCorrection()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r248760 - Add an explicitly defaulted copy ctor (and FIXME) to Command since its copy ctor is currently used (and actually slices derived objects... ) in some diagnostics handling.
Author: dblaikie Date: Mon Sep 28 18:48:52 2015 New Revision: 248760 URL: http://llvm.org/viewvc/llvm-project?rev=248760&view=rev Log: Add an explicitly defaulted copy ctor (and FIXME) to Command since its copy ctor is currently used (and actually slices derived objects... ) in some diagnostics handling. Justin mentioned he'd look into this. Modified: cfe/trunk/include/clang/Driver/Job.h Modified: cfe/trunk/include/clang/Driver/Job.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Job.h?rev=248760&r1=248759&r2=248760&view=diff == --- cfe/trunk/include/clang/Driver/Job.h (original) +++ cfe/trunk/include/clang/Driver/Job.h Mon Sep 28 18:48:52 2015 @@ -85,6 +85,9 @@ public: Command(const Action &Source, const Tool &Creator, const char *Executable, const llvm::opt::ArgStringList &Arguments, ArrayRef Inputs); + // FIXME: This really shouldn't be copyable, but is currently copied in some + // error handling in Driver::generateCompilationDiagnostics. + Command(const Command &) = default; virtual ~Command() {} virtual void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r248759 - Remove trivial dtor that was making uses of the copy ctor -Wdeprecated unclean
Author: dblaikie Date: Mon Sep 28 18:48:49 2015 New Revision: 248759 URL: http://llvm.org/viewvc/llvm-project?rev=248759&view=rev Log: Remove trivial dtor that was making uses of the copy ctor -Wdeprecated unclean And also remove an unused variable that's now diagnosed by -Wunused-variable since the dtor is now trivial. Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=248759&r1=248758&r2=248759&view=diff == --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Mon Sep 28 18:48:49 2015 @@ -129,7 +129,6 @@ namespace clang { public: RedeclarableResult(GlobalDeclID FirstID, Decl *MergeWith, bool IsKeyDecl) : FirstID(FirstID), MergeWith(MergeWith), IsKeyDecl(IsKeyDecl) {} - ~RedeclarableResult() {} /// \brief Retrieve the first ID. GlobalDeclID getFirstID() const { return FirstID; } @@ -882,7 +881,7 @@ void ASTDeclReader::VisitObjCMethodDecl( } void ASTDeclReader::VisitObjCTypeParamDecl(ObjCTypeParamDecl *D) { - RedeclarableResult Redecl = VisitTypedefNameDecl(D); + VisitTypedefNameDecl(D); D->Variance = Record[Idx++]; D->Index = Record[Idx++]; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r241035 - Pass HeaderSearchOptions and PreprocessorOptions into CodeGenModule.
Thanks, Eric! Should be fixed in r248762. -- adrian > On Sep 28, 2015, at 4:40 PM, Eric Christopher wrote: > > Actually using the right list now... > > On Mon, Sep 28, 2015 at 4:39 PM Eric Christopher wrote: > Hi Adrian, > > >: CGO(new CodeGenOptions), > -CGM(new CodeGen::CodeGenModule(C, *CGO, M, TD, C.getDiagnostics(), > +HSO(new HeaderSearchOptions), > +PPO(new PreprocessorOptions), > +CGM(new CodeGen::CodeGenModule(C, *HSO, *PPO, *CGO, > + M, TD, C.getDiagnostics(), > CoverageInfo)) { > } > > > > Sorry to do archaeology on this thread, but I see you added these as "new" > here, but didn't use delete on them a few lines down. Any reason? > > Also, might want to make them use unique_ptr while you're at it :) > > -eric > > Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=241035&r1=241034&r2=241035&view=diff > == > --- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original) > +++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Mon Jun 29 21:26:03 2015 > @@ -57,6 +57,8 @@ namespace clang { > >public: > BackendConsumer(BackendAction Action, DiagnosticsEngine &Diags, > +const HeaderSearchOptions &HeaderSearchOpts, > +const PreprocessorOptions &PPOpts, > const CodeGenOptions &CodeGenOpts, > const TargetOptions &TargetOpts, > const LangOptions &LangOpts, bool TimePasses, > @@ -66,7 +68,8 @@ namespace clang { > : Diags(Diags), Action(Action), CodeGenOpts(CodeGenOpts), >TargetOpts(TargetOpts), LangOpts(LangOpts), AsmOutStream(OS), >Context(nullptr), LLVMIRGeneration("LLVM IR Generation Time"), > - Gen(CreateLLVMCodeGen(Diags, InFile, CodeGenOpts, C, > CoverageInfo)), > + Gen(CreateLLVMCodeGen(Diags, InFile, HeaderSearchOpts, PPOpts, > +CodeGenOpts, C, CoverageInfo)), >LinkModule(LinkModule) { >llvm::TimePassesIsEnabled = TimePasses; > } > @@ -667,7 +670,8 @@ CodeGenAction::CreateASTConsumer(Compile > > std::unique_ptr(CoverageInfo)); >} >std::unique_ptr Result(new BackendConsumer( > - BA, CI.getDiagnostics(), CI.getCodeGenOpts(), CI.getTargetOpts(), > + BA, CI.getDiagnostics(), CI.getHeaderSearchOpts(), > + CI.getPreprocessorOpts(), CI.getCodeGenOpts(), CI.getTargetOpts(), >CI.getLangOpts(), CI.getFrontendOpts().ShowTimers, InFile, >LinkModuleToUse, OS, *VMContext, CoverageInfo)); >BEConsumer = Result.get(); > > Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=241035&r1=241034&r2=241035&view=diff > == > --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) > +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Jun 29 21:26:03 2015 > @@ -74,16 +74,19 @@ static CGCXXABI *createCXXABI(CodeGenMod >llvm_unreachable("invalid C++ ABI kind"); > } > > -CodeGenModule::CodeGenModule(ASTContext &C, const CodeGenOptions &CGO, > - llvm::Module &M, const llvm::DataLayout &TD, > +CodeGenModule::CodeGenModule(ASTContext &C, const HeaderSearchOptions &HSO, > + const PreprocessorOptions &PPO, > + const CodeGenOptions &CGO, llvm::Module &M, > + const llvm::DataLayout &TD, > DiagnosticsEngine &diags, > CoverageSourceInfo *CoverageInfo) > -: Context(C), LangOpts(C.getLangOpts()), CodeGenOpts(CGO), TheModule(M), > - Diags(diags), TheDataLayout(TD), Target(C.getTargetInfo()), > - ABI(createCXXABI(*this)), VMContext(M.getContext()), TBAA(nullptr), > - TheTargetCodeGenInfo(nullptr), Types(*this), VTables(*this), > - ObjCRuntime(nullptr), OpenCLRuntime(nullptr), OpenMPRuntime(nullptr), > - CUDARuntime(nullptr), DebugInfo(nullptr), ARCData(nullptr), > +: Context(C), LangOpts(C.getLangOpts()), HeaderSearchOpts(HSO), > + PreprocessorOpts(PPO), CodeGenOpts(CGO), TheModule(M), Diags(diags), > + TheDataLayout(TD), Target(C.getTargetInfo()), ABI(createCXXABI(*this)), > + VMContext(M.getContext()), TBAA(nullptr), > TheTargetCodeGenInfo(nullptr), > + Types(*this), VTables(*this), ObjCRuntime(nullptr), > + OpenCLRuntime(nullptr), OpenMPRuntime(nullptr), CUDARuntime(nullptr), > + DebugInfo(nullptr), ARCData(nullptr), >NoObjCARCExceptionsMetadata(nullptr), RRData(nullptr), > PGOReader(nullptr), >CFConstantStringClassRef(nullptr), ConstantStringClassRef(nullptr), >NSConstantS
r248762 - Unique-pointerify these pointers an plug a memory leak.
Author: adrian Date: Mon Sep 28 18:56:10 2015 New Revision: 248762 URL: http://llvm.org/viewvc/llvm-project?rev=248762&view=rev Log: Unique-pointerify these pointers an plug a memory leak. Thanks to echristo for noticing! Modified: cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp Modified: cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h?rev=248762&r1=248761&r2=248762&view=diff == --- cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h (original) +++ cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h Mon Sep 28 18:56:10 2015 @@ -52,7 +52,6 @@ class CodeGenABITypes public: CodeGenABITypes(ASTContext &C, llvm::Module &M, CoverageSourceInfo *CoverageInfo = nullptr); - ~CodeGenABITypes(); /// These methods all forward to methods in the private implementation class /// CodeGenTypes. @@ -75,12 +74,12 @@ private: /// Default CodeGenOptions object used to initialize the /// CodeGenModule and otherwise not used. More specifically, it is /// not used in ABI type generation, so none of the options matter. - CodeGenOptions *CGO; - HeaderSearchOptions *HSO; - PreprocessorOptions *PPO; + std::unique_ptr CGO; + std::unique_ptr HSO; + std::unique_ptr PPO; /// The CodeGenModule we use get to the CodeGenTypes object. - CodeGen::CodeGenModule *CGM; + std::unique_ptr CGM; }; } // end namespace CodeGen Modified: cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp?rev=248762&r1=248761&r2=248762&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp Mon Sep 28 18:56:10 2015 @@ -33,12 +33,6 @@ CodeGenABITypes::CodeGenABITypes(ASTCont CGM(new CodeGen::CodeGenModule(C, *HSO, *PPO, *CGO, M, C.getDiagnostics(), CoverageInfo)) {} -CodeGenABITypes::~CodeGenABITypes() -{ - delete CGO; - delete CGM; -} - const CGFunctionInfo & CodeGenABITypes::arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD, QualType receiverType) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
LLVM buildnaster will be restarted tonight
Hello everyone, LLVM buildmaster will be restarted after 6 PM Pacific time today. Thanks Galina ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13229: Add -Wc, option
hintonda added a comment. Here are a few examples from existing tests showing how this option could be used: -Xclang -analyzer-max-loop -Xclang 34 becomes: -Wc,-analyzer-max-loop,34 -Xclang -analyzer-checker=debug.ConfigDumper -Xclang -analyzer-max-loop -Xclang 34 becomes: -Wc,-analyzer-checker,debug.ConfigDumper,-analyzer-max-loop,34 -Xclang -analyzer-config -Xclang path-diagnostics-alternate=true -Xclang -analyzer-output=plist becomes: -Wc,-analyzer-config,path-diagnostics-alternate=true,-analyzer-output=plist -Xclang -internal-isystem -Xclang /tmp/ becomes: -Wc,-internal-isystem,/tmp/ -Xclang -internal-externc-isystem -Xclang /tmp becomes: -Wc,-internal-externc-isystem,/tmp -Xclang -main-file-name -Xclang foo.c becomes: -Wc,-main-file-name,foo.c -Xclang -include-pch -Xclang %t.pch becomes: -Wc,-include-pch,%t.pch -Xclang -fdisable-module-hash -Xclang -detailed-preprocessing-record -Xclang -verify becomes: -Wc,-fdisable-module-hash,-detailed-preprocessing-record,-verify http://reviews.llvm.org/D13229 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13171: [CUDA] Added a wrapper header for inclusion of stock CUDA headers.
echristo added a comment. Why not just call it cuda.h and use #include next for it and then fix it up? -eric http://reviews.llvm.org/D13171 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13171: [CUDA] Added a wrapper header for inclusion of stock CUDA headers.
cuda_runtime.h may be a better choice. nvcc -includes it during both host and device compilation and this wrapper file is intended to serve a similar purpose and will probably end up being -included by cc1 in the end. --Artem On Mon, Sep 28, 2015 at 6:26 PM, Eric Christopher wrote: > echristo added a comment. > > Why not just call it cuda.h and use #include next for it and then fix it > up? > > -eric > > > http://reviews.llvm.org/D13171 > > > > -- --Artem Belevich ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13229: Add -Wc, option
compnerd added a comment. While I can certainly appreciate the simplification this may afford, Im not sure if adding a new option here is really that valuable. Options being added to the frontend are expensive because they can't be changed or removed. If gcc has a similar frontend option, we may consider it for compatibility (as was the case for -fplugin). In this case, yes, it is harder to type options that we are passing down, but they are backend options and not meant to be used by users in the general case. The -Xclang and -mllvm options currently are available, and make it clear enough where the option is going. Arguably this is a bad idea since it makes it easier to pull backend options into the frontend. Is there a stronger reason for this other than aesthetics? http://reviews.llvm.org/D13229 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13229: Add -Wc, option
hintonda added a comment. Mainly aesthetic. It was the only one of the group, -Xassembler, -Xlinker, -Xpreprocessor, and -Xclang, that didn't have a corresponding comma separated option, so I figured it might be a good addition. http://reviews.llvm.org/D13229 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D13229: Add -Wc, option
compnerd added a comment. Ah. Well, Im tempted to say that we should avoid the option. Generally, making the backend options visible is undesirable since there is no guarantee of stability there. This simplifies that, and if users start using that, we would not be able to change those as easily. Wasn't an unreasonable thought though :-). http://reviews.llvm.org/D13229 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r248773 - Pass ArrayRef by value. NFC.
Author: ctopper Date: Mon Sep 28 23:30:05 2015 New Revision: 248773 URL: http://llvm.org/viewvc/llvm-project?rev=248773&view=rev Log: Pass ArrayRef by value. NFC. Modified: cfe/trunk/lib/AST/ExprConstant.cpp Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=248773&r1=248772&r2=248773&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Sep 28 23:30:05 2015 @@ -5568,7 +5568,7 @@ namespace { VectorExprEvaluator(EvalInfo &info, APValue &Result) : ExprEvaluatorBaseTy(info), Result(Result) {} -bool Success(const ArrayRef &V, const Expr *E) { +bool Success(ArrayRef V, const Expr *E) { assert(V.size() == E->getType()->castAs()->getNumElements()); // FIXME: remove this APValue copy. Result = APValue(V.data(), V.size()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r248774 - Remove 'const' from some ArrayRef arguments since they're passed by value anyway. NFC
Author: ctopper Date: Mon Sep 28 23:30:07 2015 New Revision: 248774 URL: http://llvm.org/viewvc/llvm-project?rev=248774&view=rev Log: Remove 'const' from some ArrayRef arguments since they're passed by value anyway. NFC Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=248774&r1=248773&r2=248774&view=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Mon Sep 28 23:30:07 2015 @@ -1894,8 +1894,7 @@ typedef std::pair Privates) { +createPrivatesRecordDecl(CodeGenModule &CGM, ArrayRef Privates) { if (!Privates.empty()) { auto &C = CGM.getContext(); // Build struct .kmp_privates_t. { @@ -1943,7 +1942,7 @@ createKmpTaskTRecordDecl(CodeGenModule & static RecordDecl * createKmpTaskTWithPrivatesRecordDecl(CodeGenModule &CGM, QualType KmpTaskTQTy, - const ArrayRef Privates) { + ArrayRef Privates) { auto &C = CGM.getContext(); // Build struct kmp_task_t_with_privates { // kmp_task_t task_data; @@ -2092,10 +2091,10 @@ static llvm::Value *emitDestructorsFunct /// \endcode static llvm::Value * emitTaskPrivateMappingFunction(CodeGenModule &CGM, SourceLocation Loc, - const ArrayRef PrivateVars, - const ArrayRef FirstprivateVars, + ArrayRef PrivateVars, + ArrayRef FirstprivateVars, QualType PrivatesQTy, - const ArrayRef Privates) { + ArrayRef Privates) { auto &C = CGM.getContext(); FunctionArgList Args; ImplicitParamDecl TaskPrivatesArg( ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r248775 - Honor the casted-to alignment of an explicit cast even when
Author: rjmccall Date: Mon Sep 28 23:37:40 2015 New Revision: 248775 URL: http://llvm.org/viewvc/llvm-project?rev=248775&view=rev Log: Honor the casted-to alignment of an explicit cast even when Sema thinks the cast is a no-op, as it does when (e.g.) the only thing that changes is an alignment attribute. Fixed PR24944. Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/test/CodeGen/alignment.c Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=248775&r1=248774&r2=248775&view=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Sep 28 23:37:40 2015 @@ -814,7 +814,6 @@ Address CodeGenFunction::EmitPointerWith // If this is an explicit bitcast, and the source l-value is // opaque, honor the alignment of the casted-to type. if (isa(CE) && -CE->getCastKind() == CK_BitCast && InnerSource != AlignmentSource::Decl) { Addr = Address(Addr.getPointer(), getNaturalPointeeTypeAlignment(E->getType(), Source)); Modified: cfe/trunk/test/CodeGen/alignment.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/alignment.c?rev=248775&r1=248774&r2=248775&view=diff == --- cfe/trunk/test/CodeGen/alignment.c (original) +++ cfe/trunk/test/CodeGen/alignment.c Mon Sep 28 23:37:40 2015 @@ -59,3 +59,11 @@ void test4(float4align64 *p) { // CHECK: @test4( // CHECK: store <4 x float> {{.*}}, <4 x float>* {{.*}}, align 64 +// PR24944 - Typedef alignment not honored on no-op cast. +typedef float __attribute__((vector_size(16), aligned(16))) float4align16; +typedef float __attribute__((vector_size(16), aligned(2))) float4align2; +void test6(float4align64 *p) { +float4align64 vec = *(float4align2*) p; +} +// CHECK-LABEL: @test6 +// CHECK: load <4 x float>, <4 x float>* {{.*}}, align 2 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r248776 - Simplify or remove calls to makeArrayRef based on feedback from David Blaikie. NFC.
Author: ctopper Date: Mon Sep 28 23:53:28 2015 New Revision: 248776 URL: http://llvm.org/viewvc/llvm-project?rev=248776&view=rev Log: Simplify or remove calls to makeArrayRef based on feedback from David Blaikie. NFC. Modified: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Modified: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h?rev=248776&r1=248775&r2=248776&view=diff == --- cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h (original) +++ cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h Mon Sep 28 23:53:28 2015 @@ -1395,7 +1395,7 @@ public: /// Return the list of basic blocks that this terminator can branch to. ArrayRef successors() { -return llvm::makeArrayRef(TargetBlock); +return TargetBlock; } template @@ -1445,7 +1445,7 @@ public: /// Return the list of basic blocks that this terminator can branch to. ArrayRef successors() { -return llvm::makeArrayRef(Branches); +return Branches; } template Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=248776&r1=248775&r2=248776&view=diff == --- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original) +++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Mon Sep 28 23:53:28 2015 @@ -208,7 +208,7 @@ namespace clang { auto &&PartialSpecializations = getPartialSpecializations(Common); ArrayRef LazySpecializations; if (auto *LS = Common->LazySpecializations) -LazySpecializations = llvm::makeArrayRef(LS + 1, LS + 1 + LS[0]); +LazySpecializations = llvm::makeArrayRef(LS + 1, LS[0]); // Add a slot to the record for the number of specializations. unsigned I = Record.size(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r248778 - Revert part of r248776. One of the changes worked on my local build, but not on the bots.
Author: ctopper Date: Tue Sep 29 00:08:30 2015 New Revision: 248778 URL: http://llvm.org/viewvc/llvm-project?rev=248778&view=rev Log: Revert part of r248776. One of the changes worked on my local build, but not on the bots. Modified: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h Modified: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h?rev=248778&r1=248777&r2=248778&view=diff == --- cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h (original) +++ cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h Tue Sep 29 00:08:30 2015 @@ -1445,7 +1445,7 @@ public: /// Return the list of basic blocks that this terminator can branch to. ArrayRef successors() { -return Branches; +return llvm::makeArrayRef(Branches); } template ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits