Re: [PATCH] D13750: [libcxx] Fix LWG Issue #2367 - Fixing std::tuple and std::pair's default constructors.
EricWF accepted this revision. EricWF added a reviewer: EricWF. EricWF added a comment. This revision is now accepted and ready to land. Accepting. Any additional review can happen post-commit. http://reviews.llvm.org/D13750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r256325 - [libcxx] Fix LWG Issue #2367 - Fixing std::tuple and std::pair's default constructors.
Author: ericwf Date: Wed Dec 23 02:20:26 2015 New Revision: 256325 URL: http://llvm.org/viewvc/llvm-project?rev=256325&view=rev Log: [libcxx] Fix LWG Issue #2367 - Fixing std::tuple and std::pair's default constructors. Summary: This patch implements the solution for LWG Issue #2367. See http://cplusplus.github.io/LWG/lwg-active.html#2367 Reviewers: mclow.lists, EricWF Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D13750 Added: libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp Modified: libcxx/trunk/include/__config libcxx/trunk/include/utility libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp Modified: libcxx/trunk/include/__config URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=256325&r1=256324&r2=256325&view=diff == --- libcxx/trunk/include/__config (original) +++ libcxx/trunk/include/__config Wed Dec 23 02:20:26 2015 @@ -305,6 +305,10 @@ typedef __char32_t char32_t; #define _LIBCPP_UNUSED __attribute__((__unused__)) +#if !(__has_feature(cxx_default_function_template_args)) +#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS +#endif + #if !(__has_feature(cxx_defaulted_functions)) #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #endif // !(__has_feature(cxx_defaulted_functions)) @@ -474,6 +478,7 @@ namespace std { #define _LIBCPP_HAS_NO_ADVANCED_SFINAE #define _LIBCPP_HAS_NO_DECLTYPE +#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #define _LIBCPP_HAS_NO_NULLPTR @@ -487,13 +492,12 @@ namespace std { #else // __GXX_EXPERIMENTAL_CXX0X__ #if _GNUC_VER < 403 +#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS #define _LIBCPP_HAS_NO_RVALUE_REFERENCES -#endif - -#if _GNUC_VER < 403 #define _LIBCPP_HAS_NO_STATIC_ASSERT #endif + #if _GNUC_VER < 404 #define _LIBCPP_HAS_NO_DECLTYPE #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS @@ -565,6 +569,7 @@ namespace std { #define _LIBCPP_NORETURN __attribute__((noreturn)) #define _LIBCPP_UNUSED +#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES #define _LIBCPP_HAS_NO_ADVANCED_SFINAE #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS Modified: libcxx/trunk/include/utility URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=256325&r1=256324&r2=256325&view=diff == --- libcxx/trunk/include/utility (original) +++ libcxx/trunk/include/utility Wed Dec 23 02:20:26 2015 @@ -288,6 +288,12 @@ struct _LIBCPP_TYPE_VIS_ONLY pair // pair(const pair&) = default; // pair(pair&&) = default; +#ifndef _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS +template , _Dummy>::value && +__dependent_type, _Dummy>::value + >::type> +#endif _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() : first(), second() {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 Added: libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp?rev=256325&view=auto == --- libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp (added) +++ libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp Wed Dec 23 02:20:26 2015 @@ -0,0 +1,164 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// + +// template struct pair + +// Test the SFINAE required by LWG Issue #2367. +// is_default_constructible + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +#include "test_macros.h" + +#if TEST_STD_VER > 11 +#define CONSTEXPR_CXX14 constexpr +#define STATIC_ASSERT_CXX14(Pred) static_assert(Pred, "") +#else +#define CONSTEXPR_CXX14 +#define STATIC_ASSERT_CXX14(Pred) assert(Pred) +#endif + +struct DeletedDefault { +// A class with a deleted default constructor. Used to test the SFINAE +// on std::pairs default constructor. +constexpr explicit DeletedDefault(int x) : value(x) {} +constexpr DeletedDefault() = delete; +int value; +}; + +template +struct DependantType: public Tp {}; + +template +using DependantIsDefault = DependantType, Val>; + +template +struct DefaultSFINAES { +template ::value +>::type +> +constexpr DefaultSFINAES() : value() {} +constexpr explicit
r256330 - [OPENMP 4.5] Parsing/sema for 'depend(sink:vec)' clause in 'ordered' directive.
Author: abataev Date: Wed Dec 23 04:27:45 2015 New Revision: 256330 URL: http://llvm.org/viewvc/llvm-project?rev=256330&view=rev Log: [OPENMP 4.5] Parsing/sema for 'depend(sink:vec)' clause in 'ordered' directive. OpenMP 4.5 adds 'depend(sink:vec)' in 'ordered' directive for doacross loop synchronization. Patch adds parsing and semantic analysis for this clause. Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Basic/OpenMPKinds.def cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/test/OpenMP/ordered_ast_print.cpp cfe/trunk/test/OpenMP/ordered_messages.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=256330&r1=256329&r2=256330&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Dec 23 04:27:45 2015 @@ -7951,6 +7951,16 @@ def err_omp_firstprivate_distribute_in_t "reduction variable in '#pragma omp teams' cannot be firstprivate in '#pragma omp distribute'">; def err_omp_depend_clause_thread_simd : Error< "'depend' clauses cannot be mixed with '%0' clause">; +def err_omp_depend_sink_wrong_expr : Error< + "expected expression form x[+-d], where x is the loop iteration variable and d is a constant non-negative integer">; +def err_omp_depend_sink_expected_loop_iteration : Error< + "expected %0 loop iteration variable">; +def err_omp_depend_sink_unexpected_expr : Error< + "unexpected expression: number of expressions is larger than the number of associated loops">; +def err_omp_depend_sink_expected_plus_minus : Error< + "expected '+' or '-' operation">; +def err_omp_depend_sink_source_not_allowed : Error< + "'depend(%select{source|sink:vec}0)' clause%select{|s}0 cannot be mixed with 'depend(%select{sink:vec|source}0)' clause%select{s|}0">; } // end of OpenMP category let CategoryName = "Related Result Type Issue" in { Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=256330&r1=256329&r2=256330&view=diff == --- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original) +++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Wed Dec 23 04:27:45 2015 @@ -255,6 +255,7 @@ OPENMP_DEPEND_KIND(in) OPENMP_DEPEND_KIND(out) OPENMP_DEPEND_KIND(inout) OPENMP_DEPEND_KIND(source) +OPENMP_DEPEND_KIND(sink) // Modifiers for 'linear' clause. OPENMP_LINEAR_KIND(val) Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=256330&r1=256329&r2=256330&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Wed Dec 23 04:27:45 2015 @@ -7760,8 +7760,10 @@ private: /// \brief Initialization of data-sharing attributes stack. void InitDataSharingAttributesStack(); void DestroyDataSharingAttributesStack(); - ExprResult VerifyPositiveIntegerConstantInClause(Expr *Op, - OpenMPClauseKind CKind); + ExprResult + VerifyPositiveIntegerConstantInClause(Expr *Op, OpenMPClauseKind CKind, +bool StrictlyPositive = true); + public: /// \brief Return true if the provided declaration \a VD should be captured by /// reference in the provided scope \a RSI. This will take into account the Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=256330&r1=256329&r2=256330&view=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Dec 23 04:27:45 2015 @@ -2556,6 +2556,7 @@ void CGOpenMPRuntime::emitTaskCall( DepKind = DepInOut; break; case OMPC_DEPEND_source: + case OMPC_DEPEND_sink: case OMPC_DEPEND_unknown: llvm_unreachable("Unknown task dependence type"); } Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=256330&r1=256329&r2=256330&view=diff == --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Dec 23 04:27:45 2015 @@ -89,7 +89,7 @@ private: }; typedef llvm::SmallDenseMap DeclSAMapTy; typedef llvm::SmallDenseMap AlignedMapTy; - typedef llvm::De
Re: [PATCH] D15005: Fix PR8170: Clang does not check constructor declaration that uses a template-id
faisalv added a comment. *ping* http://reviews.llvm.org/D15005 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D15743: Fix assert hit when tree-transforming template template parameter packs.
klimek created this revision. klimek added a reviewer: rsmith. klimek added a subscriber: cfe-commits. Covers significantly more code in the template template pack argument test and fixes the resulting assert problem. http://reviews.llvm.org/D15743 Files: lib/Sema/TreeTransform.h test/SemaTemplate/temp_arg_template.cpp Index: test/SemaTemplate/temp_arg_template.cpp === --- test/SemaTemplate/temp_arg_template.cpp +++ test/SemaTemplate/temp_arg_template.cpp @@ -75,7 +75,11 @@ // expected-warning@-2 {{variadic templates are a C++11 extension}} #endif -struct template_tuple {}; +struct template_tuple { +#if __cplusplus >= 201103L + static constexpr int N = sizeof...(Templates); +#endif +}; template struct identity {}; template class... Templates> Index: lib/Sema/TreeTransform.h === --- lib/Sema/TreeTransform.h +++ lib/Sema/TreeTransform.h @@ -3582,7 +3582,7 @@ case TemplateArgument::Template: case TemplateArgument::TemplateExpansion: { NestedNameSpecifierLocBuilder Builder; -TemplateName Template = Arg.getAsTemplate(); +TemplateName Template = Arg.getAsTemplateOrTemplatePattern(); if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) Builder.MakeTrivial(SemaRef.Context, DTN->getQualifier(), Loc); else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName()) Index: test/SemaTemplate/temp_arg_template.cpp === --- test/SemaTemplate/temp_arg_template.cpp +++ test/SemaTemplate/temp_arg_template.cpp @@ -75,7 +75,11 @@ // expected-warning@-2 {{variadic templates are a C++11 extension}} #endif -struct template_tuple {}; +struct template_tuple { +#if __cplusplus >= 201103L + static constexpr int N = sizeof...(Templates); +#endif +}; template struct identity {}; template class... Templates> Index: lib/Sema/TreeTransform.h === --- lib/Sema/TreeTransform.h +++ lib/Sema/TreeTransform.h @@ -3582,7 +3582,7 @@ case TemplateArgument::Template: case TemplateArgument::TemplateExpansion: { NestedNameSpecifierLocBuilder Builder; -TemplateName Template = Arg.getAsTemplate(); +TemplateName Template = Arg.getAsTemplateOrTemplatePattern(); if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) Builder.MakeTrivial(SemaRef.Context, DTN->getQualifier(), Loc); else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName()) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15737: [clang-tidy] Preserve comments and preprocessor directives when simplifying boolean expressions
alexfh added a comment. Thank you for the fix. See the comments inline. Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.cpp:493 @@ +492,3 @@ +const ast_matchers::MatchFinder::MatchResult &Result, SourceRange Range) { + CharSourceRange CharRange = Lexer::makeFileCharRange( + CharSourceRange::getTokenRange(Range), *Result.SourceManager, The range should be converted to file char range before passing it to `FixItHint::CreateReplacement`, otherwise the fix may be applied incorrectly (or not applied at all). So please move this call to `issueDiag` and pass a `CharSourceRange` here. Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.cpp:497 @@ +496,3 @@ + + std::string ReplacementText = + Lexer::getSourceText(CharRange, *Result.SourceManager, Please use `StringRef` to avoid unnecessary string allocation and copying. Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.cpp:507 @@ +506,3 @@ + while (!Lex.LexFromRawLexer(Tok)) { +if (Tok.is(tok::TokenKind::comment) || Tok.is(tok::TokenKind::hash)) { + return true; It's more common in this code to omit braces around single-line `if` bodies. Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.cpp:519 @@ +518,3 @@ +StringRef Replacement) { + if (containsDiscardedTokens(Result, ReplacementRange)) { +diag(Loc, Description); A few issues here: 1. range passed to FixItHint::CreateReplacement should be a file range, so the `makeFileCharRange` call should be moved here; 2. you can store the result of the `diag(...)` call to avoid code duplication; 3. inconsistently used braces. ``` CharSourceRange CharRange = Lexer::makeFileCharRange( CharSourceRange::getTokenRange(ReplacementRange), *Result.SourceManager, Result.Context->getLangOpts()); auto Diag = diag(Loc, Description); if (!containsDiscardedTokens(Result, CharRange)) Diag << FixItHint::CreateReplacement(CharRange, Replacement); ``` Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.cpp:533 @@ -499,3 +532,3 @@ replacementExpression(Result, Negated, UseLHS ? LHS : RHS); SourceLocation Start = LHS->getLocStart(); SourceLocation End = RHS->getLocEnd(); I'd slightly prefer to create a SourceRange right away: ``` SourceRange Range(LHS->getLocStart(), RHS->getLocEnd()); issueDiag(..., Range, ...); ``` Comment at: test/clang-tidy/readability-simplify-bool-expr.cpp:883 @@ +882,3 @@ +} +// CHECK-MESSAGES: :[[@LINE-6]]:12: warning: {{.*}} in conditional return + This test doesn't verify that the code isn't changed. I suspect, it already passes without changing the check. Please change `b` to a unique name (say, `b10`) and add ``` // CHECK-FIXES: {{^}} if (b10) { // CHECK-FIXES: {{^}}// something wicked this way comes{{$}} ``` Same below. http://reviews.llvm.org/D15737 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D15749: [X86][ms-inline asm] Test case for adding support for memory operands that include structs
myatsina created this revision. myatsina added reviewers: rnk, mcrosier. myatsina added subscribers: llvm-commits, cfe-commits. myatsina set the repository for this revision to rL LLVM. Test case for review: http://reviews.llvm.org/D15748 Repository: rL LLVM http://reviews.llvm.org/D15749 Files: test/CodeGen/ms-inline-asm.c Index: test/CodeGen/ms-inline-asm.c === --- test/CodeGen/ms-inline-asm.c +++ test/CodeGen/ms-inline-asm.c @@ -536,6 +536,38 @@ // CHECK: "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %flags) } +void t43() { +// CHECK-LABEL: define void @t43 + C strct; +// Work around PR20368: These should be single line blocks + __asm { mov eax, 4[strct.c1] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[strct.c3 + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 8[strct.c2.a + 4 + 32*2 - 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$72$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 12[4 + strct.c2.b] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$16$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[4 + strct.c4.b2.b + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$12$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[64 + strct.c1 + (2*32)] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$132$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[64 + strct.c2.a - 2*32] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [strct.c4.b1 + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [strct.c4.b2.a + 4 + 32*2 - 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$64$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [4 + strct.c1] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [4 + strct.c2.b + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [64 + strct.c3 + (2*32)] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$128$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [64 + strct.c4.b2.b - 2*32] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) +} + void call_clobber() { __asm call t41 // CHECK-LABEL: define void @call_clobber Index: test/CodeGen/ms-inline-asm.c === --- test/CodeGen/ms-inline-asm.c +++ test/CodeGen/ms-inline-asm.c @@ -536,6 +536,38 @@ // CHECK: "=*m,~{dirflag},~{fpsr},~{flags}"(i32* %flags) } +void t43() { +// CHECK-LABEL: define void @t43 + C strct; +// Work around PR20368: These should be single line blocks + __asm { mov eax, 4[strct.c1] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[strct.c3 + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$8$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 8[strct.c2.a + 4 + 32*2 - 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$72$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 12[4 + strct.c2.b] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$16$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[4 + strct.c4.b2.b + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$12$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[64 + strct.c1 + (2*32)] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$132$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, 4[64 + strct.c2.a - 2*32] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [strct.c4.b1 + 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$4$0", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) + __asm { mov eax, [strct.c4.b2.a + 4 + 32*2 - 4] } +// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr $$64
Re: r256216 - [WebAssembly] Remove the -target command-line flag from the ld commandline.
It appears the reason it was only caught on Windows was that only Windows appends ".exe" to executable files. Your change to match lld with {{.*}} appended fixes it. Thanks! Dan On Tue, Dec 22, 2015 at 2:34 PM, Nico Weber wrote: > This might have broken the test on Windows: > > Command 1 Stderr: > C:\src\chrome\src\third_party\llvm\tools\clang\test\Driver\wasm-toolchain.c:3:13: > error: expected string not found in in > put > // AS_LINK: lld" "-flavor" "ld" "[[temp]]" "-o" "a.out" > ^ > :5:476: note: scanning from here > "C:/src/chrome/src/third_party/llvm-bootstrap/./bin/clang.EXE" "-cc1as" > "-triple" "wasm32-unknown-unknown" "-filetype" > "obj" "-main-file-name" "wasm-toolchain.c" "-target-cpu" "generic" > "-dwarf-version=4" "-fdebug-compilation-dir" "C:\\src > \\chrome\\src\\third_party\\llvm-bootstrap\\tools\\clang\\test\\Driver" > "-dwarf-debug-producer" "clang version 3.8.0 (tr > unk 256248)" "-mrelocation-model" "static" "-o" > "C:\\Users\\thakis\\AppData\\Local\\Temp\\wasm-toolchain-f6ec86.o" "C:\\ > > src\\chrome\\src\\third_party\\llvm\\tools\\clang\\test\\Driver\\wasm-toolchain.c" > > > > > ^ > :5:476: note: with variable "temp" equal to > "C:UsersthakisAppDataLocalTempwasm-toolchain- > f6ec86.o" > "C:/src/chrome/src/third_party/llvm-bootstrap/./bin/clang.EXE" "-cc1as" > "-triple" "wasm32-unknown-unknown" "-filetype" > "obj" "-main-file-name" "wasm-toolchain.c" "-target-cpu" "generic" > "-dwarf-version=4" "-fdebug-compilation-dir" "C:\\src > \\chrome\\src\\third_party\\llvm-bootstrap\\tools\\clang\\test\\Driver" > "-dwarf-debug-producer" "clang version 3.8.0 (tr > unk 256248)" "-mrelocation-model" "static" "-o" > "C:\\Users\\thakis\\AppData\\Local\\Temp\\wasm-toolchain-f6ec86.o" "C:\\ > > src\\chrome\\src\\third_party\\llvm\\tools\\clang\\test\\Driver\\wasm-toolchain.c" > > > > > ^ > :6:63: note: possible intended match here > "C:\\src\\chrome\\src\\third_party\\llvm-bootstrap\\bin\\lld.exe" > "-flavor" "ld" "C:\\Users\\thakis\\AppData\\Local\\Te > mp\\wasm-toolchain-f6ec86.o" "-o" "a.out" > ^ > > I think I fixed this in 256286, but I'm a bit surprised this wasn't caught > by any LLVM bots. Can you check why this wasn't caught? > > On Mon, Dec 21, 2015 at 6:30 PM, Dan Gohman via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: djg >> Date: Mon Dec 21 17:30:41 2015 >> New Revision: 256216 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=256216&view=rev >> Log: >> [WebAssembly] Remove the -target command-line flag from the ld >> commandline. >> >> This flag isn't needed, or permitted, with the "ld" flavor of lld. >> >> Also, add a basic ld commandline test. >> >> Added: >> cfe/trunk/test/Driver/wasm-toolchain.c >> Modified: >> cfe/trunk/lib/Driver/Tools.cpp >> >> Modified: cfe/trunk/lib/Driver/Tools.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=256216&r1=256215&r2=256216&view=diff >> >> == >> --- cfe/trunk/lib/Driver/Tools.cpp (original) >> +++ cfe/trunk/lib/Driver/Tools.cpp Mon Dec 21 17:30:41 2015 >> @@ -6516,8 +6516,6 @@ void wasm::Linker::ConstructJob(Compilat >>ArgStringList CmdArgs; >>CmdArgs.push_back("-flavor"); >>CmdArgs.push_back("ld"); >> - CmdArgs.push_back("-target"); >> - >> CmdArgs.push_back(Args.MakeArgString(getToolChain().getTripleString())); >>AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs); >>CmdArgs.push_back("-o"); >>CmdArgs.push_back(Output.getFilename()); >> >> Added: cfe/trunk/test/Driver/wasm-toolchain.c >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=256216&view=auto >> >> == >> --- cfe/trunk/test/Driver/wasm-toolchain.c (added) >> +++ cfe/trunk/test/Driver/wasm-toolchain.c Mon Dec 21 17:30:41 2015 >> @@ -0,0 +1,3 @@ >> +// RUN: %clang -### -target wasm32-unknown-unknown -x assembler %s 2>&1 >> | FileCheck -check-prefix=AS_LINK %s >> +// AS_LINK: clang{{.*}}" "-cc1as" {{.*}} "-o" "[[temp:[^"]*]]" >> +// AS_LINK: lld" "-flavor" "ld" "[[temp]]" "-o" "a.out" >> >> >> ___ >> 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: r256216 - [WebAssembly] Remove the -target command-line flag from the ld commandline.
It looks like the two Windows buildbots for clang on that page are already red for other reasons. Dan On Tue, Dec 22, 2015 at 2:54 PM, Nico Weber wrote: > Well yes, but we have a Windows bot on http://lab.llvm.org:8011/console, > right? > > On Tue, Dec 22, 2015 at 5:54 PM, Dan Gohman wrote: > >> It appears the reason it was only caught on Windows was that only Windows >> appends ".exe" to executable files. Your change to match lld with {{.*}} >> appended fixes it. Thanks! >> >> Dan >> >> >> On Tue, Dec 22, 2015 at 2:34 PM, Nico Weber wrote: >> >>> This might have broken the test on Windows: >>> >>> Command 1 Stderr: >>> C:\src\chrome\src\third_party\llvm\tools\clang\test\Driver\wasm-toolchain.c:3:13: >>> error: expected string not found in in >>> put >>> // AS_LINK: lld" "-flavor" "ld" "[[temp]]" "-o" "a.out" >>> ^ >>> :5:476: note: scanning from here >>> "C:/src/chrome/src/third_party/llvm-bootstrap/./bin/clang.EXE" "-cc1as" >>> "-triple" "wasm32-unknown-unknown" "-filetype" >>> "obj" "-main-file-name" "wasm-toolchain.c" "-target-cpu" "generic" >>> "-dwarf-version=4" "-fdebug-compilation-dir" "C:\\src >>> \\chrome\\src\\third_party\\llvm-bootstrap\\tools\\clang\\test\\Driver" >>> "-dwarf-debug-producer" "clang version 3.8.0 (tr >>> unk 256248)" "-mrelocation-model" "static" "-o" >>> "C:\\Users\\thakis\\AppData\\Local\\Temp\\wasm-toolchain-f6ec86.o" "C:\\ >>> >>> src\\chrome\\src\\third_party\\llvm\\tools\\clang\\test\\Driver\\wasm-toolchain.c" >>> >>> >>> >>> >>>^ >>> :5:476: note: with variable "temp" equal to >>> "C:UsersthakisAppDataLocalTempwasm-toolchain- >>> f6ec86.o" >>> "C:/src/chrome/src/third_party/llvm-bootstrap/./bin/clang.EXE" "-cc1as" >>> "-triple" "wasm32-unknown-unknown" "-filetype" >>> "obj" "-main-file-name" "wasm-toolchain.c" "-target-cpu" "generic" >>> "-dwarf-version=4" "-fdebug-compilation-dir" "C:\\src >>> \\chrome\\src\\third_party\\llvm-bootstrap\\tools\\clang\\test\\Driver" >>> "-dwarf-debug-producer" "clang version 3.8.0 (tr >>> unk 256248)" "-mrelocation-model" "static" "-o" >>> "C:\\Users\\thakis\\AppData\\Local\\Temp\\wasm-toolchain-f6ec86.o" "C:\\ >>> >>> src\\chrome\\src\\third_party\\llvm\\tools\\clang\\test\\Driver\\wasm-toolchain.c" >>> >>> >>> >>> >>>^ >>> :6:63: note: possible intended match here >>> "C:\\src\\chrome\\src\\third_party\\llvm-bootstrap\\bin\\lld.exe" >>> "-flavor" "ld" "C:\\Users\\thakis\\AppData\\Local\\Te >>> mp\\wasm-toolchain-f6ec86.o" "-o" "a.out" >>> ^ >>> >>> I think I fixed this in 256286, but I'm a bit surprised this wasn't >>> caught by any LLVM bots. Can you check why this wasn't caught? >>> >>> On Mon, Dec 21, 2015 at 6:30 PM, Dan Gohman via cfe-commits < >>> cfe-commits@lists.llvm.org> wrote: >>> Author: djg Date: Mon Dec 21 17:30:41 2015 New Revision: 256216 URL: http://llvm.org/viewvc/llvm-project?rev=256216&view=rev Log: [WebAssembly] Remove the -target command-line flag from the ld commandline. This flag isn't needed, or permitted, with the "ld" flavor of lld. Also, add a basic ld commandline test. Added: cfe/trunk/test/Driver/wasm-toolchain.c Modified: cfe/trunk/lib/Driver/Tools.cpp Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=256216&r1=256215&r2=256216&view=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Mon Dec 21 17:30:41 2015 @@ -6516,8 +6516,6 @@ void wasm::Linker::ConstructJob(Compilat ArgStringList CmdArgs; CmdArgs.push_back("-flavor"); CmdArgs.push_back("ld"); - CmdArgs.push_back("-target"); - CmdArgs.push_back(Args.MakeArgString(getToolChain().getTripleString())); AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs); CmdArgs.push_back("-o"); CmdArgs.push_back(Output.getFilename()); Added: cfe/trunk/test/Driver/wasm-toolchain.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=256216&view=auto == --- cfe/trunk/test/Driver/wasm-toolchain.c (added) +++ cfe/trunk/test/Driver/wasm-toolchain.c Mon Dec 21 17:30:41 2015 @@ -0,0 +1,3 @@ +// RUN: %clang -### -target wasm32-unknown-unknown -x assembler %s 2>&1 | FileCheck -check-prefix=AS_LINK %s +// AS_LINK: clang{{.*}}" "-cc1as" {{.*}} "-o" "[[temp:[^"]*]]" +// AS_LINK: lld" "-flavor" "ld" "[[temp]]" "-o" "a.out" ___ cfe-commits mailing list cfe-commits@lists.llvm.org >
Re: [PATCH] D15749: [X86][ms-inline asm] Test case for adding support for memory operands that include structs
mcrosier accepted this revision. mcrosier added a comment. This revision is now accepted and ready to land. LGTM. Repository: rL LLVM http://reviews.llvm.org/D15749 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.
hokein updated this revision to Diff 43544. hokein added a comment. Update patch to address review comments. http://reviews.llvm.org/D15710 Files: clang-tidy/misc/CMakeLists.txt clang-tidy/misc/DefinitionsInHeadersCheck.cpp clang-tidy/misc/DefinitionsInHeadersCheck.h clang-tidy/misc/MiscTidyModule.cpp docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/misc-definitions-in-headers.rst unittests/clang-tidy/MiscModuleTest.cpp Index: unittests/clang-tidy/MiscModuleTest.cpp === --- unittests/clang-tidy/MiscModuleTest.cpp +++ unittests/clang-tidy/MiscModuleTest.cpp @@ -1,5 +1,6 @@ #include "ClangTidyTest.h" #include "misc/ArgumentCommentCheck.h" +#include "misc/DefinitionsInHeadersCheck.h" #include "gtest/gtest.h" namespace clang { @@ -34,6 +35,180 @@ "void f(int xxx, int yyy); void g() { f(/*xxy=*/0, 0); }"); } +class DefinitionsInHeadersCheckTest : public ::testing::Test { +protected: + std::string runCheckOnCode(const std::string &Code, + const std::string &Filename) { +std::vector Errors; +std::vector Args; +if (!StringRef(Filename).endswith(".cpp")) { + Args.emplace_back("-xc++-header"); +} +test::runCheckOnCode( +Code, &Errors, Filename, Args); +if (Errors.empty()) + return ""; +return Errors[0].Message.Message; + } +}; + +TEST_F(DefinitionsInHeadersCheckTest, FunctionDefinition) { + const std::string errorMessage = +"function definition is not allowed in header file"; + const std::string okMessage = ""; + EXPECT_EQ(errorMessage, runCheckOnCode("int f() { return 0; }", "foo.h")); + EXPECT_EQ(errorMessage, runCheckOnCode("int f();\n" + "int f() { return 1; }", "foo.h")); + EXPECT_EQ(errorMessage, runCheckOnCode("class A {\n" + " int f();\n" + "};\n" + "int A::f() { return 1; }", "foo.h")); + EXPECT_EQ(errorMessage, runCheckOnCode("namespace A {\n" + " int f() { return 1; }\n" + "}", "foo.h")); + EXPECT_EQ(errorMessage, runCheckOnCode("template \n" + "T f() {\n" + " T a = 1;\n" + " return a;\n" + "}\n" + "template <>\n" + "int f() {\n" + " int a = 1;\n" + " return a;\n" + "}", "foo.h")); + EXPECT_EQ(errorMessage, runCheckOnCode("struct A {\n" + " template\n" + " T f() {\n" + "T a = 1;\n" + "return a;\n" + " }\n" + "};\n" + "template<>\n" + "int A::f() {\n" + " int a = 1;\n" + " return a;\n" + "}", "foo.h")); + + EXPECT_EQ(okMessage, runCheckOnCode("int f();", "foo.h")); + EXPECT_EQ(okMessage, runCheckOnCode("inline int f() { return 1; }", + "foo.h")); + EXPECT_EQ(okMessage, runCheckOnCode("namespace {\n" + " int f() { return 1; }\n" + "}", "foo.h")); + EXPECT_EQ(okMessage, runCheckOnCode("int f() { return 1; }\n", + "foo.cc")); + EXPECT_EQ(okMessage, runCheckOnCode("class A {\n" + " int f() { return 1; }\n" + "};", "foo.h")); + EXPECT_EQ(okMessage, runCheckOnCode("struct A {\n" + " template\n" + " T f() {\n" + "T a = 1;\n" + "return a;\n" + " }\n" + "};\n", "foo.h")); + EXPECT_EQ(okMessage, runCheckOnCode("template\n" + "struct A {\n" + " static void f();\n" + "};\n" + "template \n" + "void A::f() {\n" + " T a;\n" + "}", "foo.h")); + EXPECT_EQ(okMessage, runChe
Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.
hokein marked 9 inline comments as done. Comment at: clang-tidy/google/DefinitionsInHeadersCheck.cpp:52 @@ +51,3 @@ +// Inline function is allowed. +if (funDecl->isInlined()) + return; alexfh wrote: > This check can be done in the matcher. The `isInline` AST matcher seems only match the function with `inline` key words. It could not detect the member function defined within class, such as: ``` class A { int f() { return 1; } }; ``` Comment at: clang-tidy/google/DefinitionsInHeadersCheck.h:17 @@ +16,3 @@ +namespace tidy { +namespace google { + alexfh wrote: > This check is generic enough. It should go to the `misc` module, IMO. Done. Move to `misc` module Comment at: unittests/clang-tidy/GoogleModuleTest.cpp:140 @@ +139,3 @@ + "}", "foo.h")); + EXPECT_EQ(errorMessage, runCheckOnCode("template \n" + "T f() {\n" alexfh wrote: > I think, we can already use raw string literals (at least, MSVC 2013 seems to > support them). Raw string literals would make the test cases more readable, > imo. The Raw string literals doesn't work well with multiple lines in macro. I try it on my local machine, it will break compilation. http://reviews.llvm.org/D15710 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.
hokein added a comment. @alexfh The case of member function of a nest class in a class template (like `int A::B::fun() {...}`) is also fixed now. Please review the patch again. Thanks. http://reviews.llvm.org/D15710 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r256342 - clang-format: Fix incorrect pointer detection.
Author: djasper Date: Wed Dec 23 12:01:29 2015 New Revision: 256342 URL: http://llvm.org/viewvc/llvm-project?rev=256342&view=rev Log: clang-format: Fix incorrect pointer detection. Before: return * this += 1; After: return *this += 1; Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTest.cpp Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=256342&r1=256341&r2=256342&view=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Dec 23 12:01:29 2015 @@ -831,7 +831,7 @@ private: void modifyContext(const FormatToken &Current) { if (Current.getPrecedence() == prec::Assignment && -!Line.First->isOneOf(tok::kw_template, tok::kw_using) && +!Line.First->isOneOf(tok::kw_template, tok::kw_using, tok::kw_return) && (!Current.Previous || Current.Previous->isNot(tok::kw_operator))) { Contexts.back().IsExpression = true; if (!Line.startsWith(TT_UnaryOperator)) { Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=256342&r1=256341&r2=256342&view=diff == --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Dec 23 12:01:29 2015 @@ -5613,6 +5613,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStar Left.PointerAlignment = FormatStyle::PAS_Left; verifyFormat("x = *a(x) = *a(y);", Left); verifyFormat("for (;; * = b) {\n}", Left); + verifyFormat("return *this += 1;", Left); verifyIndependentOfContext("a = *(x + y);"); verifyIndependentOfContext("a = &(x + y);"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r256343 - clang-format: Lower penalty for breaking between array subscripts.
Author: djasper Date: Wed Dec 23 12:01:43 2015 New Revision: 256343 URL: http://llvm.org/viewvc/llvm-project?rev=256343&view=rev Log: clang-format: Lower penalty for breaking between array subscripts. Before: a[aaa()][bbb( )] After: a[aaa()] [bbb()] Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTest.cpp Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=256343&r1=256342&r2=256343&view=diff == --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Dec 23 12:01:43 2015 @@ -1722,7 +1722,7 @@ unsigned TokenAnnotator::splitPenalty(co Right.Next->is(TT_DictLiteral))) return 1; if (Right.is(tok::l_square)) { -if (Style.Language == FormatStyle::LK_Proto) +if (Style.Language == FormatStyle::LK_Proto || Left.is(tok::r_square)) return 1; // Slightly prefer formatting local lambda definitions like functions. if (Right.is(TT_LambdaLSquare) && Left.is(tok::equal)) Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=256343&r1=256342&r2=256343&view=diff == --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Dec 23 12:01:43 2015 @@ -6044,6 +6044,8 @@ TEST_F(FormatTest, BreaksLongDeclaration TEST_F(FormatTest, FormatsArrays) { verifyFormat("a[a]\n" " [b] = c;"); + verifyFormat("a[aaa()]\n" + " [bbb()] = c;"); verifyFormat("aa\n" "[] = ccc;"); verifyFormat("aa\n" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15705: Adding a scripted test for PR25717
ygao added a comment. Hi Rafael, Yes I can do that, and it works for me. Do you know whether there is a way to keep the UNIX line ending on the test file upon checkout rather than having svn or git auto-translate the line endings? The UNIX line ending is necessary to trigger the original bug, - Gao http://reviews.llvm.org/D15705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15705: Adding a scripted test for PR25717
ygao updated this revision to Diff 43554. ygao added a comment. I think what I can do is to run svn propset svn:eol-style 'LF' on the new file, and hopefully the subversion or git client will get the hint and not auto-translate the line endings. http://reviews.llvm.org/D15705 Files: test/Preprocessor/macro.c Index: test/Preprocessor/macro.c === --- test/Preprocessor/macro.c +++ test/Preprocessor/macro.c @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -E -x c %s | FileCheck %s +// The original bug requires UNIX line endings to trigger. + +// Make sure clang does not crash during preprocessing +// CHECK-NOT: fatal error + +#define M0 extern int x; +#define M2 M0 M0 M0 M0 +#define M4 M2 M2 M2 M2 +#define M6 M4 M4 M4 M4 +#define M8 M6 M6 M6 M6 +#define M10 M8 M8 M8 M8 +#define M12 M10 M10 M10 M10 +#define M14 M12 M12 M12 M12 + +M14 Index: test/Preprocessor/macro.c === --- test/Preprocessor/macro.c +++ test/Preprocessor/macro.c @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -E -x c %s | FileCheck %s +// The original bug requires UNIX line endings to trigger. + +// Make sure clang does not crash during preprocessing +// CHECK-NOT: fatal error + +#define M0 extern int x; +#define M2 M0 M0 M0 M0 +#define M4 M2 M2 M2 M2 +#define M6 M4 M4 M4 M4 +#define M8 M6 M6 M6 M6 +#define M10 M8 M8 M8 M8 +#define M12 M10 M10 M10 M10 +#define M14 M12 M12 M12 M12 + +M14 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r256349 - Replace isa+cast with dyn_cast and obey the no else after return rule.
Author: yrnkrn Date: Wed Dec 23 14:38:13 2015 New Revision: 256349 URL: http://llvm.org/viewvc/llvm-project?rev=256349&view=rev Log: Replace isa+cast with dyn_cast and obey the no else after return rule. Modified: cfe/trunk/lib/Sema/SemaExpr.cpp Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=256349&r1=256348&r2=256349&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Dec 23 14:38:13 2015 @@ -4928,14 +4928,10 @@ Sema::ActOnCallExpr(Scope *S, Expr *Fn, // We aren't supposed to apply this logic for if there's an '&' involved. if (!find.HasFormOfMemberPointer) { OverloadExpr *ovl = find.Expression; - if (isa(ovl)) { -UnresolvedLookupExpr *ULE = cast(ovl); + if (UnresolvedLookupExpr *ULE = dyn_cast(ovl)) return BuildOverloadedCallExpr(S, Fn, ULE, LParenLoc, ArgExprs, RParenLoc, ExecConfig); - } else { -return BuildCallToMemberFunction(S, Fn, LParenLoc, ArgExprs, - RParenLoc); - } + return BuildCallToMemberFunction(S, Fn, LParenLoc, ArgExprs, RParenLoc); } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15705: Adding a scripted test for PR25717
Are you sure the line ending in a problem? The preprocessor output has 16 lines, but the last one is very long. In any case, it looks like at least on linux clang produces an output with '\n' even when the input has CRLF: $ file test.c test.c: ASCII text, with CRLF line terminators $ clang -E test.c > test.i $ file test.i test.i: C source, ASCII text, with very long lines Cheers, Rafael On 23 December 2015 at 15:22, Yunzhong Gao wrote: > ygao updated this revision to Diff 43554. > ygao added a comment. > > I think what I can do is to run > svn propset svn:eol-style 'LF' > on the new file, and hopefully the subversion or git client will get the hint > and not auto-translate the line endings. > > > http://reviews.llvm.org/D15705 > > Files: > test/Preprocessor/macro.c > > Index: test/Preprocessor/macro.c > === > --- test/Preprocessor/macro.c > +++ test/Preprocessor/macro.c > @@ -0,0 +1,16 @@ > +// RUN: %clang_cc1 -E -x c %s | FileCheck %s > +// The original bug requires UNIX line endings to trigger. > + > +// Make sure clang does not crash during preprocessing > +// CHECK-NOT: fatal error > + > +#define M0 extern int x; > +#define M2 M0 M0 M0 M0 > +#define M4 M2 M2 M2 M2 > +#define M6 M4 M4 M4 M4 > +#define M8 M6 M6 M6 M6 > +#define M10 M8 M8 M8 M8 > +#define M12 M10 M10 M10 M10 > +#define M14 M12 M12 M12 M12 > + > +M14 > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15705: Adding a scripted test for PR25717
ygao added a comment. If you take a look at void PrintPreprocessedAction::ExecuteAction() { ... while (next < end) { if (*cur == 0x0D) { // CR if (*next == 0x0A) // CRLF BinaryMode = false; ... The value of this BinaryMode reflects whether the line ending style of the input file is CRLF or LF. And it is passed all the way down to the constructor of raw_fd_ostream, std::unique_ptr CompilerInstance::createOutputFile(...) { ... if (!Binary || OS->supportsSeeking()) return std::move(OS); auto B = llvm::make_unique(*OS); ... So I think the line ending style of the input file does affect whether the output is buffered. http://reviews.llvm.org/D15705 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15705: Adding a scripted test for PR25717
Gosh, that is quite unfortunate. The problems I see are * The code only work on windows, as opening a file as text on other systems is not special. * There is a confusion in the code about binary being "crlf translation" or "produce a .o". The logic for creating a buffer is there because the .o writer needs something it can seek on. What I would suggest is: * Check that this test fails at least on windows with your patch reverted. If so, commit it. BTW, don't you need to drop the "| FileCheck" to cause a crash? * Pass two flags to createDefaultOutputFile: TranslateCrLf and NeedsSeek instead of just Binary. * Stop using F_Text flag and just print the correct line ending so this works on any system. The last two can be just a bug report for now :-) Cheers, Rafael On 23 December 2015 at 17:43, Yunzhong Gao wrote: > ygao added a comment. > > If you take a look at > > void PrintPreprocessedAction::ExecuteAction() { > ... > while (next < end) { > if (*cur == 0x0D) { // CR > if (*next == 0x0A) // CRLF > BinaryMode = false; > ... > > The value of this BinaryMode reflects whether the line ending style of the > input file > is CRLF or LF. And it is passed all the way down to the constructor of > raw_fd_ostream, > > std::unique_ptr > CompilerInstance::createOutputFile(...) { > ... > if (!Binary || OS->supportsSeeking()) > return std::move(OS); > > auto B = llvm::make_unique(*OS); > ... > > So I think the line ending style of the input file does affect whether the > output is buffered. > > > http://reviews.llvm.org/D15705 > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r256358 - [StaticAnalyzer] Use front() and back() instead of dereferencing begin() and rbegin(). Makes the code a little cleaner. NFC
Author: ctopper Date: Wed Dec 23 20:55:45 2015 New Revision: 256358 URL: http://llvm.org/viewvc/llvm-project?rev=256358&view=rev Log: [StaticAnalyzer] Use front() and back() instead of dereferencing begin() and rbegin(). Makes the code a little cleaner. NFC Modified: cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp?rev=256358&r1=256357&r2=256358&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp Wed Dec 23 20:55:45 2015 @@ -123,10 +123,10 @@ void HTMLDiagnostics::ReportDiag(const P // The path as already been prechecked that all parts of the path are // from the same file and that it is non-empty. - const SourceManager &SMgr = (*path.begin())->getLocation().getManager(); + const SourceManager &SMgr = path.front()->getLocation().getManager(); assert(!path.empty()); FileID FID = -(*path.begin())->getLocation().asLocation().getExpansionLoc().getFileID(); +path.front()->getLocation().asLocation().getExpansionLoc().getFileID(); assert(FID.isValid()); // Create a new rewriter to generate HTML. @@ -144,7 +144,7 @@ void HTMLDiagnostics::ReportDiag(const P // Retrieve the relative position of the declaration which will be used // for the file name FullSourceLoc L( - SMgr.getExpansionLoc((*path.rbegin())->getLocation().asLocation()), + SMgr.getExpansionLoc(path.back()->getLocation().asLocation()), SMgr); FullSourceLoc FunL(SMgr.getExpansionLoc(Body->getLocStart()), SMgr); offsetDecl = L.getExpansionLineNumber() - FunL.getExpansionLineNumber(); @@ -188,8 +188,8 @@ void HTMLDiagnostics::ReportDiag(const P DirName += '/'; } - int LineNumber = (*path.rbegin())->getLocation().asLocation().getExpansionLineNumber(); - int ColumnNumber = (*path.rbegin())->getLocation().asLocation().getExpansionColumnNumber(); + int LineNumber = path.back()->getLocation().asLocation().getExpansionLineNumber(); + int ColumnNumber = path.back()->getLocation().asLocation().getExpansionColumnNumber(); // Add the name of the file as an tag. Modified: cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp?rev=256358&r1=256357&r2=256358&view=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp Wed Dec 23 20:55:45 2015 @@ -295,7 +295,7 @@ void PlistDiagnostics::FlushDiagnosticsI const SourceManager* SM = nullptr; if (!Diags.empty()) -SM = &(*(*Diags.begin())->path.begin())->getLocation().getManager(); +SM = &Diags.front()->path.front()->getLocation().getManager(); for (std::vector::iterator DI = Diags.begin(), ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r256359 - [TrailingObjects] Convert ASTTemplateKWAndArgsInfo and ASTTemplateArgumentListInfo.
Author: jyknight Date: Wed Dec 23 20:59:37 2015 New Revision: 256359 URL: http://llvm.org/viewvc/llvm-project?rev=256359&view=rev Log: [TrailingObjects] Convert ASTTemplateKWAndArgsInfo and ASTTemplateArgumentListInfo. Doing so required separating them so that the former doesn't inherit from the latter anymore. Investigating that, it became clear that the inheritance wasn't actually providing real value in any case. So also: - Remove a bunch of redundant functions (getExplicitTemplateArgs, getOptionalExplicitTemplateArgs) on various Expr subclasses which depended on the inheritance relationship. - Switched external callers to use pre-existing accessors that return the data they're actually interested in (getTemplateArgs, getNumTemplateArgs, etc). - Switched internal callers to use pre-existing getTemplateKWAndArgsInfo. Modified: cfe/trunk/include/clang/AST/Expr.h cfe/trunk/include/clang/AST/ExprCXX.h cfe/trunk/include/clang/AST/RecursiveASTVisitor.h cfe/trunk/include/clang/AST/TemplateBase.h cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/lib/AST/StmtProfile.cpp cfe/trunk/lib/AST/TemplateBase.cpp cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp cfe/trunk/lib/Serialization/ASTWriterStmt.cpp cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang/AST/Expr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=256359&r1=256358&r2=256359&view=diff == --- cfe/trunk/include/clang/AST/Expr.h (original) +++ cfe/trunk/include/clang/AST/Expr.h Wed Dec 23 20:59:37 2015 @@ -1097,7 +1097,7 @@ public: /// this name, if any. SourceLocation getTemplateKeywordLoc() const { if (!hasTemplateKWAndArgsInfo()) return SourceLocation(); -return getTemplateKWAndArgsInfo()->getTemplateKeywordLoc(); +return getTemplateKWAndArgsInfo()->TemplateKWLoc; } /// \brief Retrieve the location of the left angle bracket starting the @@ -1122,32 +1122,11 @@ public: /// explicit template argument list. bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); } - /// \brief Retrieve the explicit template argument list that followed the - /// member template name. - ASTTemplateArgumentListInfo &getExplicitTemplateArgs() { -assert(hasExplicitTemplateArgs()); -return *getTemplateKWAndArgsInfo(); - } - - /// \brief Retrieve the explicit template argument list that followed the - /// member template name. - const ASTTemplateArgumentListInfo &getExplicitTemplateArgs() const { -return const_cast(this)->getExplicitTemplateArgs(); - } - - /// \brief Retrieves the optional explicit template arguments. - /// This points to the same data as getExplicitTemplateArgs(), but - /// returns null if there are no explicit template arguments. - const ASTTemplateArgumentListInfo *getOptionalExplicitTemplateArgs() const { -if (!hasExplicitTemplateArgs()) return nullptr; -return &getExplicitTemplateArgs(); - } - /// \brief Copies the template arguments (if present) into the given /// structure. void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { if (hasExplicitTemplateArgs()) - getExplicitTemplateArgs().copyInto(List); + getTemplateKWAndArgsInfo()->copyInto(List); } /// \brief Retrieve the template arguments provided as part of this @@ -1156,7 +1135,7 @@ public: if (!hasExplicitTemplateArgs()) return nullptr; -return getExplicitTemplateArgs().getTemplateArgs(); +return getTemplateKWAndArgsInfo()->getTemplateArgs(); } /// \brief Retrieve the number of template arguments provided as part of this @@ -1165,7 +1144,7 @@ public: if (!hasExplicitTemplateArgs()) return 0; -return getExplicitTemplateArgs().NumTemplateArgs; +return getTemplateKWAndArgsInfo()->NumTemplateArgs; } /// \brief Returns true if this expression refers to a function that @@ -2502,7 +2481,7 @@ public: /// the member name, if any. SourceLocation getTemplateKeywordLoc() const { if (!HasTemplateKWAndArgsInfo) return SourceLocation(); -return getTemplateKWAndArgsInfo()->getTemplateKeywordLoc(); +return getTemplateKWAndArgsInfo()->TemplateKWLoc; } /// \brief Retrieve the location of the left angle bracket starting the @@ -2530,30 +2509,7 @@ public: /// structure. void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { if (hasExplicitTemplateArgs()) - getExplicitTemplateArgs().copyInto(List); - } - - /// \brief Retrieve the explicit template argument list that - /// follow the member template name. This must only be called on an - /// expression with explicit template arguments. - ASTTemplateArgumentListInfo &getExplicitTemplateArgs() { -assert(hasExplicitTemplateArgs()); -return *getTemplateKWAndArgsInfo(); - } - - /// \brief Retrieve the explici