[PATCH] D38061: Set AnonymousTagLocations false for ASTContext if column info is expected not to be used
twoh updated this revision to Diff 164564. twoh edited the summary of this revision. twoh added a comment. Herald added a subscriber: cfe-commits. Addressing comments from @echristo. Reverted option name change, and added a test case. Sorry I haven't work on this code for a while so it took time to invent a test case. Repository: rC Clang https://reviews.llvm.org/D38061 Files: lib/AST/Expr.cpp lib/CodeGen/CGDebugInfo.cpp lib/Frontend/CompilerInstance.cpp test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp test/CodeGenCXX/debug-info-anonymous.cpp test/Sema/assign.c test/Sema/enum.c test/Sema/switch.c test/SemaCXX/condition.cpp test/SemaCXX/enum.cpp test/SemaCXX/lambda-expressions.cpp test/SemaCXX/pass-object-size.cpp test/SemaCXX/warn-sign-conversion.cpp Index: test/SemaCXX/warn-sign-conversion.cpp === --- test/SemaCXX/warn-sign-conversion.cpp +++ test/SemaCXX/warn-sign-conversion.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -verify -fsyntax-only -Wsign-conversion %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -dwarf-column-info -verify -fsyntax-only -Wsign-conversion %s // NOTE: When a 'enumeral mismatch' warning is implemented then expect several // of the following cases to be impacted. Index: test/SemaCXX/pass-object-size.cpp === --- test/SemaCXX/pass-object-size.cpp +++ test/SemaCXX/pass-object-size.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 +// RUN: %clang_cc1 -dwarf-column-info -fsyntax-only -verify %s -std=c++11 namespace simple { int Foo(void *const p __attribute__((pass_object_size(0; Index: test/SemaCXX/lambda-expressions.cpp === --- test/SemaCXX/lambda-expressions.cpp +++ test/SemaCXX/lambda-expressions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify -fblocks %s +// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -dwarf-column-info -fsyntax-only -verify -fblocks %s namespace std { class type_info; }; Index: test/SemaCXX/enum.cpp === --- test/SemaCXX/enum.cpp +++ test/SemaCXX/enum.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++98 -verify -triple x86_64-apple-darwin %s -// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++11 -verify -triple x86_64-apple-darwin %s +// RUN: %clang_cc1 -dwarf-column-info -fsyntax-only -pedantic -std=c++98 -verify -triple x86_64-apple-darwin %s +// RUN: %clang_cc1 -dwarf-column-info -fsyntax-only -pedantic -std=c++11 -verify -triple x86_64-apple-darwin %s enum E { // expected-note{{previous definition is here}} Val1, Val2 Index: test/SemaCXX/condition.cpp === --- test/SemaCXX/condition.cpp +++ test/SemaCXX/condition.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// RUN: %clang_cc1 -dwarf-column-info -fsyntax-only -verify -std=c++11 %s void test() { int x; Index: test/Sema/switch.c === --- test/Sema/switch.c +++ test/Sema/switch.c @@ -1,8 +1,8 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-enum -Wcovered-switch-default -triple x86_64-linux-gnu %s -void f (int z) { - while (z) { +// RUN: %clang_cc1 -dwarf-column-info -fsyntax-only -verify -Wswitch-enum -Wcovered-switch-default -triple x86_64-linux-gnu %s +void f (int z) { + while (z) { default: z--;// expected-error {{statement not in switch}} - } + } } void foo(int X) { @@ -22,7 +22,7 @@ } } -void test3(void) { +void test3(void) { // empty switch; switch (0); // expected-warning {{no case matching constant switch condition '0'}} \ // expected-warning {{switch statement has empty body}} \ @@ -45,33 +45,33 @@ case 0 ... g(): // expected-error {{expression is not an integer constant expression}} break; } - + switch (cond) { case 0 && g() ... 1 || g(): break; } - + switch (cond) { case g() // expected-error {{expression is not an integer constant expression}} && 0: break; } - + switch (cond) { case 0 ... g() // expected-error {{expression is not an integer constant expression}} || 1: break; } } -void test5(int z) { +void test5(int z) { switch(z) { default: // expected-note {{previous case defined here}} default: // expected-error {{multiple default labels in one switch}} break; } -} +} void test6() { char ch = 'a'; @@ -187,7 +187,7 @@ case 0 ... //expected-warning{{case value not in enumerated type 'enum (anonymous enum}} 1: //expected-warning{{case value not in enumerated type 'enum (anonymous enum}} case 2 ... 4: -case
[PATCH] D51824: StmtPrinter: allow customizing the end-of-line character
george.karpenkov created this revision. george.karpenkov added reviewers: NoQ, Eugene.Zelenko. Some environments need a different end-of-line character, namely, dot graphs. There, "\l" must be used to left-adjust the printed text, as "\n" centers everything printed. https://reviews.llvm.org/D51824 Files: clang/include/clang/AST/Stmt.h clang/lib/AST/DeclPrinter.cpp clang/lib/AST/StmtPrinter.cpp Index: clang/lib/AST/StmtPrinter.cpp === --- clang/lib/AST/StmtPrinter.cpp +++ clang/lib/AST/StmtPrinter.cpp @@ -69,14 +69,16 @@ unsigned IndentLevel; PrinterHelper* Helper; PrintingPolicy Policy; +std::string NewlineSymbol; const ASTContext *Context; public: StmtPrinter(raw_ostream , PrinterHelper *helper, const PrintingPolicy , unsigned Indentation = 0, +StringRef NewlineSymbol = "\n", const ASTContext *Context = nullptr) : OS(os), IndentLevel(Indentation), Helper(helper), Policy(Policy), - Context(Context) {} + NewlineSymbol(NewlineSymbol), Context(Context) {} void PrintStmt(Stmt *S) { PrintStmt(S, Policy.Indentation); @@ -88,11 +90,11 @@ // If this is an expr used in a stmt context, indent and newline it. Indent(); Visit(S); -OS << ";\n"; +OS << ";" << NewlineSymbol; } else if (S) { Visit(S); } else { -Indent() << "<<>>\n"; +Indent() << "<<>>" << NewlineSymbol; } IndentLevel -= SubIndent; } @@ -128,7 +130,7 @@ } void VisitStmt(Stmt *Node) LLVM_ATTRIBUTE_UNUSED { - Indent() << "<>\n"; + Indent() << "<>" << NewlineSymbol; } void VisitExpr(Expr *Node) LLVM_ATTRIBUTE_UNUSED { @@ -152,7 +154,7 @@ /// PrintRawCompoundStmt - Print a compound stmt without indenting the {, and /// with no newline after the }. void StmtPrinter::PrintRawCompoundStmt(CompoundStmt *Node) { - OS << "{\n"; + OS << "{" << NewlineSymbol; for (auto *I : Node->body()) PrintStmt(I); @@ -169,19 +171,19 @@ } void StmtPrinter::VisitNullStmt(NullStmt *Node) { - Indent() << ";\n"; + Indent() << ";" << NewlineSymbol; } void StmtPrinter::VisitDeclStmt(DeclStmt *Node) { Indent(); PrintRawDeclStmt(Node); - OS << ";\n"; + OS << ";" << NewlineSymbol; } void StmtPrinter::VisitCompoundStmt(CompoundStmt *Node) { Indent(); PrintRawCompoundStmt(Node); - OS << "\n"; + OS << "" << NewlineSymbol; } void StmtPrinter::VisitCaseStmt(CaseStmt *Node) { @@ -191,18 +193,18 @@ OS << " ... "; PrintExpr(Node->getRHS()); } - OS << ":\n"; + OS << ":" << NewlineSymbol; PrintStmt(Node->getSubStmt(), 0); } void StmtPrinter::VisitDefaultStmt(DefaultStmt *Node) { - Indent(-1) << "default:\n"; + Indent(-1) << "default:" << NewlineSymbol; PrintStmt(Node->getSubStmt(), 0); } void StmtPrinter::VisitLabelStmt(LabelStmt *Node) { - Indent(-1) << Node->getName() << ":\n"; + Indent(-1) << Node->getName() << ":" << NewlineSymbol; PrintStmt(Node->getSubStmt(), 0); } @@ -225,9 +227,9 @@ if (auto *CS = dyn_cast(If->getThen())) { OS << ' '; PrintRawCompoundStmt(CS); -OS << (If->getElse() ? ' ' : '\n'); +OS << (If->getElse() ? " " : NewlineSymbol); } else { -OS << '\n'; +OS << NewlineSymbol; PrintStmt(If->getThen()); if (If->getElse()) Indent(); } @@ -238,12 +240,12 @@ if (auto *CS = dyn_cast(Else)) { OS << ' '; PrintRawCompoundStmt(CS); - OS << '\n'; + OS << NewlineSymbol; } else if (auto *ElseIf = dyn_cast(Else)) { OS << ' '; PrintRawIfStmt(ElseIf); } else { - OS << '\n'; + OS << NewlineSymbol; PrintStmt(If->getElse()); } } @@ -266,9 +268,9 @@ if (auto *CS = dyn_cast(Node->getBody())) { OS << " "; PrintRawCompoundStmt(CS); -OS << "\n"; +OS << NewlineSymbol; } else { -OS << "\n"; +OS << NewlineSymbol; PrintStmt(Node->getBody()); } } @@ -279,7 +281,7 @@ PrintRawDeclStmt(DS); else PrintExpr(Node->getCond()); - OS << ")\n"; + OS << ")" << NewlineSymbol; PrintStmt(Node->getBody()); } @@ -289,14 +291,14 @@ PrintRawCompoundStmt(CS); OS << " "; } else { -OS << "\n"; +OS << NewlineSymbol; PrintStmt(Node->getBody()); Indent(); } OS << "while ("; PrintExpr(Node->getCond()); - OS << ");\n"; + OS << ");" << NewlineSymbol; } void StmtPrinter::VisitForStmt(ForStmt *Node) { @@ -321,9 +323,9 @@ if (auto *CS = dyn_cast(Node->getBody())) { PrintRawCompoundStmt(CS); -OS << "\n"; +OS << NewlineSymbol; } else { -OS << "\n"; +OS << NewlineSymbol; PrintStmt(Node->getBody()); } } @@ -340,9 +342,9 @@ if (auto *CS = dyn_cast(Node->getBody())) { PrintRawCompoundStmt(CS); -OS << "\n"; +OS << NewlineSymbol; } else { -
[PATCH] D51822: Support generating unique identifiers for Stmt objects
george.karpenkov created this revision. george.karpenkov added reviewers: NoQ, rsmith, bogner, aprantl, arphaman. Unlike pointer values, those identifiers are reproducible between the runs. https://reviews.llvm.org/D51822 Files: clang/include/clang/AST/Stmt.h clang/lib/AST/Stmt.cpp Index: clang/lib/AST/Stmt.cpp === --- clang/lib/AST/Stmt.cpp +++ clang/lib/AST/Stmt.cpp @@ -302,6 +302,14 @@ llvm_unreachable("unknown statement kind"); } +int64_t Stmt::getID(const ASTContext ) const { + Optional Out = Context.getAllocator().identifyObject(this); + assert(Out && "Wrong allocator used"); + assert(*Out % alignof(Stmt) == 0 && "Wrong alignment information"); + return *Out / alignof(Stmt); + +} + CompoundStmt::CompoundStmt(ArrayRef Stmts, SourceLocation LB, SourceLocation RB) : Stmt(CompoundStmtClass), LBraceLoc(LB), RBraceLoc(RB) { Index: clang/include/clang/AST/Stmt.h === --- clang/include/clang/AST/Stmt.h +++ clang/include/clang/AST/Stmt.h @@ -413,6 +413,9 @@ void dump(raw_ostream , SourceManager ) const; void dump(raw_ostream ) const; + /// \return Unique reproducible object identifier + int64_t getID(const ASTContext ) const; + /// dumpColor - same as dump(), but forces color highlighting. void dumpColor() const; Index: clang/lib/AST/Stmt.cpp === --- clang/lib/AST/Stmt.cpp +++ clang/lib/AST/Stmt.cpp @@ -302,6 +302,14 @@ llvm_unreachable("unknown statement kind"); } +int64_t Stmt::getID(const ASTContext ) const { + Optional Out = Context.getAllocator().identifyObject(this); + assert(Out && "Wrong allocator used"); + assert(*Out % alignof(Stmt) == 0 && "Wrong alignment information"); + return *Out / alignof(Stmt); + +} + CompoundStmt::CompoundStmt(ArrayRef Stmts, SourceLocation LB, SourceLocation RB) : Stmt(CompoundStmtClass), LBraceLoc(LB), RBraceLoc(RB) { Index: clang/include/clang/AST/Stmt.h === --- clang/include/clang/AST/Stmt.h +++ clang/include/clang/AST/Stmt.h @@ -413,6 +413,9 @@ void dump(raw_ostream , SourceManager ) const; void dump(raw_ostream ) const; + /// \return Unique reproducible object identifier + int64_t getID(const ASTContext ) const; + /// dumpColor - same as dump(), but forces color highlighting. void dumpColor() const; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51817: Do not use optimized atomic libcalls for misaligned atomics.
This revision was automatically updated to reflect the committed changes. Closed by commit rL341734: Do not use optimized atomic libcalls for misaligned atomics. (authored by rsmith, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D51817 Files: cfe/trunk/lib/CodeGen/CGAtomic.cpp cfe/trunk/test/CodeGen/atomic-ops.c Index: cfe/trunk/test/CodeGen/atomic-ops.c === --- cfe/trunk/test/CodeGen/atomic-ops.c +++ cfe/trunk/test/CodeGen/atomic-ops.c @@ -198,10 +198,12 @@ struct S fd1(struct S *a) { // CHECK-LABEL: @fd1 // CHECK: [[RETVAL:%.*]] = alloca %struct.S, align 4 - // CHECK: bitcast %struct.S* {{.*}} to i64* + // CHECK: [[A:%.*]] = bitcast %struct.S* {{.*}} to i64* // CHECK: [[CAST:%.*]] = bitcast %struct.S* [[RETVAL]] to i64* - // CHECK: [[CALL:%.*]] = call i64 @__atomic_load_8( - // CHECK: store i64 [[CALL]], i64* [[CAST]], align 4 + // CHECK: [[SRC:%.*]] = bitcast i64* [[A]] to i8* + // CHECK: [[DEST:%.*]] = bitcast i64* [[CAST]] to i8* + // CHECK: call void @__atomic_load(i32 8, i8* [[SRC]], i8* [[DEST]], i32 5) + // CHECK: ret struct S ret; __atomic_load(a, , memory_order_seq_cst); return ret; @@ -218,8 +220,8 @@ // CHECK-NEXT: [[COERCED_A_TMP:%.*]] = bitcast %struct.S* [[LOAD_A_PTR]] to i64* // CHECK-NEXT: [[COERCED_B:%.*]] = bitcast %struct.S* [[LOAD_B_PTR]] to i64* // CHECK-NEXT: [[COERCED_A:%.*]] = bitcast i64* [[COERCED_A_TMP]] to i8* - // CHECK-NEXT: [[LOAD_B:%.*]] = load i64, i64* [[COERCED_B]], align 4 - // CHECK-NEXT: call void @__atomic_store_8(i8* [[COERCED_A]], i64 [[LOAD_B]], + // CHECK-NEXT: [[CAST_B:%.*]] = bitcast i64* [[COERCED_B]] to i8* + // CHECK-NEXT: call void @__atomic_store(i32 8, i8* [[COERCED_A]], i8* [[CAST_B]], // CHECK-NEXT: ret void __atomic_store(a, b, memory_order_seq_cst); } @@ -239,9 +241,9 @@ // CHECK-NEXT: [[COERCED_B:%.*]] = bitcast %struct.S* [[LOAD_B_PTR]] to i64* // CHECK-NEXT: [[COERCED_C:%.*]] = bitcast %struct.S* [[LOAD_C_PTR]] to i64* // CHECK-NEXT: [[COERCED_A:%.*]] = bitcast i64* [[COERCED_A_TMP]] to i8* - // CHECK-NEXT: [[LOAD_B:%.*]] = load i64, i64* [[COERCED_B]], align 4 - // CHECK-NEXT: [[CALL:%.*]] = call i64 @__atomic_exchange_8(i8* [[COERCED_A]], i64 [[LOAD_B]], - // CHECK-NEXT: store i64 [[CALL]], i64* [[COERCED_C]], align 4 + // CHECK-NEXT: [[CAST_B:%.*]] = bitcast i64* [[COERCED_B]] to i8* + // CHECK-NEXT: [[CAST_C:%.*]] = bitcast i64* [[COERCED_C]] to i8* + // CHECK-NEXT: call void @__atomic_exchange(i32 8, i8* [[COERCED_A]], i8* [[CAST_B]], i8* [[CAST_C]], __atomic_exchange(a, b, c, memory_order_seq_cst); } @@ -262,8 +264,8 @@ // CHECK-NEXT: [[COERCED_C:%.*]] = bitcast %struct.S* [[LOAD_C_PTR]] to i64* // CHECK-NEXT: [[COERCED_A:%.*]] = bitcast i64* [[COERCED_A_TMP]] to i8* // CHECK-NEXT: [[COERCED_B:%.*]] = bitcast i64* [[COERCED_B_TMP]] to i8* - // CHECK-NEXT: [[LOAD_C:%.*]] = load i64, i64* [[COERCED_C]], align 4 - // CHECK-NEXT: [[CALL:%.*]] = call zeroext i1 @__atomic_compare_exchange_8(i8* [[COERCED_A]], i8* [[COERCED_B]], i64 [[LOAD_C]] + // CHECK-NEXT: [[CAST_C:%.*]] = bitcast i64* [[COERCED_C]] to i8* + // CHECK-NEXT: [[CALL:%.*]] = call zeroext i1 @__atomic_compare_exchange(i32 8, i8* [[COERCED_A]], i8* [[COERCED_B]], i8* [[CAST_C]], // CHECK-NEXT: ret i1 [[CALL]] return __atomic_compare_exchange(a, b, c, 1, 5, 5); } @@ -634,4 +636,29 @@ return __atomic_add_fetch(i, value, memory_order_seq_cst); } +void test_underaligned() { + // CHECK-LABEL: @test_underaligned + struct Underaligned { char c[8]; } underaligned_a, underaligned_b, underaligned_c; + + // CHECK: call void @__atomic_load(i32 8, + __atomic_load(_a, _b, memory_order_seq_cst); + // CHECK: call void @__atomic_store(i32 8, + __atomic_store(_a, _b, memory_order_seq_cst); + // CHECK: call void @__atomic_exchange(i32 8, + __atomic_exchange(_a, _b, _c, memory_order_seq_cst); + // CHECK: call {{.*}} @__atomic_compare_exchange(i32 8, + __atomic_compare_exchange(_a, _b, _c, 1, memory_order_seq_cst, memory_order_seq_cst); + + __attribute__((aligned)) struct Underaligned aligned_a, aligned_b, aligned_c; + + // CHECK: load atomic + __atomic_load(_a, _b, memory_order_seq_cst); + // CHECK: store atomic + __atomic_store(_a, _b, memory_order_seq_cst); + // CHECK: atomicrmw xchg + __atomic_exchange(_a, _b, _c, memory_order_seq_cst); + // CHECK: cmpxchg weak + __atomic_compare_exchange(_a, _b, _c, 1, memory_order_seq_cst, memory_order_seq_cst); +} + #endif Index: cfe/trunk/lib/CodeGen/CGAtomic.cpp === --- cfe/trunk/lib/CodeGen/CGAtomic.cpp +++ cfe/trunk/lib/CodeGen/CGAtomic.cpp @@ -927,6 +927,15 @@ UseOptimizedLibcall = true; break; +case AtomicExpr::AO__atomic_load: +case AtomicExpr::AO__atomic_store: +case AtomicExpr::AO__atomic_exchange: +case
r341734 - Do not use optimized atomic libcalls for misaligned atomics.
Author: rsmith Date: Fri Sep 7 16:57:54 2018 New Revision: 341734 URL: http://llvm.org/viewvc/llvm-project?rev=341734=rev Log: Do not use optimized atomic libcalls for misaligned atomics. Summary: The optimized (__atomic_foo_) libcalls assume that the atomic object is properly aligned, so should never be called on an underaligned object. This addresses one of several problems identified in PR38846. Reviewers: jyknight, t.p.northover Subscribers: jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D51817 Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp cfe/trunk/test/CodeGen/atomic-ops.c Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=341734=341733=341734=diff == --- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original) +++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Fri Sep 7 16:57:54 2018 @@ -927,6 +927,15 @@ RValue CodeGenFunction::EmitAtomicExpr(A UseOptimizedLibcall = true; break; +case AtomicExpr::AO__atomic_load: +case AtomicExpr::AO__atomic_store: +case AtomicExpr::AO__atomic_exchange: +case AtomicExpr::AO__atomic_compare_exchange: + // Use the generic version if we don't know that the operand will be + // suitably aligned for the optimized version. + if (Misaligned) +break; + LLVM_FALLTHROUGH; case AtomicExpr::AO__c11_atomic_load: case AtomicExpr::AO__c11_atomic_store: case AtomicExpr::AO__c11_atomic_exchange: @@ -938,14 +947,11 @@ RValue CodeGenFunction::EmitAtomicExpr(A case AtomicExpr::AO__opencl_atomic_compare_exchange_weak: case AtomicExpr::AO__opencl_atomic_compare_exchange_strong: case AtomicExpr::AO__atomic_load_n: -case AtomicExpr::AO__atomic_load: case AtomicExpr::AO__atomic_store_n: -case AtomicExpr::AO__atomic_store: case AtomicExpr::AO__atomic_exchange_n: -case AtomicExpr::AO__atomic_exchange: case AtomicExpr::AO__atomic_compare_exchange_n: -case AtomicExpr::AO__atomic_compare_exchange: // Only use optimized library calls for sizes for which they exist. + // FIXME: Size == 16 optimized library functions exist too. if (Size == 1 || Size == 2 || Size == 4 || Size == 8) UseOptimizedLibcall = true; break; Modified: cfe/trunk/test/CodeGen/atomic-ops.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/atomic-ops.c?rev=341734=341733=341734=diff == --- cfe/trunk/test/CodeGen/atomic-ops.c (original) +++ cfe/trunk/test/CodeGen/atomic-ops.c Fri Sep 7 16:57:54 2018 @@ -198,10 +198,12 @@ struct S implicit_load(_Atomic(struct S) struct S fd1(struct S *a) { // CHECK-LABEL: @fd1 // CHECK: [[RETVAL:%.*]] = alloca %struct.S, align 4 - // CHECK: bitcast %struct.S* {{.*}} to i64* + // CHECK: [[A:%.*]] = bitcast %struct.S* {{.*}} to i64* // CHECK: [[CAST:%.*]] = bitcast %struct.S* [[RETVAL]] to i64* - // CHECK: [[CALL:%.*]] = call i64 @__atomic_load_8( - // CHECK: store i64 [[CALL]], i64* [[CAST]], align 4 + // CHECK: [[SRC:%.*]] = bitcast i64* [[A]] to i8* + // CHECK: [[DEST:%.*]] = bitcast i64* [[CAST]] to i8* + // CHECK: call void @__atomic_load(i32 8, i8* [[SRC]], i8* [[DEST]], i32 5) + // CHECK: ret struct S ret; __atomic_load(a, , memory_order_seq_cst); return ret; @@ -218,8 +220,8 @@ void fd2(struct S *a, struct S *b) { // CHECK-NEXT: [[COERCED_A_TMP:%.*]] = bitcast %struct.S* [[LOAD_A_PTR]] to i64* // CHECK-NEXT: [[COERCED_B:%.*]] = bitcast %struct.S* [[LOAD_B_PTR]] to i64* // CHECK-NEXT: [[COERCED_A:%.*]] = bitcast i64* [[COERCED_A_TMP]] to i8* - // CHECK-NEXT: [[LOAD_B:%.*]] = load i64, i64* [[COERCED_B]], align 4 - // CHECK-NEXT: call void @__atomic_store_8(i8* [[COERCED_A]], i64 [[LOAD_B]], + // CHECK-NEXT: [[CAST_B:%.*]] = bitcast i64* [[COERCED_B]] to i8* + // CHECK-NEXT: call void @__atomic_store(i32 8, i8* [[COERCED_A]], i8* [[CAST_B]], // CHECK-NEXT: ret void __atomic_store(a, b, memory_order_seq_cst); } @@ -239,9 +241,9 @@ void fd3(struct S *a, struct S *b, struc // CHECK-NEXT: [[COERCED_B:%.*]] = bitcast %struct.S* [[LOAD_B_PTR]] to i64* // CHECK-NEXT: [[COERCED_C:%.*]] = bitcast %struct.S* [[LOAD_C_PTR]] to i64* // CHECK-NEXT: [[COERCED_A:%.*]] = bitcast i64* [[COERCED_A_TMP]] to i8* - // CHECK-NEXT: [[LOAD_B:%.*]] = load i64, i64* [[COERCED_B]], align 4 - // CHECK-NEXT: [[CALL:%.*]] = call i64 @__atomic_exchange_8(i8* [[COERCED_A]], i64 [[LOAD_B]], - // CHECK-NEXT: store i64 [[CALL]], i64* [[COERCED_C]], align 4 + // CHECK-NEXT: [[CAST_B:%.*]] = bitcast i64* [[COERCED_B]] to i8* + // CHECK-NEXT: [[CAST_C:%.*]] = bitcast i64* [[COERCED_C]] to i8* + // CHECK-NEXT: call void @__atomic_exchange(i32 8, i8* [[COERCED_A]], i8* [[CAST_B]], i8* [[CAST_C]], __atomic_exchange(a, b, c, memory_order_seq_cst); } @@
[PATCH] D51817: Do not use optimized atomic libcalls for misaligned atomics.
This revision was automatically updated to reflect the committed changes. Closed by commit rC341734: Do not use optimized atomic libcalls for misaligned atomics. (authored by rsmith, committed by ). Changed prior to commit: https://reviews.llvm.org/D51817?vs=164517=164544#toc Repository: rL LLVM https://reviews.llvm.org/D51817 Files: lib/CodeGen/CGAtomic.cpp test/CodeGen/atomic-ops.c Index: test/CodeGen/atomic-ops.c === --- test/CodeGen/atomic-ops.c +++ test/CodeGen/atomic-ops.c @@ -198,10 +198,12 @@ struct S fd1(struct S *a) { // CHECK-LABEL: @fd1 // CHECK: [[RETVAL:%.*]] = alloca %struct.S, align 4 - // CHECK: bitcast %struct.S* {{.*}} to i64* + // CHECK: [[A:%.*]] = bitcast %struct.S* {{.*}} to i64* // CHECK: [[CAST:%.*]] = bitcast %struct.S* [[RETVAL]] to i64* - // CHECK: [[CALL:%.*]] = call i64 @__atomic_load_8( - // CHECK: store i64 [[CALL]], i64* [[CAST]], align 4 + // CHECK: [[SRC:%.*]] = bitcast i64* [[A]] to i8* + // CHECK: [[DEST:%.*]] = bitcast i64* [[CAST]] to i8* + // CHECK: call void @__atomic_load(i32 8, i8* [[SRC]], i8* [[DEST]], i32 5) + // CHECK: ret struct S ret; __atomic_load(a, , memory_order_seq_cst); return ret; @@ -218,8 +220,8 @@ // CHECK-NEXT: [[COERCED_A_TMP:%.*]] = bitcast %struct.S* [[LOAD_A_PTR]] to i64* // CHECK-NEXT: [[COERCED_B:%.*]] = bitcast %struct.S* [[LOAD_B_PTR]] to i64* // CHECK-NEXT: [[COERCED_A:%.*]] = bitcast i64* [[COERCED_A_TMP]] to i8* - // CHECK-NEXT: [[LOAD_B:%.*]] = load i64, i64* [[COERCED_B]], align 4 - // CHECK-NEXT: call void @__atomic_store_8(i8* [[COERCED_A]], i64 [[LOAD_B]], + // CHECK-NEXT: [[CAST_B:%.*]] = bitcast i64* [[COERCED_B]] to i8* + // CHECK-NEXT: call void @__atomic_store(i32 8, i8* [[COERCED_A]], i8* [[CAST_B]], // CHECK-NEXT: ret void __atomic_store(a, b, memory_order_seq_cst); } @@ -239,9 +241,9 @@ // CHECK-NEXT: [[COERCED_B:%.*]] = bitcast %struct.S* [[LOAD_B_PTR]] to i64* // CHECK-NEXT: [[COERCED_C:%.*]] = bitcast %struct.S* [[LOAD_C_PTR]] to i64* // CHECK-NEXT: [[COERCED_A:%.*]] = bitcast i64* [[COERCED_A_TMP]] to i8* - // CHECK-NEXT: [[LOAD_B:%.*]] = load i64, i64* [[COERCED_B]], align 4 - // CHECK-NEXT: [[CALL:%.*]] = call i64 @__atomic_exchange_8(i8* [[COERCED_A]], i64 [[LOAD_B]], - // CHECK-NEXT: store i64 [[CALL]], i64* [[COERCED_C]], align 4 + // CHECK-NEXT: [[CAST_B:%.*]] = bitcast i64* [[COERCED_B]] to i8* + // CHECK-NEXT: [[CAST_C:%.*]] = bitcast i64* [[COERCED_C]] to i8* + // CHECK-NEXT: call void @__atomic_exchange(i32 8, i8* [[COERCED_A]], i8* [[CAST_B]], i8* [[CAST_C]], __atomic_exchange(a, b, c, memory_order_seq_cst); } @@ -262,8 +264,8 @@ // CHECK-NEXT: [[COERCED_C:%.*]] = bitcast %struct.S* [[LOAD_C_PTR]] to i64* // CHECK-NEXT: [[COERCED_A:%.*]] = bitcast i64* [[COERCED_A_TMP]] to i8* // CHECK-NEXT: [[COERCED_B:%.*]] = bitcast i64* [[COERCED_B_TMP]] to i8* - // CHECK-NEXT: [[LOAD_C:%.*]] = load i64, i64* [[COERCED_C]], align 4 - // CHECK-NEXT: [[CALL:%.*]] = call zeroext i1 @__atomic_compare_exchange_8(i8* [[COERCED_A]], i8* [[COERCED_B]], i64 [[LOAD_C]] + // CHECK-NEXT: [[CAST_C:%.*]] = bitcast i64* [[COERCED_C]] to i8* + // CHECK-NEXT: [[CALL:%.*]] = call zeroext i1 @__atomic_compare_exchange(i32 8, i8* [[COERCED_A]], i8* [[COERCED_B]], i8* [[CAST_C]], // CHECK-NEXT: ret i1 [[CALL]] return __atomic_compare_exchange(a, b, c, 1, 5, 5); } @@ -634,4 +636,29 @@ return __atomic_add_fetch(i, value, memory_order_seq_cst); } +void test_underaligned() { + // CHECK-LABEL: @test_underaligned + struct Underaligned { char c[8]; } underaligned_a, underaligned_b, underaligned_c; + + // CHECK: call void @__atomic_load(i32 8, + __atomic_load(_a, _b, memory_order_seq_cst); + // CHECK: call void @__atomic_store(i32 8, + __atomic_store(_a, _b, memory_order_seq_cst); + // CHECK: call void @__atomic_exchange(i32 8, + __atomic_exchange(_a, _b, _c, memory_order_seq_cst); + // CHECK: call {{.*}} @__atomic_compare_exchange(i32 8, + __atomic_compare_exchange(_a, _b, _c, 1, memory_order_seq_cst, memory_order_seq_cst); + + __attribute__((aligned)) struct Underaligned aligned_a, aligned_b, aligned_c; + + // CHECK: load atomic + __atomic_load(_a, _b, memory_order_seq_cst); + // CHECK: store atomic + __atomic_store(_a, _b, memory_order_seq_cst); + // CHECK: atomicrmw xchg + __atomic_exchange(_a, _b, _c, memory_order_seq_cst); + // CHECK: cmpxchg weak + __atomic_compare_exchange(_a, _b, _c, 1, memory_order_seq_cst, memory_order_seq_cst); +} + #endif Index: lib/CodeGen/CGAtomic.cpp === --- lib/CodeGen/CGAtomic.cpp +++ lib/CodeGen/CGAtomic.cpp @@ -927,6 +927,15 @@ UseOptimizedLibcall = true; break; +case AtomicExpr::AO__atomic_load: +case AtomicExpr::AO__atomic_store: +case AtomicExpr::AO__atomic_exchange: +case AtomicExpr::AO__atomic_compare_exchange: +
[PATCH] D51817: Do not use optimized atomic libcalls for misaligned atomics.
efriedma accepted this revision. efriedma added a comment. This revision is now accepted and ready to land. LGTM Comment at: lib/CodeGen/CGAtomic.cpp:949 case AtomicExpr::AO__opencl_atomic_compare_exchange_strong: case AtomicExpr::AO__atomic_load_n: case AtomicExpr::AO__atomic_store_n: rsmith wrote: > efriedma wrote: > > Is there any particular reason to expect that the pointer operand to > > __atomic_load_n can't be misaligned? I mean, for most ABIs, integers are > > naturally aligned, but that isn't actually a hard rule. > `__atomic_load_n` is, by definition, guaranteed to never call an unoptimized > atomic library function (see https://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary). > [I think the purpose of the `..._n` variants is to provide builtins that > libatomic's unoptimized library functions can use and have a guarantee that > they will not be recursively re-entered.] Oh, okay, makes sense. Repository: rC Clang https://reviews.llvm.org/D51817 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51817: Do not use optimized atomic libcalls for misaligned atomics.
rsmith added inline comments. Comment at: lib/CodeGen/CGAtomic.cpp:949 case AtomicExpr::AO__opencl_atomic_compare_exchange_strong: case AtomicExpr::AO__atomic_load_n: case AtomicExpr::AO__atomic_store_n: efriedma wrote: > Is there any particular reason to expect that the pointer operand to > __atomic_load_n can't be misaligned? I mean, for most ABIs, integers are > naturally aligned, but that isn't actually a hard rule. `__atomic_load_n` is, by definition, guaranteed to never call an unoptimized atomic library function (see https://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary). [I think the purpose of the `..._n` variants is to provide builtins that libatomic's unoptimized library functions can use and have a guarantee that they will not be recursively re-entered.] Repository: rC Clang https://reviews.llvm.org/D51817 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51817: Do not use optimized atomic libcalls for misaligned atomics.
efriedma added inline comments. Comment at: lib/CodeGen/CGAtomic.cpp:949 case AtomicExpr::AO__opencl_atomic_compare_exchange_strong: case AtomicExpr::AO__atomic_load_n: case AtomicExpr::AO__atomic_store_n: Is there any particular reason to expect that the pointer operand to __atomic_load_n can't be misaligned? I mean, for most ABIs, integers are naturally aligned, but that isn't actually a hard rule. Repository: rC Clang https://reviews.llvm.org/D51817 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51513: [analyzer] [NFC] Move methods for dumping the coverage in HTMLDiagnostics into the class
This revision was automatically updated to reflect the committed changes. Closed by commit rC341724: [analyzer] [NFC] Move methods for dumping the coverage in HTMLDiagnostics into… (authored by george.karpenkov, committed by ). Herald added a subscriber: cfe-commits. Changed prior to commit: https://reviews.llvm.org/D51513?vs=163421=164528#toc Repository: rC Clang https://reviews.llvm.org/D51513 Files: lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp Index: lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp === --- lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp +++ lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp @@ -122,6 +122,15 @@ /// \return Javascript for navigating the HTML report using j/k keys. StringRef generateKeyboardNavigationJavascript(); + + /// \return JavaScript for an option to only show relevant lines. + std::string showRelevantLinesJavascript( +const PathDiagnostic , const PathPieces ); + + /// Write executed lines from \p D in JSON format into \p os. + void dumpCoverageData(const PathDiagnostic , +const PathPieces , +llvm::raw_string_ostream ); }; } // namespace @@ -333,8 +342,7 @@ return os.str(); } -/// Write executed lines from \p D in JSON format into \p os. -static void serializeExecutedLines( +void HTMLDiagnostics::dumpCoverageData( const PathDiagnostic , const PathPieces , llvm::raw_string_ostream ) { @@ -360,13 +368,12 @@ os << "};"; } -/// \return JavaScript for an option to only show relevant lines. -static std::string showRelevantLinesJavascript( +std::string HTMLDiagnostics::showRelevantLinesJavascript( const PathDiagnostic , const PathPieces ) { std::string s; llvm::raw_string_ostream os(s); os <<
[PATCH] D51512: [analyzer] [NFC] Use StringRef when returning a large string literal in HTMLDiagnostics
This revision was automatically updated to reflect the committed changes. Closed by commit rC341723: [analyzer] [NFC] Use StringRef when returning a large string literal in… (authored by george.karpenkov, committed by ). Herald added a subscriber: cfe-commits. Changed prior to commit: https://reviews.llvm.org/D51512?vs=163419=164527#toc Repository: rC Clang https://reviews.llvm.org/D51512 Files: lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp Index: lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp === --- lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp +++ lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp @@ -115,12 +115,13 @@ void RewriteFile(Rewriter , const SourceManager& SMgr, const PathPieces& path, FileID FID); - /// \return Javascript for navigating the HTML report using j/k keys. - std::string generateKeyboardNavigationJavascript(); private: /// \return Javascript for displaying shortcuts help; - std::string showHelpJavascript(); + StringRef showHelpJavascript(); + + /// \return Javascript for navigating the HTML report using j/k keys. + StringRef generateKeyboardNavigationJavascript(); }; } // namespace @@ -571,7 +572,7 @@ html::AddHeaderFooterInternalBuiltinCSS(R, FID, Entry->getName()); } -std::string HTMLDiagnostics::showHelpJavascript() { +StringRef HTMLDiagnostics::showHelpJavascript() { return R"<<<(
r341724 - [analyzer] [NFC] Move methods for dumping the coverage in HTMLDiagnostics into the class
Author: george.karpenkov Date: Fri Sep 7 15:13:35 2018 New Revision: 341724 URL: http://llvm.org/viewvc/llvm-project?rev=341724=rev Log: [analyzer] [NFC] Move methods for dumping the coverage in HTMLDiagnostics into the class Differential Revision: https://reviews.llvm.org/D51513 Modified: cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp?rev=341724=341723=341724=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp Fri Sep 7 15:13:35 2018 @@ -122,6 +122,15 @@ private: /// \return Javascript for navigating the HTML report using j/k keys. StringRef generateKeyboardNavigationJavascript(); + + /// \return JavaScript for an option to only show relevant lines. + std::string showRelevantLinesJavascript( +const PathDiagnostic , const PathPieces ); + + /// Write executed lines from \p D in JSON format into \p os. + void dumpCoverageData(const PathDiagnostic , +const PathPieces , +llvm::raw_string_ostream ); }; } // namespace @@ -333,8 +342,7 @@ std::string HTMLDiagnostics::GenerateHTM return os.str(); } -/// Write executed lines from \p D in JSON format into \p os. -static void serializeExecutedLines( +void HTMLDiagnostics::dumpCoverageData( const PathDiagnostic , const PathPieces , llvm::raw_string_ostream ) { @@ -360,13 +368,12 @@ static void serializeExecutedLines( os << "};"; } -/// \return JavaScript for an option to only show relevant lines. -static std::string showRelevantLinesJavascript( +std::string HTMLDiagnostics::showRelevantLinesJavascript( const PathDiagnostic , const PathPieces ) { std::string s; llvm::raw_string_ostream os(s); os <<
r341723 - [analyzer] [NFC] Use StringRef when returning a large string literal in HTMLDiagnostics
Author: george.karpenkov Date: Fri Sep 7 15:13:15 2018 New Revision: 341723 URL: http://llvm.org/viewvc/llvm-project?rev=341723=rev Log: [analyzer] [NFC] Use StringRef when returning a large string literal in HTMLDiagnostics (NB: could be a clang-tidy / analyzer check) Differential Revision: https://reviews.llvm.org/D51512 Modified: cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp?rev=341723=341722=341723=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp Fri Sep 7 15:13:15 2018 @@ -115,12 +115,13 @@ public: void RewriteFile(Rewriter , const SourceManager& SMgr, const PathPieces& path, FileID FID); - /// \return Javascript for navigating the HTML report using j/k keys. - std::string generateKeyboardNavigationJavascript(); private: /// \return Javascript for displaying shortcuts help; - std::string showHelpJavascript(); + StringRef showHelpJavascript(); + + /// \return Javascript for navigating the HTML report using j/k keys. + StringRef generateKeyboardNavigationJavascript(); }; } // namespace @@ -571,7 +572,7 @@ void HTMLDiagnostics::FinalizeHTML(const html::AddHeaderFooterInternalBuiltinCSS(R, FID, Entry->getName()); } -std::string HTMLDiagnostics::showHelpJavascript() { +StringRef HTMLDiagnostics::showHelpJavascript() { return R"<<<(
r341722 - [analyzer] Remove the "postponed" hack, deal with derived symbols using an extra map
Author: george.karpenkov Date: Fri Sep 7 15:07:57 2018 New Revision: 341722 URL: http://llvm.org/viewvc/llvm-project?rev=341722=rev Log: [analyzer] Remove the "postponed" hack, deal with derived symbols using an extra map The "derived" symbols indicate children fields of a larger symbol. As parents do not have pointers to their children, the garbage collection algorithm the analyzer currently uses adds such symbols into a "postponed" category, and then keeps running through the worklist until the fixed point is reached. The current patch rectifies that by instead using a helper map which stores pointers from parents to children, so that no fixed point calculation is necessary. The current patch yields ~5% improvement in running time on sqlite. Differential Revision: https://reviews.llvm.org/D51397 Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=341722=341721=341722=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Fri Sep 7 15:07:57 2018 @@ -769,6 +769,9 @@ class SymbolicRegion : public SubRegion assert(s->getType()->isAnyPointerType() || s->getType()->isReferenceType() || s->getType()->isBlockPointerType()); + +// populateWorklistFromSymbol() relies on this assertion, and needs to be +// updated if more cases are introduced. assert(isa(sreg) || isa(sreg)); } Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h?rev=341722=341721=341722=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h Fri Sep 7 15:07:57 2018 @@ -130,6 +130,8 @@ public: /// used to query and manipulate MemRegion objects. MemRegionManager& getRegionManager() { return MRMgr; } + SValBuilder& getSValBuilder() { return svalBuilder; } + virtual Loc getLValueVar(const VarDecl *VD, const LocationContext *LC) { return svalBuilder.makeLoc(MRMgr.getVarRegion(VD, LC)); } Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=341722=341721=341722=diff == --- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Fri Sep 7 15:07:57 2018 @@ -2394,7 +2394,10 @@ RegionStoreManager::bindAggregate(Region namespace { class RemoveDeadBindingsWorker : public ClusterAnalysis { - SmallVector Postponed; + using ChildrenListTy = SmallVector; + using MapParentsToDerivedTy = llvm::DenseMap; + + MapParentsToDerivedTy ParentsToDerived; SymbolReaper const StackFrameContext *CurrentLCtx; @@ -2415,8 +2418,10 @@ public: bool AddToWorkList(const MemRegion *R); - bool UpdatePostponed(); void VisitBinding(SVal V); + +private: + void populateWorklistFromSymbol(SymbolRef s); }; } @@ -2436,10 +2441,11 @@ void RemoveDeadBindingsWorker::VisitAdde } if (const SymbolicRegion *SR = dyn_cast(baseR)) { -if (SymReaper.isLive(SR->getSymbol())) +if (SymReaper.isLive(SR->getSymbol())) { AddToWorkList(SR, ); -else - Postponed.push_back(SR); +} else if (const auto *SD = dyn_cast(SR->getSymbol())) { + ParentsToDerived[SD->getParentSymbol()].push_back(SD); +} return; } @@ -2451,7 +2457,7 @@ void RemoveDeadBindingsWorker::VisitAdde // CXXThisRegion in the current or parent location context is live. if (const CXXThisRegion *TR = dyn_cast(baseR)) { -const StackArgumentsSpaceRegion *StackReg = +const auto *StackReg = cast(TR->getSuperRegion()); const StackFrameContext *RegCtx = StackReg->getStackFrame(); if (CurrentLCtx && @@ -2496,6 +2502,15 @@ void RemoveDeadBindingsWorker::VisitBind // If V is a region, then add it to the worklist. if (const MemRegion *R = V.getAsRegion()) { AddToWorkList(R); + +if (const auto *TVR = dyn_cast(R)) { + DefinedOrUnknownSVal RVS = + RM.getSValBuilder().getRegionValueSymbolVal(TVR); + if (const MemRegion *SR = RVS.getAsRegion()) { +AddToWorkList(SR); + } +} + SymReaper.markLive(R); // All regions captured by a block
[PATCH] D51819: [clang-tidy/ObjC] Update list of acronyms in PropertyDeclarationCheck
This revision was automatically updated to reflect the committed changes. Closed by commit rL341720: [clang-tidy/ObjC] Update list of acronyms in PropertyDeclarationCheck (authored by benhamilton, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D51819?vs=164523=164525#toc Repository: rL LLVM https://reviews.llvm.org/D51819 Files: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp @@ -42,12 +42,15 @@ "[2-9]G", "ACL", "API", +"APN", +"APNS", "AR", "ARGB", "ASCII", "AV", "BGRA", "CA", +"CDN", "CF", "CG", "CI", @@ -71,14 +74,17 @@ "ID", "JPG", "JS", +"JSON", "LAN", "LZW", +"LTR", "MAC", "MD", "MDNS", "MIDI", "NS", "OS", +"P2P", "PDF", "PIN", "PNG", @@ -102,12 +108,14 @@ "SSO", "TCP", "TIFF", +"TOS", "TTS", "UI", "URI", "URL", "UUID", "VC", +"VO", "VOIP", "VPN", "VR", Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp @@ -42,12 +42,15 @@ "[2-9]G", "ACL", "API", +"APN", +"APNS", "AR", "ARGB", "ASCII", "AV", "BGRA", "CA", +"CDN", "CF", "CG", "CI", @@ -71,14 +74,17 @@ "ID", "JPG", "JS", +"JSON", "LAN", "LZW", +"LTR", "MAC", "MD", "MDNS", "MIDI", "NS", "OS", +"P2P", "PDF", "PIN", "PNG", @@ -102,12 +108,14 @@ "SSO", "TCP", "TIFF", +"TOS", "TTS", "UI", "URI", "URL", "UUID", "VC", +"VO", "VOIP", "VPN", "VR", ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51819: [clang-tidy/ObjC] Update list of acronyms in PropertyDeclarationCheck
benhamilton updated this revision to Diff 164523. benhamilton added a comment. - Update docs. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D51819 Files: clang-tidy/objc/PropertyDeclarationCheck.cpp docs/clang-tidy/checks/objc-property-declaration.rst Index: docs/clang-tidy/checks/objc-property-declaration.rst === --- docs/clang-tidy/checks/objc-property-declaration.rst +++ docs/clang-tidy/checks/objc-property-declaration.rst @@ -63,7 +63,7 @@ If set to ``1``, the value in ``Acronyms`` is appended to the default list of acronyms: - ``ACL;API;ARGB;ASCII;BGRA;CMYK;DNS;FPS;FTP;GIF;GPS;HD;HDR;HTML;HTTP;HTTPS;HUD;ID;JPG;JS;LAN;LZW;MDNS;MIDI;OS;PDF;PIN;PNG;POI;PSTN;PTR;QA;QOS;RGB;RGBA;RGBX;ROM;RPC;RTF;RTL;SDK;SSO;TCP;TIFF;TTS;UI;URI;URL;VC;VOIP;VPN;VR;WAN;XML``. + ``[2-9]G;ACL;API;APN;APNS;AR;ARGB;ASCII;AV;BGRA;CA;CDN;CF;CG;CI;CRC;CV;CMYK;DNS;FPS;FTP;GIF;GL;GPS;GUID;HD;HDR;HMAC;HTML;HTTP;HTTPS;HUD;ID;JPG;JS;JSON;LAN;LZW;LTR;MAC;MD;MDNS;MIDI;NS;OS;P2P;PDF;PIN;PNG;POI;PSTN;PTR;QA;QOS;RGB;RGBA;RGBX;RIPEMD;ROM;RPC;RTF;RTL;SC;SDK;SHA;SQL;SSO;TCP;TIFF;TOS;TTS;UI;URI;URL;UUID;VC;VO;VOIP;VPN;VR;W;WAN;X;XML;Y;Z``. If set to ``0``, the value in ``Acronyms`` replaces the default list of acronyms. Index: clang-tidy/objc/PropertyDeclarationCheck.cpp === --- clang-tidy/objc/PropertyDeclarationCheck.cpp +++ clang-tidy/objc/PropertyDeclarationCheck.cpp @@ -42,12 +42,15 @@ "[2-9]G", "ACL", "API", +"APN", +"APNS", "AR", "ARGB", "ASCII", "AV", "BGRA", "CA", +"CDN", "CF", "CG", "CI", @@ -71,14 +74,17 @@ "ID", "JPG", "JS", +"JSON", "LAN", "LZW", +"LTR", "MAC", "MD", "MDNS", "MIDI", "NS", "OS", +"P2P", "PDF", "PIN", "PNG", @@ -102,12 +108,14 @@ "SSO", "TCP", "TIFF", +"TOS", "TTS", "UI", "URI", "URL", "UUID", "VC", +"VO", "VOIP", "VPN", "VR", Index: docs/clang-tidy/checks/objc-property-declaration.rst === --- docs/clang-tidy/checks/objc-property-declaration.rst +++ docs/clang-tidy/checks/objc-property-declaration.rst @@ -63,7 +63,7 @@ If set to ``1``, the value in ``Acronyms`` is appended to the default list of acronyms: - ``ACL;API;ARGB;ASCII;BGRA;CMYK;DNS;FPS;FTP;GIF;GPS;HD;HDR;HTML;HTTP;HTTPS;HUD;ID;JPG;JS;LAN;LZW;MDNS;MIDI;OS;PDF;PIN;PNG;POI;PSTN;PTR;QA;QOS;RGB;RGBA;RGBX;ROM;RPC;RTF;RTL;SDK;SSO;TCP;TIFF;TTS;UI;URI;URL;VC;VOIP;VPN;VR;WAN;XML``. + ``[2-9]G;ACL;API;APN;APNS;AR;ARGB;ASCII;AV;BGRA;CA;CDN;CF;CG;CI;CRC;CV;CMYK;DNS;FPS;FTP;GIF;GL;GPS;GUID;HD;HDR;HMAC;HTML;HTTP;HTTPS;HUD;ID;JPG;JS;JSON;LAN;LZW;LTR;MAC;MD;MDNS;MIDI;NS;OS;P2P;PDF;PIN;PNG;POI;PSTN;PTR;QA;QOS;RGB;RGBA;RGBX;RIPEMD;ROM;RPC;RTF;RTL;SC;SDK;SHA;SQL;SSO;TCP;TIFF;TOS;TTS;UI;URI;URL;UUID;VC;VO;VOIP;VPN;VR;W;WAN;X;XML;Y;Z``. If set to ``0``, the value in ``Acronyms`` replaces the default list of acronyms. Index: clang-tidy/objc/PropertyDeclarationCheck.cpp === --- clang-tidy/objc/PropertyDeclarationCheck.cpp +++ clang-tidy/objc/PropertyDeclarationCheck.cpp @@ -42,12 +42,15 @@ "[2-9]G", "ACL", "API", +"APN", +"APNS", "AR", "ARGB", "ASCII", "AV", "BGRA", "CA", +"CDN", "CF", "CG", "CI", @@ -71,14 +74,17 @@ "ID", "JPG", "JS", +"JSON", "LAN", "LZW", +"LTR", "MAC", "MD", "MDNS", "MIDI", "NS", "OS", +"P2P", "PDF", "PIN", "PNG", @@ -102,12 +108,14 @@ "SSO", "TCP", "TIFF", +"TOS", "TTS", "UI", "URI", "URL", "UUID", "VC", +"VO", "VOIP", "VPN", "VR", ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r341721 - [clang-tidy/ObjC] Update list of acronyms in PropertyDeclarationCheck
Author: benhamilton Date: Fri Sep 7 15:03:48 2018 New Revision: 341721 URL: http://llvm.org/viewvc/llvm-project?rev=341721=rev Log: [clang-tidy/ObjC] Update list of acronyms in PropertyDeclarationCheck Summary: This adds a few common acronyms we found were missing from PropertyDeclarationCheck. Reviewers: Wizard, hokein Reviewed By: hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51819 Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst?rev=341721=341720=341721=diff == --- clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst (original) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst Fri Sep 7 15:03:48 2018 @@ -63,7 +63,7 @@ Options If set to ``1``, the value in ``Acronyms`` is appended to the default list of acronyms: - ``ACL;API;ARGB;ASCII;BGRA;CMYK;DNS;FPS;FTP;GIF;GPS;HD;HDR;HTML;HTTP;HTTPS;HUD;ID;JPG;JS;LAN;LZW;MDNS;MIDI;OS;PDF;PIN;PNG;POI;PSTN;PTR;QA;QOS;RGB;RGBA;RGBX;ROM;RPC;RTF;RTL;SDK;SSO;TCP;TIFF;TTS;UI;URI;URL;VC;VOIP;VPN;VR;WAN;XML``. + ``[2-9]G;ACL;API;APN;APNS;AR;ARGB;ASCII;AV;BGRA;CA;CDN;CF;CG;CI;CRC;CV;CMYK;DNS;FPS;FTP;GIF;GL;GPS;GUID;HD;HDR;HMAC;HTML;HTTP;HTTPS;HUD;ID;JPG;JS;JSON;LAN;LZW;LTR;MAC;MD;MDNS;MIDI;NS;OS;P2P;PDF;PIN;PNG;POI;PSTN;PTR;QA;QOS;RGB;RGBA;RGBX;RIPEMD;ROM;RPC;RTF;RTL;SC;SDK;SHA;SQL;SSO;TCP;TIFF;TOS;TTS;UI;URI;URL;UUID;VC;VO;VOIP;VPN;VR;W;WAN;X;XML;Y;Z``. If set to ``0``, the value in ``Acronyms`` replaces the default list of acronyms. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r341720 - [clang-tidy/ObjC] Update list of acronyms in PropertyDeclarationCheck
Author: benhamilton Date: Fri Sep 7 15:02:38 2018 New Revision: 341720 URL: http://llvm.org/viewvc/llvm-project?rev=341720=rev Log: [clang-tidy/ObjC] Update list of acronyms in PropertyDeclarationCheck Summary: This adds a few common acronyms we found were missing from PropertyDeclarationCheck. Reviewers: Wizard, hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51819 Modified: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp?rev=341720=341719=341720=diff == --- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Fri Sep 7 15:02:38 2018 @@ -42,12 +42,15 @@ constexpr llvm::StringLiteral DefaultSpe "[2-9]G", "ACL", "API", +"APN", +"APNS", "AR", "ARGB", "ASCII", "AV", "BGRA", "CA", +"CDN", "CF", "CG", "CI", @@ -71,14 +74,17 @@ constexpr llvm::StringLiteral DefaultSpe "ID", "JPG", "JS", +"JSON", "LAN", "LZW", +"LTR", "MAC", "MD", "MDNS", "MIDI", "NS", "OS", +"P2P", "PDF", "PIN", "PNG", @@ -102,12 +108,14 @@ constexpr llvm::StringLiteral DefaultSpe "SSO", "TCP", "TIFF", +"TOS", "TTS", "UI", "URI", "URL", "UUID", "VC", +"VO", "VOIP", "VPN", "VR", ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51819: [clang-tidy/ObjC] Update list of acronyms in PropertyDeclarationCheck
hokein accepted this revision. hokein added a comment. This revision is now accepted and ready to land. We need to update the documentation http://clang.llvm.org/extra/clang-tidy/checks/objc-property-declaration.html as well. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D51819 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51812: Simplify CheckFallThroughForBody
rsmith added a comment. I'm not a fan of the duplication introduced here, but the new code is definitely more obvious. On balance, this seems like a small improvement, so let's go for it. Comment at: b/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp:542-544 + // cpu_dispatch functions permit empty function bodies for ICC compatibility. + if (FD->isCPUDispatchMultiVersion()) +return; Hmm. It really doesn't make any sense to apply `cpu_dispatch` to a lambda, because the call operator can't be overloaded. I don't think this special case warning suppression is worthwhile. (Rather, we should probably disallow the attribute on lambdas; I've asked Erich Keane about that.) Comment at: b/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp:595 + D->getLocation())) && + (!HasNoReturnAttr)) + return; I know this is just rearranged from where it was before, but... can you remove the redundant parens here, and run the patch through clang-format? Comment at: b/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp:601 +case MaybeFallThrough: + if (ReturnsValue) +S.Diag(RBrace, diag::warn_maybe_falloff_nonvoid_coroutine) This `if` and the one below are redundant now. Repository: rC Clang https://reviews.llvm.org/D51812 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51819: [clang-tidy/ObjC] Update list of acronyms in PropertyDeclarationCheck
benhamilton created this revision. benhamilton added reviewers: Wizard, hokein. Herald added a subscriber: cfe-commits. This adds a few common acronyms we found were missing from PropertyDeclarationCheck. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D51819 Files: clang-tidy/objc/PropertyDeclarationCheck.cpp Index: clang-tidy/objc/PropertyDeclarationCheck.cpp === --- clang-tidy/objc/PropertyDeclarationCheck.cpp +++ clang-tidy/objc/PropertyDeclarationCheck.cpp @@ -42,12 +42,15 @@ "[2-9]G", "ACL", "API", +"APN", +"APNS", "AR", "ARGB", "ASCII", "AV", "BGRA", "CA", +"CDN", "CF", "CG", "CI", @@ -71,14 +74,17 @@ "ID", "JPG", "JS", +"JSON", "LAN", "LZW", +"LTR", "MAC", "MD", "MDNS", "MIDI", "NS", "OS", +"P2P", "PDF", "PIN", "PNG", @@ -102,12 +108,14 @@ "SSO", "TCP", "TIFF", +"TOS", "TTS", "UI", "URI", "URL", "UUID", "VC", +"VO", "VOIP", "VPN", "VR", Index: clang-tidy/objc/PropertyDeclarationCheck.cpp === --- clang-tidy/objc/PropertyDeclarationCheck.cpp +++ clang-tidy/objc/PropertyDeclarationCheck.cpp @@ -42,12 +42,15 @@ "[2-9]G", "ACL", "API", +"APN", +"APNS", "AR", "ARGB", "ASCII", "AV", "BGRA", "CA", +"CDN", "CF", "CG", "CI", @@ -71,14 +74,17 @@ "ID", "JPG", "JS", +"JSON", "LAN", "LZW", +"LTR", "MAC", "MD", "MDNS", "MIDI", "NS", "OS", +"P2P", "PDF", "PIN", "PNG", @@ -102,12 +108,14 @@ "SSO", "TCP", "TIFF", +"TOS", "TTS", "UI", "URI", "URL", "UUID", "VC", +"VO", "VOIP", "VPN", "VR", ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51752: NFC: deduplicate isRepeatedBytePattern from clang to LLVM's isBytewiseValue
jfb added a comment. Will wait on https://reviews.llvm.org/D51751 before committing, otherwise clang tests will start failing (because current `isRepeatedBytePattern` isn't capable enough). Repository: rC Clang https://reviews.llvm.org/D51752 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51817: Do not use optimized atomic libcalls for misaligned atomics.
rsmith created this revision. rsmith added reviewers: jyknight, t.p.northover. Herald added a subscriber: jfb. The optimized (__atomic_foo_) libcalls assume that the atomic object is properly aligned, so should never be called on an underaligned object. This addresses one of several problems identified in PR38846. Repository: rC Clang https://reviews.llvm.org/D51817 Files: lib/CodeGen/CGAtomic.cpp test/CodeGen/atomic-ops.c Index: test/CodeGen/atomic-ops.c === --- test/CodeGen/atomic-ops.c +++ test/CodeGen/atomic-ops.c @@ -198,10 +198,12 @@ struct S fd1(struct S *a) { // CHECK-LABEL: @fd1 // CHECK: [[RETVAL:%.*]] = alloca %struct.S, align 4 - // CHECK: bitcast %struct.S* {{.*}} to i64* + // CHECK: [[A:%.*]] = bitcast %struct.S* {{.*}} to i64* // CHECK: [[CAST:%.*]] = bitcast %struct.S* [[RETVAL]] to i64* - // CHECK: [[CALL:%.*]] = call i64 @__atomic_load_8( - // CHECK: store i64 [[CALL]], i64* [[CAST]], align 4 + // CHECK: [[SRC:%.*]] = bitcast i64* [[A]] to i8* + // CHECK: [[DEST:%.*]] = bitcast i64* [[CAST]] to i8* + // CHECK: call void @__atomic_load(i32 8, i8* [[SRC]], i8* [[DEST]], i32 5) + // CHECK: ret struct S ret; __atomic_load(a, , memory_order_seq_cst); return ret; @@ -218,8 +220,8 @@ // CHECK-NEXT: [[COERCED_A_TMP:%.*]] = bitcast %struct.S* [[LOAD_A_PTR]] to i64* // CHECK-NEXT: [[COERCED_B:%.*]] = bitcast %struct.S* [[LOAD_B_PTR]] to i64* // CHECK-NEXT: [[COERCED_A:%.*]] = bitcast i64* [[COERCED_A_TMP]] to i8* - // CHECK-NEXT: [[LOAD_B:%.*]] = load i64, i64* [[COERCED_B]], align 4 - // CHECK-NEXT: call void @__atomic_store_8(i8* [[COERCED_A]], i64 [[LOAD_B]], + // CHECK-NEXT: [[CAST_B:%.*]] = bitcast i64* [[COERCED_B]] to i8* + // CHECK-NEXT: call void @__atomic_store(i32 8, i8* [[COERCED_A]], i8* [[CAST_B]], // CHECK-NEXT: ret void __atomic_store(a, b, memory_order_seq_cst); } @@ -239,9 +241,9 @@ // CHECK-NEXT: [[COERCED_B:%.*]] = bitcast %struct.S* [[LOAD_B_PTR]] to i64* // CHECK-NEXT: [[COERCED_C:%.*]] = bitcast %struct.S* [[LOAD_C_PTR]] to i64* // CHECK-NEXT: [[COERCED_A:%.*]] = bitcast i64* [[COERCED_A_TMP]] to i8* - // CHECK-NEXT: [[LOAD_B:%.*]] = load i64, i64* [[COERCED_B]], align 4 - // CHECK-NEXT: [[CALL:%.*]] = call i64 @__atomic_exchange_8(i8* [[COERCED_A]], i64 [[LOAD_B]], - // CHECK-NEXT: store i64 [[CALL]], i64* [[COERCED_C]], align 4 + // CHECK-NEXT: [[CAST_B:%.*]] = bitcast i64* [[COERCED_B]] to i8* + // CHECK-NEXT: [[CAST_C:%.*]] = bitcast i64* [[COERCED_C]] to i8* + // CHECK-NEXT: call void @__atomic_exchange(i32 8, i8* [[COERCED_A]], i8* [[CAST_B]], i8* [[CAST_C]], __atomic_exchange(a, b, c, memory_order_seq_cst); } @@ -262,8 +264,8 @@ // CHECK-NEXT: [[COERCED_C:%.*]] = bitcast %struct.S* [[LOAD_C_PTR]] to i64* // CHECK-NEXT: [[COERCED_A:%.*]] = bitcast i64* [[COERCED_A_TMP]] to i8* // CHECK-NEXT: [[COERCED_B:%.*]] = bitcast i64* [[COERCED_B_TMP]] to i8* - // CHECK-NEXT: [[LOAD_C:%.*]] = load i64, i64* [[COERCED_C]], align 4 - // CHECK-NEXT: [[CALL:%.*]] = call zeroext i1 @__atomic_compare_exchange_8(i8* [[COERCED_A]], i8* [[COERCED_B]], i64 [[LOAD_C]] + // CHECK-NEXT: [[CAST_C:%.*]] = bitcast i64* [[COERCED_C]] to i8* + // CHECK-NEXT: [[CALL:%.*]] = call zeroext i1 @__atomic_compare_exchange(i32 8, i8* [[COERCED_A]], i8* [[COERCED_B]], i8* [[CAST_C]], // CHECK-NEXT: ret i1 [[CALL]] return __atomic_compare_exchange(a, b, c, 1, 5, 5); } @@ -634,4 +636,29 @@ return __atomic_add_fetch(i, value, memory_order_seq_cst); } +void test_underaligned() { + // CHECK-LABEL: @test_underaligned + struct Underaligned { char c[8]; } underaligned_a, underaligned_b, underaligned_c; + + // CHECK: call void @__atomic_load(i32 8, + __atomic_load(_a, _b, memory_order_seq_cst); + // CHECK: call void @__atomic_store(i32 8, + __atomic_store(_a, _b, memory_order_seq_cst); + // CHECK: call void @__atomic_exchange(i32 8, + __atomic_exchange(_a, _b, _c, memory_order_seq_cst); + // CHECK: call {{.*}} @__atomic_compare_exchange(i32 8, + __atomic_compare_exchange(_a, _b, _c, 1, memory_order_seq_cst, memory_order_seq_cst); + + __attribute__((aligned)) struct Underaligned aligned_a, aligned_b, aligned_c; + + // CHECK: load atomic + __atomic_load(_a, _b, memory_order_seq_cst); + // CHECK: store atomic + __atomic_store(_a, _b, memory_order_seq_cst); + // CHECK: atomicrmw xchg + __atomic_exchange(_a, _b, _c, memory_order_seq_cst); + // CHECK: cmpxchg weak + __atomic_compare_exchange(_a, _b, _c, 1, memory_order_seq_cst, memory_order_seq_cst); +} + #endif Index: lib/CodeGen/CGAtomic.cpp === --- lib/CodeGen/CGAtomic.cpp +++ lib/CodeGen/CGAtomic.cpp @@ -927,6 +927,15 @@ UseOptimizedLibcall = true; break; +case AtomicExpr::AO__atomic_load: +case AtomicExpr::AO__atomic_store: +case AtomicExpr::AO__atomic_exchange: +case
r341710 - Make -Watomic-alignment say whether the atomic operation was oversized
Author: rsmith Date: Fri Sep 7 14:24:27 2018 New Revision: 341710 URL: http://llvm.org/viewvc/llvm-project?rev=341710=rev Log: Make -Watomic-alignment say whether the atomic operation was oversized or misaligned. Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/CodeGen/CGAtomic.cpp cfe/trunk/test/CodeGen/atomics-sema-alignment.c Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=341710=341709=341710=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Sep 7 14:24:27 2018 @@ -7093,8 +7093,8 @@ def warn_atomic_op_has_invalid_memory_or def err_atomic_op_has_invalid_synch_scope : Error< "synchronization scope argument to atomic operation is invalid">; def warn_atomic_op_misaligned : Warning< - "misaligned or large atomic operation may incur significant performance penalty">, - InGroup>; + "%select{large|misaligned}0 atomic operation may incur " + "significant performance penalty">, InGroup>; def err_overflow_builtin_must_be_int : Error< "operand argument to overflow builtin must be an integer (%0 invalid)">; Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=341710=341709=341710=diff == --- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original) +++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Fri Sep 7 14:24:27 2018 @@ -765,11 +765,15 @@ RValue CodeGenFunction::EmitAtomicExpr(A std::tie(sizeChars, alignChars) = getContext().getTypeInfoInChars(AtomicTy); uint64_t Size = sizeChars.getQuantity(); unsigned MaxInlineWidthInBits = getTarget().getMaxAtomicInlineWidth(); - bool UseLibcall = ((Ptr.getAlignment() % sizeChars) != 0 || - getContext().toBits(sizeChars) > MaxInlineWidthInBits); - if (UseLibcall) -CGM.getDiags().Report(E->getBeginLoc(), diag::warn_atomic_op_misaligned); + bool Oversized = getContext().toBits(sizeChars) > MaxInlineWidthInBits; + bool Misaligned = (Ptr.getAlignment() % sizeChars) != 0; + bool UseLibcall = Misaligned | Oversized; + + if (UseLibcall) { +CGM.getDiags().Report(E->getBeginLoc(), diag::warn_atomic_op_misaligned) +<< !Oversized; + } llvm::Value *Order = EmitScalarExpr(E->getOrder()); llvm::Value *Scope = Modified: cfe/trunk/test/CodeGen/atomics-sema-alignment.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/atomics-sema-alignment.c?rev=341710=341709=341710=diff == --- cfe/trunk/test/CodeGen/atomics-sema-alignment.c (original) +++ cfe/trunk/test/CodeGen/atomics-sema-alignment.c Fri Sep 7 14:24:27 2018 @@ -12,10 +12,10 @@ typedef int __attribute__((aligned(1))) void func(IntPair *p) { IntPair res; - __atomic_load(p, , 0); // expected-warning {{misaligned or large atomic operation may incur significant performance penalty}} - __atomic_store(p, , 0); // expected-warning {{misaligned or large atomic operation may incur significant performance penalty}} - __atomic_fetch_add((unaligned_int *)p, 1, 2); // expected-warning {{misaligned or large atomic operation may incur significant performance penalty}} - __atomic_fetch_sub((unaligned_int *)p, 1, 3); // expected-warning {{misaligned or large atomic operation may incur significant performance penalty}} + __atomic_load(p, , 0); // expected-warning {{misaligned atomic operation may incur significant performance penalty}} + __atomic_store(p, , 0); // expected-warning {{misaligned atomic operation may incur significant performance penalty}} + __atomic_fetch_add((unaligned_int *)p, 1, 2); // expected-warning {{misaligned atomic operation may incur significant performance penalty}} + __atomic_fetch_sub((unaligned_int *)p, 1, 3); // expected-warning {{misaligned atomic operation may incur significant performance penalty}} } void func1(LongStruct *p) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51747: [clangd] Implement deprecation diagnostics with lower severity.
ioeric added a comment. In https://reviews.llvm.org/D51747#1227089, @ilya-biryukov wrote: > Not sure if it's fine to hijack our own diagnostic-specific flags in to clang > command args. > > Cons that I see: > > 1. There is no way for the users to turn them off if they find them > non-useful. If we add a way, it would be more config parameters which overlap > with other mechanism that we have - compiler flags. > 2. Users who are used to having them as warnings will now see them as notes. > Again, no way to tweak this behavior. > > What's our use-case? Maybe we should ask the clients to add -Wdeprecated if > they care about those? > > PS In case I'm missing the context here, please let me know. Instead of In https://reviews.llvm.org/D51747#1227719, @kadircet wrote: > In https://reviews.llvm.org/D51747#1227089, @ilya-biryukov wrote: > > > Not sure if it's fine to hijack our own diagnostic-specific flags in to > > clang command args. > > > > Cons that I see: > > > > 1. There is no way for the users to turn them off if they find them > > non-useful. If we add a way, it would be more config parameters which > > overlap with other mechanism that we have - compiler flags. > > 2. Users who are used to having them as warnings will now see them as > > notes. Again, no way to tweak this behavior. > > > > What's our use-case? Maybe we should ask the clients to add -Wdeprecated > > if they care about those? > > > > PS In case I'm missing the context here, please let me know. > > > Agree with you, I think it would be better to provide it as an option. > https://reviews.llvm.org/D51724 with this one we added a way to show > deprecated symbols on code completion responses and wanted to move forward > with showing the ones that are already in existing code. I also agree with you regarding options. A pattern I've observed (in some infamous large codebase ;) is that warnings for deprecated symbols are disabled in the compile command as they can introduce too much noise during build, although it would make sense to show these warnings when user edits the code (most of the time). I think there can be other diagnostics that are more desirable as editor diagnostics than as compiler warnings/errors. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D51747 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51812: Simplify CheckFallThroughForBody
gromer created this revision. gromer added a reviewer: rsmith. Herald added subscribers: cfe-commits, modocache. Split CheckFallThroughForBody into separate implementations for blocks, lambdas, coroutines, and all other functions. This simplifies the code because virtually every part of it varies depending on what kind of function is being processed; it's both clearer and safer to branch once at the beginning, rather than branch repeatedly (sometimes on subtly different conditions) and/or rely on layers of indirection. Notice, for example, how this refactoring surfaces the inconsistency between the fast and slow paths for coroutines, and enables the fast-path condition for functions to take advantage of more information about what kinds of diagnostics the slow path can produce (see specifically how SuggestNoReturn now feeds into the early-return condition). Repository: rC Clang https://reviews.llvm.org/D51812 Files: b/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp Index: b/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp === --- b/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp +++ b/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -497,205 +497,221 @@ return AlwaysFallThrough; } -namespace { +static void CheckFallThroughForBlock(Sema , const Stmt *Body, + const BlockExpr *blkExpr, + AnalysisDeclContext ) { + const FunctionType *FT = + blkExpr->getType()->getPointeeType()->getAs(); + if (FT == nullptr) return; -struct CheckFallThroughDiagnostics { - unsigned diag_MaybeFallThrough_HasNoReturn; - unsigned diag_MaybeFallThrough_ReturnsNonVoid; - unsigned diag_AlwaysFallThrough_HasNoReturn; - unsigned diag_AlwaysFallThrough_ReturnsNonVoid; - unsigned diag_NeverFallThroughOrReturn; - enum { Function, Block, Lambda, Coroutine } funMode; - SourceLocation FuncLoc; - - static CheckFallThroughDiagnostics MakeForFunction(const Decl *Func) { -CheckFallThroughDiagnostics D; -D.FuncLoc = Func->getLocation(); -D.diag_MaybeFallThrough_HasNoReturn = - diag::warn_falloff_noreturn_function; -D.diag_MaybeFallThrough_ReturnsNonVoid = - diag::warn_maybe_falloff_nonvoid_function; -D.diag_AlwaysFallThrough_HasNoReturn = - diag::warn_falloff_noreturn_function; -D.diag_AlwaysFallThrough_ReturnsNonVoid = - diag::warn_falloff_nonvoid_function; + bool ReturnsValue = !FT->getReturnType()->isVoidType(); + bool HasNoReturnAttr = FT->getNoReturnAttr(); -// Don't suggest that virtual functions be marked "noreturn", since they -// might be overridden by non-noreturn functions. -bool isVirtualMethod = false; -if (const CXXMethodDecl *Method = dyn_cast(Func)) - isVirtualMethod = Method->isVirtual(); + // Short circuit for compilation speed. + if (!ReturnsValue && !HasNoReturnAttr) + return; -// Don't suggest that template instantiations be marked "noreturn" -bool isTemplateInstantiation = false; -if (const FunctionDecl *Function = dyn_cast(Func)) - isTemplateInstantiation = Function->isTemplateInstantiation(); + SourceLocation RBrace = Body->getEndLoc(); + switch (CheckFallThrough(AC)) { +case MaybeFallThrough: + if (HasNoReturnAttr) +S.Diag(RBrace, diag::err_noreturn_block_has_return_expr); + else if (ReturnsValue) +S.Diag(RBrace, diag::err_maybe_falloff_nonvoid_block); + break; -if (!isVirtualMethod && !isTemplateInstantiation) - D.diag_NeverFallThroughOrReturn = -diag::warn_suggest_noreturn_function; -else - D.diag_NeverFallThroughOrReturn = 0; +case AlwaysFallThrough: + if (HasNoReturnAttr) +S.Diag(RBrace, diag::err_noreturn_block_has_return_expr); + else if (ReturnsValue) +S.Diag(RBrace, diag::err_falloff_nonvoid_block); + break; -D.funMode = Function; -return D; +case NeverFallThroughOrReturn: +case NeverFallThrough: +case UnknownFallThrough: + break; } +} - static CheckFallThroughDiagnostics MakeForCoroutine(const Decl *Func) { -CheckFallThroughDiagnostics D; -D.FuncLoc = Func->getLocation(); -D.diag_MaybeFallThrough_HasNoReturn = 0; -D.diag_MaybeFallThrough_ReturnsNonVoid = -diag::warn_maybe_falloff_nonvoid_coroutine; -D.diag_AlwaysFallThrough_HasNoReturn = 0; -D.diag_AlwaysFallThrough_ReturnsNonVoid = -diag::warn_falloff_nonvoid_coroutine; -D.funMode = Coroutine; -return D; - } - - static CheckFallThroughDiagnostics MakeForBlock() { -CheckFallThroughDiagnostics D; -D.diag_MaybeFallThrough_HasNoReturn = - diag::err_noreturn_block_has_return_expr; -D.diag_MaybeFallThrough_ReturnsNonVoid = - diag::err_maybe_falloff_nonvoid_block; -D.diag_AlwaysFallThrough_HasNoReturn = - diag::err_noreturn_block_has_return_expr; -
[PATCH] D51809: [CUDA][HIP] Fix assertion in LookupSpecialMember
tra added a comment. @jlebar Justin, can you take a look? https://reviews.llvm.org/D51809 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51752: NFC: deduplicate isRepeatedBytePattern from clang to LLVM's isBytewiseValue
MatzeB accepted this revision. MatzeB added a comment. This revision is now accepted and ready to land. Looks obvious and LGTM. Repository: rC Clang https://reviews.llvm.org/D51752 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51784: ms: Insert $$Z in mangling between directly consecutive parameter packs.
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. lgtm, thanks! I thought that was going to be more of a pain. :) https://reviews.llvm.org/D51784 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51789: [WIP][clang] Add the no_extern_template attribute
rsmith added a comment. It'd be good to test that `[[no_extern_template]]` affects instantiation, not just code generation (eg, put something in the body of the entity that will trigger an error if instantiated, and check that the diagnostic is produced at the right times). Repository: rL LLVM https://reviews.llvm.org/D51789 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51809: [CUDA][HIP] Fix assertion in LookupSpecialMember
yaxunl created this revision. yaxunl added a reviewer: tra. ShouldDeleteSpecialMember is called upon inherited constructors. It calls inferCUDATargetForImplicitSpecialMember, which in turn calls LookupSpecialMember. LookupSpecialMember expects ConstArg==false for CXXDefaultConstructor. For inherited constructor with const arguments, this causes assertion. This patch fixes that by passing false as ConstArg argument for CXXDefaultConstructor in ShouldDeleteSpecialMember. https://reviews.llvm.org/D51809 Files: lib/Sema/SemaDeclCXX.cpp test/SemaCUDA/inherited-ctor.cu Index: test/SemaCUDA/inherited-ctor.cu === --- /dev/null +++ test/SemaCUDA/inherited-ctor.cu @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s +// expected-no-diagnostics + +struct A { + A(const int ) {} +}; + +struct B : A { + using A::A; +}; + +struct C { + struct B b; + C() : b(0) {} +}; + +void test() { + B b(0); + C c; +} Index: lib/Sema/SemaDeclCXX.cpp === --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -7187,8 +7187,9 @@ if (getLangOpts().CUDA) { // We should delete the special member in CUDA mode if target inference // failed. -return inferCUDATargetForImplicitSpecialMember(RD, CSM, MD, SMI.ConstArg, - Diagnose); +return inferCUDATargetForImplicitSpecialMember( +RD, CSM, MD, CSM == CXXDefaultConstructor ? false : SMI.ConstArg, +Diagnose); } return false; Index: test/SemaCUDA/inherited-ctor.cu === --- /dev/null +++ test/SemaCUDA/inherited-ctor.cu @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s +// expected-no-diagnostics + +struct A { + A(const int ) {} +}; + +struct B : A { + using A::A; +}; + +struct C { + struct B b; + C() : b(0) {} +}; + +void test() { + B b(0); + C c; +} Index: lib/Sema/SemaDeclCXX.cpp === --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -7187,8 +7187,9 @@ if (getLangOpts().CUDA) { // We should delete the special member in CUDA mode if target inference // failed. -return inferCUDATargetForImplicitSpecialMember(RD, CSM, MD, SMI.ConstArg, - Diagnose); +return inferCUDATargetForImplicitSpecialMember( +RD, CSM, MD, CSM == CXXDefaultConstructor ? false : SMI.ConstArg, +Diagnose); } return false; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r341700 - PR38870: Add warning for zero-width unicode characters appearing in
Author: rsmith Date: Fri Sep 7 12:25:39 2018 New Revision: 341700 URL: http://llvm.org/viewvc/llvm-project?rev=341700=rev Log: PR38870: Add warning for zero-width unicode characters appearing in identifiers. Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td cfe/trunk/lib/Lex/Lexer.cpp cfe/trunk/test/Lexer/unicode.c Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=341700=341699=341700=diff == --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Sep 7 12:25:39 2018 @@ -122,6 +122,9 @@ def ext_unicode_whitespace : ExtWarn< def warn_utf8_symbol_homoglyph : Warning< "treating Unicode character as identifier character rather than " "as '%1' symbol">, InGroup>; +def warn_utf8_symbol_zero_width : Warning< + "identifier contains Unicode character that is invisible in " + "some environments">, InGroup>; def err_hex_escape_no_digits : Error< "\\%0 used with no following hex digits">; Modified: cfe/trunk/lib/Lex/Lexer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=341700=341699=341700=diff == --- cfe/trunk/lib/Lex/Lexer.cpp (original) +++ cfe/trunk/lib/Lex/Lexer.cpp Fri Sep 7 12:25:39 2018 @@ -1510,8 +1510,17 @@ static void maybeDiagnoseUTF8Homoglyph(D bool operator<(HomoglyphPair R) const { return Character < R.Character; } }; static constexpr HomoglyphPair SortedHomoglyphs[] = { +{U'\u00ad', 0}, // SOFT HYPHEN {U'\u01c3', '!'}, // LATIN LETTER RETROFLEX CLICK {U'\u037e', ';'}, // GREEK QUESTION MARK +{U'\u200b', 0}, // ZERO WIDTH SPACE +{U'\u200c', 0}, // ZERO WIDTH NON-JOINER +{U'\u200d', 0}, // ZERO WIDTH JOINER +{U'\u2060', 0}, // WORD JOINER +{U'\u2061', 0}, // FUNCTION APPLICATION +{U'\u2062', 0}, // INVISIBLE TIMES +{U'\u2063', 0}, // INVISIBLE SEPARATOR +{U'\u2064', 0}, // INVISIBLE PLUS {U'\u2212', '-'}, // MINUS SIGN {U'\u2215', '/'}, // DIVISION SLASH {U'\u2216', '\\'}, // SET MINUS @@ -1521,6 +1530,7 @@ static void maybeDiagnoseUTF8Homoglyph(D {U'\u2236', ':'}, // RATIO {U'\u223c', '~'}, // TILDE OPERATOR {U'\ua789', ':'}, // MODIFIER LETTER COLON +{U'\ufeff', 0}, // ZERO WIDTH NO-BREAK SPACE {U'\uff01', '!'}, // FULLWIDTH EXCLAMATION MARK {U'\uff03', '#'}, // FULLWIDTH NUMBER SIGN {U'\uff04', '$'}, // FULLWIDTH DOLLAR SIGN @@ -1560,9 +1570,14 @@ static void maybeDiagnoseUTF8Homoglyph(D llvm::raw_svector_ostream CharOS(CharBuf); llvm::write_hex(CharOS, C, llvm::HexPrintStyle::Upper, 4); } -const char LooksLikeStr[] = {Homoglyph->LooksLike, 0}; -Diags.Report(Range.getBegin(), diag::warn_utf8_symbol_homoglyph) -<< Range << CharBuf << LooksLikeStr; +if (Homoglyph->LooksLike) { + const char LooksLikeStr[] = {Homoglyph->LooksLike, 0}; + Diags.Report(Range.getBegin(), diag::warn_utf8_symbol_homoglyph) + << Range << CharBuf << LooksLikeStr; +} else { + Diags.Report(Range.getBegin(), diag::warn_utf8_symbol_zero_width) + << Range << CharBuf; +} } } Modified: cfe/trunk/test/Lexer/unicode.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/unicode.c?rev=341700=341699=341700=diff == --- cfe/trunk/test/Lexer/unicode.c (original) +++ cfe/trunk/test/Lexer/unicode.c Fri Sep 7 12:25:39 2018 @@ -38,3 +38,10 @@ int n; = 3; // expected-warning {{tre int *nêêv = ;; // expected-warning 2{{treating Unicode character as identifier character rather than as ':' symbol}} // expected-warning@-1 {{treating Unicode character as identifier character rather than as ';' symbol}} int vï¼ï¼»ï¼ï¼½ï¼autoï¼ï½returnï½xï¼ï½ï¼ï¼; // expected-warning 12{{treating Unicode character}} + +int â xxâ; +// expected-warning@-1 {{identifier contains Unicode character that is invisible in some environments}} +// expected-warning@-2 {{identifier contains Unicode character that is invisible in some environments}} +// expected-warning@-3 {{identifier contains Unicode character that is invisible in some environments}} +int fooâbar = 0; // expected-warning {{identifier contains Unicode character that is invisible in some environments}} +int x = foobar; // expected-error {{undeclared identifier}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51805: [X86] Custom emit __builtin_rdtscp so we can emit an explicit store for the out parameter
This revision was automatically updated to reflect the committed changes. Closed by commit rL341699: [X86] Custom emit __builtin_rdtscp so we can emit an explicit store for the out… (authored by ctopper, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D51805?vs=164467=164490#toc Repository: rL LLVM https://reviews.llvm.org/D51805 Files: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/rd-builtins.c Index: cfe/trunk/test/CodeGen/rd-builtins.c === --- cfe/trunk/test/CodeGen/rd-builtins.c +++ cfe/trunk/test/CodeGen/rd-builtins.c @@ -14,3 +14,12 @@ // CHECK: @test_rdtsc // CHECK: call i64 @llvm.x86.rdtsc } + +unsigned long long test_rdtscp(unsigned int *a) { +// CHECK: @test_rdtscp +// CHECK: [[RDTSCP:%.*]] = call { i64, i32 } @llvm.x86.rdtscp +// CHECK: [[TSC_AUX:%.*]] = extractvalue { i64, i32 } [[RDTSCP]], 1 +// CHECK: store i32 [[TSC_AUX]], i32* %{{.*}} +// CHECK: [[TSC:%.*]] = extractvalue { i64, i32 } [[RDTSCP]], 0 + return __rdtscp(a); +} Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp === --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp @@ -9158,6 +9158,12 @@ case X86::BI__rdtsc: { return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_rdtsc)); } + case X86::BI__builtin_ia32_rdtscp: { +Value *Call = Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_rdtscp)); +Builder.CreateDefaultAlignedStore(Builder.CreateExtractValue(Call, 1), + Ops[0]); +return Builder.CreateExtractValue(Call, 0); + } case X86::BI__builtin_ia32_undef128: case X86::BI__builtin_ia32_undef256: case X86::BI__builtin_ia32_undef512: Index: cfe/trunk/test/CodeGen/rd-builtins.c === --- cfe/trunk/test/CodeGen/rd-builtins.c +++ cfe/trunk/test/CodeGen/rd-builtins.c @@ -14,3 +14,12 @@ // CHECK: @test_rdtsc // CHECK: call i64 @llvm.x86.rdtsc } + +unsigned long long test_rdtscp(unsigned int *a) { +// CHECK: @test_rdtscp +// CHECK: [[RDTSCP:%.*]] = call { i64, i32 } @llvm.x86.rdtscp +// CHECK: [[TSC_AUX:%.*]] = extractvalue { i64, i32 } [[RDTSCP]], 1 +// CHECK: store i32 [[TSC_AUX]], i32* %{{.*}} +// CHECK: [[TSC:%.*]] = extractvalue { i64, i32 } [[RDTSCP]], 0 + return __rdtscp(a); +} Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp === --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp @@ -9158,6 +9158,12 @@ case X86::BI__rdtsc: { return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_rdtsc)); } + case X86::BI__builtin_ia32_rdtscp: { +Value *Call = Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_rdtscp)); +Builder.CreateDefaultAlignedStore(Builder.CreateExtractValue(Call, 1), + Ops[0]); +return Builder.CreateExtractValue(Call, 0); + } case X86::BI__builtin_ia32_undef128: case X86::BI__builtin_ia32_undef256: case X86::BI__builtin_ia32_undef512: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r341699 - [X86] Custom emit __builtin_rdtscp so we can emit an explicit store for the out parameter
Author: ctopper Date: Fri Sep 7 12:14:24 2018 New Revision: 341699 URL: http://llvm.org/viewvc/llvm-project?rev=341699=rev Log: [X86] Custom emit __builtin_rdtscp so we can emit an explicit store for the out parameter This is the clang side of D51803. The llvm intrinsic now returns two results. So we need to emit an explicit store in IR for the out parameter. This is similar to addcarry/subborrow/rdrand/rdseed. Differential Revision: https://reviews.llvm.org/D51805 Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/rd-builtins.c Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=341699=341698=341699=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Sep 7 12:14:24 2018 @@ -9158,6 +9158,12 @@ Value *CodeGenFunction::EmitX86BuiltinEx case X86::BI__rdtsc: { return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_rdtsc)); } + case X86::BI__builtin_ia32_rdtscp: { +Value *Call = Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_rdtscp)); +Builder.CreateDefaultAlignedStore(Builder.CreateExtractValue(Call, 1), + Ops[0]); +return Builder.CreateExtractValue(Call, 0); + } case X86::BI__builtin_ia32_undef128: case X86::BI__builtin_ia32_undef256: case X86::BI__builtin_ia32_undef512: Modified: cfe/trunk/test/CodeGen/rd-builtins.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/rd-builtins.c?rev=341699=341698=341699=diff == --- cfe/trunk/test/CodeGen/rd-builtins.c (original) +++ cfe/trunk/test/CodeGen/rd-builtins.c Fri Sep 7 12:14:24 2018 @@ -14,3 +14,12 @@ int test_rdtsc() { // CHECK: @test_rdtsc // CHECK: call i64 @llvm.x86.rdtsc } + +unsigned long long test_rdtscp(unsigned int *a) { +// CHECK: @test_rdtscp +// CHECK: [[RDTSCP:%.*]] = call { i64, i32 } @llvm.x86.rdtscp +// CHECK: [[TSC_AUX:%.*]] = extractvalue { i64, i32 } [[RDTSCP]], 1 +// CHECK: store i32 [[TSC_AUX]], i32* %{{.*}} +// CHECK: [[TSC:%.*]] = extractvalue { i64, i32 } [[RDTSCP]], 0 + return __rdtscp(a); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r335081 - Recommit r335063: [Darwin] Add a warning for missing include path for libstdc++
On Fri, 7 Sep 2018 at 05:41, Nico Weber wrote: > On Wed, Sep 5, 2018 at 9:25 PM Alex L wrote: > >> Sorry for the late response, >> >> On Sat, 18 Aug 2018 at 20:10, Nico Weber wrote: >> >>> Also, the diag text should probably say "pass '-stdlib=libc++' " not >>> "pass '-std=libc++' "? >>> >> >> Good catch, thanks! I'll commit a fixup for it. >> > Fixed in r341697. > >> >>> >>> On Sat, Aug 18, 2018 at 11:06 PM Nico Weber wrote: >>> Should this maybe not be emitted when compiling e.g. .ii files (preprocessed output)? I just got this when I built a standalone .ii file with some bug repro after I deleted all -I and -isysroot flags and whatnot, since they aren't needed for preprocessed files. >>> >> That would make sense, but I'm not sure how easy it is to determine if a >> file is already preprocessed. I'll try to create a patch for this fixup. >> > > Probably you'd want something like > http://llvm-cs.pcc.me.uk/tools/clang/lib/Driver/Types.cpp#123 that > returns true for all (or most) of the TY_PP_ types, and then just rely > on lookupTypeForExtension. > Good idea, I'll try it out. > > >> >> >> >>> On Tue, Jun 19, 2018 at 6:52 PM Alex Lorenz via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: arphaman > Date: Tue Jun 19 15:47:53 2018 > New Revision: 335081 > > URL: http://llvm.org/viewvc/llvm-project?rev=335081=rev > Log: > Recommit r335063: [Darwin] Add a warning for missing include path for > libstdc++ > > The recommit ensures that the tests that failed on bots don't trigger > the warning. > > Xcode 10 removes support for libstdc++, but the users just get a > confusing > include not file warning when including an STL header (when building > for iOS6 > which uses libstdc++ by default for example). > This patch adds a new warning that lets the user know that the > libstdc++ include > path was not found to ensure that the user is more aware of why the > error occurs. > > rdar://40830462 > > Differential Revision: https://reviews.llvm.org/D48297 > > Added: > cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp > Modified: > cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td > cfe/trunk/include/clang/Lex/HeaderSearch.h > cfe/trunk/lib/Frontend/InitHeaderSearch.cpp > cfe/trunk/test/CodeGenCXX/apple-kext-guard-variable.cpp > cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp > > Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=335081=335080=335081=diff > > == > --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original) > +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Tue Jun > 19 15:47:53 2018 > @@ -236,4 +236,9 @@ def err_invalid_vfs_overlay : Error< > > def warn_option_invalid_ocl_version : Warning< >"OpenCL version %0 does not support the option '%1'">, > InGroup; > + > +def warn_stdlibcxx_not_found : Warning< > + "include path for stdlibc++ headers not found; pass '-std=libc++' > on the " > + "command line to use the libc++ standard library instead">, > + InGroup>; > } > > Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=335081=335080=335081=diff > > == > --- cfe/trunk/include/clang/Lex/HeaderSearch.h (original) > +++ cfe/trunk/include/clang/Lex/HeaderSearch.h Tue Jun 19 15:47:53 2018 > @@ -272,6 +272,8 @@ public: > >FileManager () const { return FileMgr; } > > + DiagnosticsEngine () const { return Diags; } > + >/// Interface for setting the file search paths. >void SetSearchPaths(const std::vector , >unsigned angledDirIdx, unsigned systemDirIdx, > > Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=335081=335080=335081=diff > > == > --- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original) > +++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Tue Jun 19 15:47:53 > 2018 > @@ -14,6 +14,7 @@ > #include "clang/Basic/FileManager.h" > #include "clang/Basic/LangOptions.h" > #include "clang/Config/config.h" // C_INCLUDE_DIRS > +#include "clang/Frontend/FrontendDiagnostic.h" > #include "clang/Frontend/Utils.h" > #include "clang/Lex/HeaderMap.h" > #include
r341697 - warn_stdlibcxx_not_found: suggest '-stdlib=libc++' instead of '-std'
Author: arphaman Date: Fri Sep 7 11:59:45 2018 New Revision: 341697 URL: http://llvm.org/viewvc/llvm-project?rev=341697=rev Log: warn_stdlibcxx_not_found: suggest '-stdlib=libc++' instead of '-std' Addresses first post-commit feedback for r335081 from Nico Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=341697=341696=341697=diff == --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Fri Sep 7 11:59:45 2018 @@ -238,7 +238,7 @@ def warn_option_invalid_ocl_version : Wa "OpenCL version %0 does not support the option '%1'">, InGroup; def warn_stdlibcxx_not_found : Warning< - "include path for stdlibc++ headers not found; pass '-std=libc++' on the " + "include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the " "command line to use the libc++ standard library instead">, InGroup>; } Modified: cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp?rev=341697=341696=341697=diff == --- cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp (original) +++ cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp Fri Sep 7 11:59:45 2018 @@ -1,5 +1,5 @@ // RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist %s 2>&1 | FileCheck %s // RUN: %clang -cc1 -triple arm64-apple-ios6.0.0 -isysroot %S/doesnotexist -stdlib=libc++ %s -verify -// CHECK: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead +// CHECK: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead // expected-no-diagnostics ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51747: [clangd] Implement deprecation diagnostics with lower severity.
kadircet added a comment. In https://reviews.llvm.org/D51747#1227089, @ilya-biryukov wrote: > Not sure if it's fine to hijack our own diagnostic-specific flags in to clang > command args. > > Cons that I see: > > 1. There is no way for the users to turn them off if they find them > non-useful. If we add a way, it would be more config parameters which overlap > with other mechanism that we have - compiler flags. > 2. Users who are used to having them as warnings will now see them as notes. > Again, no way to tweak this behavior. > > What's our use-case? Maybe we should ask the clients to add -Wdeprecated if > they care about those? > > PS In case I'm missing the context here, please let me know. Agree with you, I think it would be better to provide it as an option. https://reviews.llvm.org/D51724 with this one we added a way to show deprecated symbols on code completion responses and wanted to move forward with showing the ones that are already in existing code. Comment at: clangd/Diagnostics.cpp:299 +D.Severity = +D.Category == "Deprecations" ? DiagnosticsEngine::Note : DiagLevel; return D; ioeric wrote: > kadircet wrote: > > Couldn't find a better way to check for this one. Category types are coming > > from tablegen file > > https://github.com/llvm-mirror/clang/blob/master/include/clang/Basic/DiagnosticGroups.td#L128 > > which does not expose category id, at least I couldn't find even if it > > does. > Have you tried the Diagnostic ID (i.e. `Info.getID()`)? It matches the diag > kinds defined in `DiagnosticSemaKinds.inc` (e.g. `warn_deprecated`). Unfortunately these are also internal, https://github.com/llvm-mirror/clang/blob/master/lib/Basic/DiagnosticIDs.cpp#L97 Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D51747 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51808: [CUDA] Ignore uncallable functions when we check for usual deallocators.
tra created this revision. tra added a reviewer: rsmith. Herald added subscribers: bixia, jlebar, sanjoy. Previously clang considered function variants from both sides of compilation and that sometimes resulted in picking up wrong deallocation function. https://reviews.llvm.org/D51808 Files: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp clang/include/clang/AST/DeclCXX.h clang/include/clang/Sema/Sema.h clang/lib/AST/DeclCXX.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaExprCXX.cpp clang/test/CodeGenCUDA/usual-deallocators.cu clang/test/SemaCUDA/call-host-fn-from-device.cu clang/test/SemaCUDA/usual-deallocators.cu Index: clang/test/SemaCUDA/usual-deallocators.cu === --- /dev/null +++ clang/test/SemaCUDA/usual-deallocators.cu @@ -0,0 +1,95 @@ +// RUN: %clang_cc1 %s --std=c++11 -triple nvptx-unknown-unknown -fcuda-is-device \ +// RUN: -emit-llvm -o /dev/null -verify=device +// RUN: %clang_cc1 %s --std=c++11 -triple nvptx-unknown-unknown \ +// RUN: -emit-llvm -o /dev/null -verify=host +// RUN: %clang_cc1 %s --std=c++17 -triple nvptx-unknown-unknown -fcuda-is-device \ +// RUN: -emit-llvm -o /dev/null -verify=device +// RUN: %clang_cc1 %s --std=c++17 -triple nvptx-unknown-unknown \ +// RUN: -emit-llvm -o /dev/null -verify=host + +#include "Inputs/cuda.h" +extern __host__ void host_fn(); +extern __device__ void dev_fn(); +extern __host__ __device__ void hd_fn(); + +struct H1D1 { + __host__ void operator delete(void *) { host_fn(); }; + __device__ void operator delete(void *) { dev_fn(); }; +}; + +struct h1D1 { + __host__ void operator delete(void *) = delete; + // host-note@-1 {{'operator delete' has been explicitly marked deleted here}} + __device__ void operator delete(void *) { dev_fn(); }; +}; + +struct H1d1 { + __host__ void operator delete(void *) { host_fn(); }; + __device__ void operator delete(void *) = delete; + // device-note@-1 {{'operator delete' has been explicitly marked deleted here}} +}; + +struct H1D2 { + __host__ void operator delete(void *) { host_fn(); }; + __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); }; +}; + +struct H2D1 { + __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); }; + __device__ void operator delete(void *) { dev_fn(); }; +}; + +struct H2D2 { + __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); }; + __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); }; +}; + +struct H1D1D2 { + __host__ void operator delete(void *) { host_fn(); }; + __device__ void operator delete(void *) { dev_fn(); }; + __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); }; +}; + +struct H1H2D1 { + __host__ void operator delete(void *) { host_fn(); }; + __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); }; + __device__ void operator delete(void *) { dev_fn(); }; +}; + +struct H1H2D2 { + __host__ void operator delete(void *) { host_fn(); }; + __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); }; + __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); }; +}; + +struct H1H2D1D2 { + __host__ void operator delete(void *) { host_fn(); }; + __host__ void operator delete(void *, __SIZE_TYPE__) { host_fn(); }; + __device__ void operator delete(void *) { dev_fn(); }; + __device__ void operator delete(void *, __SIZE_TYPE__) { dev_fn(); }; +}; + + +template +__host__ __device__ void test_hd(void *p) { + T *t = (T *)p; + delete t; + // host-error@-1 {{attempt to use a deleted function}} + // device-error@-2 {{attempt to use a deleted function}} +} + +__host__ __device__ void tests_hd(void *t) { + test_hd(t); + test_hd(t); + // host-note@-1 {{in instantiation of function template specialization 'test_hd' requested here}} + test_hd(t); + // device-note@-1 {{in instantiation of function template specialization 'test_hd' requested here}} + test_hd(t); + test_hd(t); + test_hd(t); + test_hd(t); + test_hd(t); + test_hd(t); + test_hd(t); + test_hd(t); +} Index: clang/test/SemaCUDA/call-host-fn-from-device.cu === --- clang/test/SemaCUDA/call-host-fn-from-device.cu +++ clang/test/SemaCUDA/call-host-fn-from-device.cu @@ -41,12 +41,12 @@ operator Dummy() { return Dummy(); } // expected-note@-1 {{'operator Dummy' declared here}} - __host__ void operator delete(void*); - __device__ void operator delete(void*, size_t); + __host__ void operator delete(void *) { host_fn(); }; + __device__ void operator delete(void*, __SIZE_TYPE__); }; struct U { - __device__ void operator delete(void*, size_t) = delete; + __device__ void operator delete(void*, __SIZE_TYPE__) = delete; __host__ __device__ void operator delete(void*); }; Index: clang/test/CodeGenCUDA/usual-deallocators.cu === --- /dev/null +++
[PATCH] D51805: [X86] Custom emit __builtin_rdtscp so we can emit an explicit store for the out parameter
RKSimon accepted this revision. RKSimon added a comment. This revision is now accepted and ready to land. LGTM - The lack of existing tests is worrying. https://reviews.llvm.org/D51805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51807: Remove all uses of DIFlagBlockByrefStruct from Clang
aprantl added a comment. ( https://reviews.llvm.org/D51763 is not *really* a dependency, but it's closely related. ) https://reviews.llvm.org/D51807 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51752: NFC: move isRepeatedBytePattern from clang to Constant
jfb updated this revision to Diff 164481. jfb added a comment. - Use isBytewiseValue instead. Repository: rC Clang https://reviews.llvm.org/D51752 Files: lib/CodeGen/CGDecl.cpp Index: lib/CodeGen/CGDecl.cpp === --- lib/CodeGen/CGDecl.cpp +++ lib/CodeGen/CGDecl.cpp @@ -30,6 +30,7 @@ #include "clang/Basic/TargetInfo.h" #include "clang/CodeGen/CGFunctionInfo.h" #include "clang/Frontend/CodeGenOptions.h" +#include "llvm/Analysis/ValueTracking.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/Intrinsics.h" @@ -948,111 +949,17 @@ canEmitInitWithFewStoresAfterBZero(Init, StoreBudget); } -/// A byte pattern. -/// -/// Can be "any" pattern if the value was padding or known to be undef. -/// Can be "none" pattern if a sequence doesn't exist. -class BytePattern { - uint8_t Val; - enum class ValueType : uint8_t { Specific, Any, None } Type; - BytePattern(ValueType Type) : Type(Type) {} - -public: - BytePattern(uint8_t Value) : Val(Value), Type(ValueType::Specific) {} - static BytePattern Any() { return BytePattern(ValueType::Any); } - static BytePattern None() { return BytePattern(ValueType::None); } - bool isAny() const { return Type == ValueType::Any; } - bool isNone() const { return Type == ValueType::None; } - bool isValued() const { return Type == ValueType::Specific; } - uint8_t getValue() const { -assert(isValued()); -return Val; - } - BytePattern merge(const BytePattern Other) const { -if (isNone() || Other.isNone()) - return None(); -if (isAny()) - return Other; -if (Other.isAny()) - return *this; -if (getValue() == Other.getValue()) - return *this; -return None(); - } -}; - -/// Figures out whether the constant can be initialized with memset. -static BytePattern constantIsRepeatedBytePattern(llvm::Constant *C) { - if (isa(C) || isa(C)) -return BytePattern(0x00); - if (isa(C)) -return BytePattern::Any(); - - if (isa(C)) { -auto *Int = cast(C); -if (Int->getBitWidth() % 8 != 0) - return BytePattern::None(); -const llvm::APInt = Int->getValue(); -if (Value.isSplat(8)) - return BytePattern(Value.getLoBits(8).getLimitedValue()); -return BytePattern::None(); - } - - if (isa(C)) { -auto *FP = cast(C); -llvm::APInt Bits = FP->getValueAPF().bitcastToAPInt(); -if (Bits.getBitWidth() % 8 != 0) - return BytePattern::None(); -if (!Bits.isSplat(8)) - return BytePattern::None(); -return BytePattern(Bits.getLimitedValue() & 0xFF); - } - - if (isa(C)) { -llvm::Constant *Splat = cast(C)->getSplatValue(); -if (Splat) - return constantIsRepeatedBytePattern(Splat); -return BytePattern::None(); - } - - if (isa(C) || isa(C)) { -BytePattern Pattern(BytePattern::Any()); -for (unsigned I = 0, E = C->getNumOperands(); I != E; ++I) { - llvm::Constant *Elt = cast(C->getOperand(I)); - Pattern = Pattern.merge(constantIsRepeatedBytePattern(Elt)); - if (Pattern.isNone()) -return Pattern; -} -return Pattern; - } - - if (llvm::ConstantDataSequential *CDS = - dyn_cast(C)) { -BytePattern Pattern(BytePattern::Any()); -for (unsigned I = 0, E = CDS->getNumElements(); I != E; ++I) { - llvm::Constant *Elt = CDS->getElementAsConstant(I); - Pattern = Pattern.merge(constantIsRepeatedBytePattern(Elt)); - if (Pattern.isNone()) -return Pattern; -} -return Pattern; - } - - // BlockAddress, ConstantExpr, and everything else is scary. - return BytePattern::None(); -} - /// Decide whether we should use memset to initialize a local variable instead /// of using a memcpy from a constant global. Assumes we've already decided to /// not user bzero. /// FIXME We could be more clever, as we are for bzero above, and generate /// memset followed by stores. It's unclear that's worth the effort. -static BytePattern shouldUseMemSetToInitialize(llvm::Constant *Init, - uint64_t GlobalSize) { +static llvm::Value *shouldUseMemSetToInitialize(llvm::Constant *Init, +uint64_t GlobalSize) { uint64_t SizeLimit = 32; if (GlobalSize <= SizeLimit) -return BytePattern::None(); - return constantIsRepeatedBytePattern(Init); +return nullptr; + return llvm::isBytewiseValue(Init); } static void emitStoresForConstant(CodeGenModule , const VarDecl , @@ -1081,9 +988,14 @@ return; } - BytePattern Pattern = shouldUseMemSetToInitialize(constant, ConstantSize); - if (!Pattern.isNone()) { -uint8_t Value = Pattern.isAny() ? 0x00 : Pattern.getValue(); + llvm::Value *Pattern = shouldUseMemSetToInitialize(constant, ConstantSize); + if (Pattern) { +uint64_t Value = 0x00; +if (!isa(Pattern)) { + const llvm::APInt = cast(Pattern)->getValue(); + assert(AP.getBitWidth()
[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.
kadircet updated this revision to Diff 164477. kadircet added a comment. - Rebase and use new signature help. Currently the problem is, there are again some tests out there that rely on CodeCompeleteOrdinaryName to be called even when getting overloads at an unknown parameter type. These tests are: Clang :: CodeCompletion/call.cpp Clang :: Index/code-completion.cpp Clang :: Index/complete-call.cpp Clang :: Index/complete-functor-call.cpp Clang :: Index/complete-optional-params.cpp Clang :: Index/complete-pointer-and-reference-to-functions.cpp You can run something like this to check for the output(change ../clangd_bugs): ninja c-index-test && ./bin/c-index-test -code-completion-at=../clangd_bugs/tools/clang/test/Index/complete-call.cpp:53:12 ../clan gd_bugs/tools/clang/test/Index/complete-call.cpp As you can see current version generates only overloadcandidates, but tests don't check them with a next loop, because they expect other completions, which is not problematic but after checks for the items they also look for completion context, which is not set as desired if CodeCompleteOrdinaryName or CodeCompleteExpression is not called. But for the first test case it is more complicated, it checks for code patterns like dynamic_cast(EXPR); which is not generated if we don't call CodeCompletionOrdinaryName or Expressions. Repository: rC Clang https://reviews.llvm.org/D51038 Files: include/clang/Parse/Parser.h lib/Parse/ParseExpr.cpp test/CodeCompletion/function-overloads-inside-param.cpp test/CodeCompletion/function-overloads.cpp test/Index/complete-block-property-assignment.m Index: test/Index/complete-block-property-assignment.m === --- test/Index/complete-block-property-assignment.m +++ test/Index/complete-block-property-assignment.m @@ -60,13 +60,20 @@ // RUN: c-index-test -code-completion-at=%s:51:16 %s | FileCheck -check-prefix=CHECK-NO %s // RUN: c-index-test -code-completion-at=%s:52:23 %s | FileCheck -check-prefix=CHECK-NO %s // RUN: c-index-test -code-completion-at=%s:53:12 %s | FileCheck -check-prefix=CHECK-NO %s -// RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck -check-prefix=CHECK-NO %s // RUN: c-index-test -code-completion-at=%s:56:15 %s | FileCheck -check-prefix=CHECK-NO %s // CHECK-NO: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35) // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType Obj *}{TypedText obj} (35) // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction} (35) // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler} (35) // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType void (^)(int *)}{TypedText onReadonly} (35) // CHECK-NO-NEXT: ObjCPropertyDecl:{ResultType int (^)(int)}{TypedText processEvent} (35) +// RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck -check-prefix=CHECK-NO1 %s +// CHECK-NO1: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35) +// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType Obj *}{TypedText obj} (35) +// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType void (^)(Obj *)}{TypedText onAction} (35) +// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType FooBlock}{TypedText onEventHandler} (35) +// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType void (^)(int *)}{TypedText onReadonly} (35) +// CHECK-NO1-NEXT: ObjCPropertyDecl:{ResultType int (^)(int)}{TypedText processEvent} (35) +// CHECK-NO1-NEXT: OverloadCandidate:{ResultType void}{Text func}{LeftParen (}{CurrentParameter int x}{RightParen )} (1) @end Index: test/CodeCompletion/function-overloads.cpp === --- /dev/null +++ test/CodeCompletion/function-overloads.cpp @@ -0,0 +1,8 @@ +void f(int i, int j = 2, int k = 5); +void f(float x, float y...); + +void test() { + ::f( + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:5:7 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s + // CHECK-CC1: f(<#int i#>{#, <#int j = 2#>{#, <#int k = 5#>#}#}) + // CHECK-CC1: f(<#float x#>, <#float y, ...#>) Index: test/CodeCompletion/function-overloads-inside-param.cpp === --- /dev/null +++ test/CodeCompletion/function-overloads-inside-param.cpp @@ -0,0 +1,8 @@ +void f(int i, int j = 2, int k = 5); +void f(float x, float y...); + +void test() { + ::f(1 + // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:5:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s + // CHECK-CC1: f(<#int i#>{#, <#int j = 2#>{#, <#int k = 5#>#}#}) + // CHECK-CC1: f(<#float x#>, <#float y, ...#>) Index: lib/Parse/ParseExpr.cpp === --- lib/Parse/ParseExpr.cpp +++ lib/Parse/ParseExpr.cpp @@ -1659,12 +1659,27 @@ if (OpKind == tok::l_paren || !LHS.isInvalid()) { if (Tok.isNot(tok::r_paren)) { - if (ParseExpressionList(ArgExprs, CommaLocs, [&] { -
[PATCH] D51807: Remove all uses of DIFlagBlockByrefStruct from Clang
aprantl created this revision. aprantl added a reviewer: debug-info. Herald added a subscriber: JDevlieghere. This patch removes the last reason why DIFlagBlockByrefStruct from Clang by directly implementing the drilling into the member type done in DwarfDebug::DbgVariable::getType() into the frontend. https://reviews.llvm.org/D51807 Files: lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.h test/CodeGenObjC/block-byref-debuginfo.m Index: test/CodeGenObjC/block-byref-debuginfo.m === --- test/CodeGenObjC/block-byref-debuginfo.m +++ test/CodeGenObjC/block-byref-debuginfo.m @@ -1,16 +1,35 @@ // RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak -debug-info-kind=limited -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s -// rdar://problem/14386148 +// CHECK: !DILocalVariable(name: "foo", {{.*}}type: ![[FOOTY:[0-9]+]]) +// CHECK: ![[FOOTY]] = {{.*}}!DICompositeType({{.*}}, name: "Foo" + +// CHECK-NOT: DIFlagBlockByrefStruct +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "__block_literal_1", +// CHECK-SAME: size: 320, elements: ![[BL_ELTS:[0-9]+]]) +// CHECK: ![[BL_ELTS]] = !{{.*}}![[WFOO:[0-9]+]]} + // Test that the foo is aligned at an 8 byte boundary in the DWARF // expression (256) that locates it inside of the byref descriptor: -// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "foo", -// CHECK-NOT:line: -// CHECK-SAME: offset: 256 +// CHECK: ![[WFOO]] = !DIDerivedType(tag: DW_TAG_member, name: "foo", +// CHECK-SAME: baseType: ![[PTR:[0-9]+]] +// CHECK-SAME: offset: 256) + +// CHECK: ![[PTR]] = !DIDerivedType(tag: DW_TAG_pointer_type, +// CHECK-SAME: baseType: ![[WRAPPER:[0-9]+]] +// CHECK: ![[WRAPPER]] = !DICompositeType(tag: DW_TAG_structure_type, scope: +// CHECK: elements: ![[WR_ELTS:[0-9]+]]) +// CHECK: ![[WR_ELTS]] = !{{.*}}![[WFOO:[0-9]+]]} +// CHECK: ![[WFOO]] = !DIDerivedType(tag: DW_TAG_member, name: "foo", +// CHECK-SAME: baseType: ![[FOOTY]] + +// CHECK: !DILocalVariable(name: "foo", {{.*}}type: ![[FOOTY]]) + struct Foo { unsigned char *data; }; int func() { __attribute__((__blocks__(byref))) struct Foo foo; + ^{ foo.data = 0; }(); return 0; } Index: lib/CodeGen/CGDebugInfo.h === --- lib/CodeGen/CGDebugInfo.h +++ lib/CodeGen/CGDebugInfo.h @@ -491,9 +491,16 @@ llvm::Optional ArgNo, CGBuilderTy ); + struct BlockByRefType { +/// The wrapper struct used inside the __block_literal struct. +llvm::DIType *BlockByRefWrapper; +/// The type as it appears in the source code. +llvm::DIType *WrappedType; + }; + /// Build up structure info for the byref. See \a BuildByRefType. - llvm::DIType *EmitTypeForVarWithBlocksAttr(const VarDecl *VD, - uint64_t *OffSet); + BlockByRefType EmitTypeForVarWithBlocksAttr(const VarDecl *VD, + uint64_t *OffSet); /// Get context info for the DeclContext of \p Decl. llvm::DIScope *getDeclContextDescriptor(const Decl *D); Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -3565,9 +3565,9 @@ DBuilder.finalizeSubprogram(Fn->getSubprogram()); } -llvm::DIType *CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD, -uint64_t *XOffset) { - +CGDebugInfo::BlockByRefType +CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD, + uint64_t *XOffset) { SmallVector EltTys; QualType FType; uint64_t FieldSize, FieldOffset; @@ -3619,23 +3619,21 @@ } FType = Type; - llvm::DIType *FieldTy = getOrCreateType(FType, Unit); + llvm::DIType *WrappedTy = getOrCreateType(FType, Unit); FieldSize = CGM.getContext().getTypeSize(FType); FieldAlign = CGM.getContext().toBits(Align); *XOffset = FieldOffset; - FieldTy = DBuilder.createMemberType(Unit, VD->getName(), Unit, 0, FieldSize, - FieldAlign, FieldOffset, - llvm::DINode::FlagZero, FieldTy); + llvm::DIType *FieldTy = DBuilder.createMemberType( + Unit, VD->getName(), Unit, 0, FieldSize, FieldAlign, FieldOffset, + llvm::DINode::FlagZero, WrappedTy); EltTys.push_back(FieldTy); FieldOffset += FieldSize; llvm::DINodeArray Elements = DBuilder.getOrCreateArray(EltTys); - - llvm::DINode::DIFlags Flags = llvm::DINode::FlagBlockByrefStruct; - - return DBuilder.createStructType(Unit, "", Unit, 0, FieldOffset, 0, Flags, - nullptr,
[PATCH] D51806: [clang-cl] Enable -march
aganea created this revision. aganea added reviewers: thakis, ddunbar, hans. Herald added a subscriber: cfe-commits. Currently, `-march` does not work in the `clang-cl` driver. We are currently migrating from MSVC. The project size makes that we have to stick with `clang-cl` for a little while. However, we don't want to loose optimisation oportunities in the runtime code, and the MSVC flag `/arch` only supports a limited set of options. Repository: rC Clang https://reviews.llvm.org/D51806 Files: include/clang/Driver/Options.td Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1931,7 +1931,7 @@ def mwatchos_version_min_EQ : Joined<["-"], "mwatchos-version-min=">, Group; def mwatchos_simulator_version_min_EQ : Joined<["-"], "mwatchos-simulator-version-min=">; def mwatchsimulator_version_min_EQ : Joined<["-"], "mwatchsimulator-version-min=">, Alias; -def march_EQ : Joined<["-"], "march=">, Group; +def march_EQ : Joined<["-"], "march=">, Group, Flags<[CoreOption]>; def masm_EQ : Joined<["-"], "masm=">, Group, Flags<[DriverOption]>; def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group; def mimplicit_it_EQ : Joined<["-"], "mimplicit-it=">, Group; Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1931,7 +1931,7 @@ def mwatchos_version_min_EQ : Joined<["-"], "mwatchos-version-min=">, Group; def mwatchos_simulator_version_min_EQ : Joined<["-"], "mwatchos-simulator-version-min=">; def mwatchsimulator_version_min_EQ : Joined<["-"], "mwatchsimulator-version-min=">, Alias; -def march_EQ : Joined<["-"], "march=">, Group; +def march_EQ : Joined<["-"], "march=">, Group, Flags<[CoreOption]>; def masm_EQ : Joined<["-"], "masm=">, Group, Flags<[DriverOption]>; def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group; def mimplicit_it_EQ : Joined<["-"], "mimplicit-it=">, Group; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51805: [X86] Custom emit __builtin_rdtscp so we can emit an explicit store for the out parameter
craig.topper created this revision. craig.topper added reviewers: RKSimon, spatel. This is the clang side of https://reviews.llvm.org/D51803. The llvm intrinsic now returns two results. So we need to emit an explicit store in IR for the out parameter. This is similar to addcarry/subborrow/rdrand/rdseed. https://reviews.llvm.org/D51805 Files: lib/CodeGen/CGBuiltin.cpp test/CodeGen/rd-builtins.c Index: test/CodeGen/rd-builtins.c === --- test/CodeGen/rd-builtins.c +++ test/CodeGen/rd-builtins.c @@ -14,3 +14,12 @@ // CHECK: @test_rdtsc // CHECK: call i64 @llvm.x86.rdtsc } + +unsigned long long test_rdtscp(unsigned int *a) { +// CHECK: @test_rdtscp +// CHECK: [[RDTSCP:%.*]] = call { i64, i32 } @llvm.x86.rdtscp +// CHECK: [[TSC_AUX:%.*]] = extractvalue { i64, i32 } [[RDTSCP]], 1 +// CHECK: store i32 [[TSC_AUX]], i32* %{{.*}} +// CHECK: [[TSC:%.*]] = extractvalue { i64, i32 } [[RDTSCP]], 0 + return __rdtscp(a); +} Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -9158,6 +9158,12 @@ case X86::BI__rdtsc: { return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_rdtsc)); } + case X86::BI__builtin_ia32_rdtscp: { +Value *Call = Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_rdtscp)); +Builder.CreateDefaultAlignedStore(Builder.CreateExtractValue(Call, 1), + Ops[0]); +return Builder.CreateExtractValue(Call, 0); + } case X86::BI__builtin_ia32_undef128: case X86::BI__builtin_ia32_undef256: case X86::BI__builtin_ia32_undef512: Index: test/CodeGen/rd-builtins.c === --- test/CodeGen/rd-builtins.c +++ test/CodeGen/rd-builtins.c @@ -14,3 +14,12 @@ // CHECK: @test_rdtsc // CHECK: call i64 @llvm.x86.rdtsc } + +unsigned long long test_rdtscp(unsigned int *a) { +// CHECK: @test_rdtscp +// CHECK: [[RDTSCP:%.*]] = call { i64, i32 } @llvm.x86.rdtscp +// CHECK: [[TSC_AUX:%.*]] = extractvalue { i64, i32 } [[RDTSCP]], 1 +// CHECK: store i32 [[TSC_AUX]], i32* %{{.*}} +// CHECK: [[TSC:%.*]] = extractvalue { i64, i32 } [[RDTSCP]], 0 + return __rdtscp(a); +} Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -9158,6 +9158,12 @@ case X86::BI__rdtsc: { return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_rdtsc)); } + case X86::BI__builtin_ia32_rdtscp: { +Value *Call = Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_rdtscp)); +Builder.CreateDefaultAlignedStore(Builder.CreateExtractValue(Call, 1), + Ops[0]); +return Builder.CreateExtractValue(Call, 0); + } case X86::BI__builtin_ia32_undef128: case X86::BI__builtin_ia32_undef256: case X86::BI__builtin_ia32_undef512: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51802: [clangd] Make advanceTo() faster on Posting Lists
kbobyrev updated this revision to Diff 164462. kbobyrev edited the summary of this revision. https://reviews.llvm.org/D51802 Files: clang-tools-extra/clangd/index/dex/Iterator.cpp Index: clang-tools-extra/clangd/index/dex/Iterator.cpp === --- clang-tools-extra/clangd/index/dex/Iterator.cpp +++ clang-tools-extra/clangd/index/dex/Iterator.cpp @@ -38,6 +38,8 @@ /// or higher than the given one. void advanceTo(DocID ID) override { assert(!reachedEnd() && "DOCUMENT iterator can't advance() at the end."); +if (peek() >= ID) + return; Index = std::lower_bound(Index, std::end(Documents), ID); } Index: clang-tools-extra/clangd/index/dex/Iterator.cpp === --- clang-tools-extra/clangd/index/dex/Iterator.cpp +++ clang-tools-extra/clangd/index/dex/Iterator.cpp @@ -38,6 +38,8 @@ /// or higher than the given one. void advanceTo(DocID ID) override { assert(!reachedEnd() && "DOCUMENT iterator can't advance() at the end."); +if (peek() >= ID) + return; Index = std::lower_bound(Index, std::end(Documents), ID); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51802: [clangd] Make advanceTo() faster on Posting Lists
kbobyrev created this revision. kbobyrev added reviewers: ioeric, sammccall, ilya-biryukov. kbobyrev added a project: clang-tools-extra. Herald added subscribers: kadircet, arphaman, jkorous, MaskRay. If the current element is already beyond advanceTo()'s DocID, just return instead of doing binary search. This simple optimization saves up to 3-4% performance, https://reviews.llvm.org/D51802 Files: clang-tools-extra/clangd/index/dex/Iterator.cpp Index: clang-tools-extra/clangd/index/dex/Iterator.cpp === --- clang-tools-extra/clangd/index/dex/Iterator.cpp +++ clang-tools-extra/clangd/index/dex/Iterator.cpp @@ -38,6 +38,8 @@ /// or higher than the given one. void advanceTo(DocID ID) override { assert(!reachedEnd() && "DOCUMENT iterator can't advance() at the end."); +if (peek() == ID) + return; Index = std::lower_bound(Index, std::end(Documents), ID); } Index: clang-tools-extra/clangd/index/dex/Iterator.cpp === --- clang-tools-extra/clangd/index/dex/Iterator.cpp +++ clang-tools-extra/clangd/index/dex/Iterator.cpp @@ -38,6 +38,8 @@ /// or higher than the given one. void advanceTo(DocID ID) override { assert(!reachedEnd() && "DOCUMENT iterator can't advance() at the end."); +if (peek() == ID) + return; Index = std::lower_bound(Index, std::end(Documents), ID); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51771: [X86] Modify addcarry/subborrow builtins to emit an 2 result and intrinsic and an store instruction.
This revision was automatically updated to reflect the committed changes. Closed by commit rC341678: [X86] Modify addcarry/subborrow builtins to emit an 2 result and intrinsic and… (authored by ctopper, committed by ). Changed prior to commit: https://reviews.llvm.org/D51771?vs=164357=164452#toc Repository: rC Clang https://reviews.llvm.org/D51771 Files: lib/CodeGen/CGBuiltin.cpp test/CodeGen/adc-builtins.c test/CodeGen/adx-builtins.c Index: test/CodeGen/adx-builtins.c === --- test/CodeGen/adx-builtins.c +++ test/CodeGen/adx-builtins.c @@ -5,14 +5,20 @@ unsigned char test_addcarryx_u32(unsigned char __cf, unsigned int __x, unsigned int __y, unsigned int *__p) { // CHECK-LABEL: test_addcarryx_u32 -// CHECK: call i8 @llvm.x86.addcarryx.u32 +// CHECK: [[ADC:%.*]] = call { i8, i32 } @llvm.x86.addcarryx.u32 +// CHECK: [[DATA:%.*]] = extractvalue { i8, i32 } [[ADC]], 1 +// CHECK: store i32 [[DATA]], i32* %{{.*}} +// CHECK: [[CF:%.*]] = extractvalue { i8, i32 } [[ADC]], 0 return _addcarryx_u32(__cf, __x, __y, __p); } unsigned char test_addcarryx_u64(unsigned char __cf, unsigned long long __x, unsigned long long __y, unsigned long long *__p) { // CHECK-LABEL: test_addcarryx_u64 -// CHECK: call i8 @llvm.x86.addcarryx.u64 +// CHECK: [[ADC:%.*]] = call { i8, i64 } @llvm.x86.addcarryx.u64 +// CHECK: [[DATA:%.*]] = extractvalue { i8, i64 } [[ADC]], 1 +// CHECK: store i64 [[DATA]], i64* %{{.*}} +// CHECK: [[CF:%.*]] = extractvalue { i8, i64 } [[ADC]], 0 return _addcarryx_u64(__cf, __x, __y, __p); } Index: test/CodeGen/adc-builtins.c === --- test/CodeGen/adc-builtins.c +++ test/CodeGen/adc-builtins.c @@ -5,29 +5,41 @@ unsigned char test_addcarry_u32(unsigned char __cf, unsigned int __x, unsigned int __y, unsigned int *__p) { // CHECK-LABEL: test_addcarry_u32 -// CHECK: call i8 @llvm.x86.addcarry.u32 +// CHECK: [[ADC:%.*]] = call { i8, i32 } @llvm.x86.addcarry.u32 +// CHECK: [[DATA:%.*]] = extractvalue { i8, i32 } [[ADC]], 1 +// CHECK: store i32 [[DATA]], i32* %{{.*}} +// CHECK: [[CF:%.*]] = extractvalue { i8, i32 } [[ADC]], 0 return _addcarry_u32(__cf, __x, __y, __p); } unsigned char test_addcarry_u64(unsigned char __cf, unsigned long long __x, unsigned long long __y, unsigned long long *__p) { // CHECK-LABEL: test_addcarry_u64 -// CHECK: call i8 @llvm.x86.addcarry.u64 +// CHECK: [[ADC:%.*]] = call { i8, i64 } @llvm.x86.addcarry.u64 +// CHECK: [[DATA:%.*]] = extractvalue { i8, i64 } [[ADC]], 1 +// CHECK: store i64 [[DATA]], i64* %{{.*}} +// CHECK: [[CF:%.*]] = extractvalue { i8, i64 } [[ADC]], 0 return _addcarry_u64(__cf, __x, __y, __p); } unsigned char test_subborrow_u32(unsigned char __cf, unsigned int __x, unsigned int __y, unsigned int *__p) { // CHECK-LABEL: test_subborrow_u32 -// CHECK: call i8 @llvm.x86.subborrow.u32 +// CHECK: [[SBB:%.*]] = call { i8, i32 } @llvm.x86.subborrow.u32 +// CHECK: [[DATA:%.*]] = extractvalue { i8, i32 } [[SBB]], 1 +// CHECK: store i32 [[DATA]], i32* %{{.*}} +// CHECK: [[CF:%.*]] = extractvalue { i8, i32 } [[SBB]], 0 return _subborrow_u32(__cf, __x, __y, __p); } unsigned char test_subborrow_u64(unsigned char __cf, unsigned long long __x, unsigned long long __y, unsigned long long *__p) { // CHECK-LABEL: test_subborrow_u64 -// CHECK: call i8 @llvm.x86.subborrow.u64 +// CHECK: [[SBB:%.*]] = call { i8, i64 } @llvm.x86.subborrow.u64 +// CHECK: [[DATA:%.*]] = extractvalue { i8, i64 } [[SBB]], 1 +// CHECK: store i64 [[DATA]], i64* %{{.*}} +// CHECK: [[CF:%.*]] = extractvalue { i8, i64 } [[SBB]], 0 return _subborrow_u64(__cf, __x, __y, __p); } Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -10405,6 +10405,41 @@ Ops[0]); return Builder.CreateExtractValue(Call, 1); } + case X86::BI__builtin_ia32_addcarryx_u32: + case X86::BI__builtin_ia32_addcarryx_u64: + case X86::BI__builtin_ia32_addcarry_u32: + case X86::BI__builtin_ia32_addcarry_u64: + case X86::BI__builtin_ia32_subborrow_u32: + case X86::BI__builtin_ia32_subborrow_u64: { +Intrinsic::ID IID; +switch (BuiltinID) { +default: llvm_unreachable("Unsupported intrinsic!"); +case X86::BI__builtin_ia32_addcarryx_u32: + IID = Intrinsic::x86_addcarryx_u32; + break; +case X86::BI__builtin_ia32_addcarryx_u64: + IID = Intrinsic::x86_addcarryx_u64; + break; +case X86::BI__builtin_ia32_addcarry_u32: + IID = Intrinsic::x86_addcarry_u32; + break; +case
r341678 - [X86] Modify addcarry/subborrow builtins to emit an 2 result and intrinsic and an store instruction.
Author: ctopper Date: Fri Sep 7 09:58:57 2018 New Revision: 341678 URL: http://llvm.org/viewvc/llvm-project?rev=341678=rev Log: [X86] Modify addcarry/subborrow builtins to emit an 2 result and intrinsic and an store instruction. This is the clang side of D51769. The llvm intrinsics now return two results instead of using an out parameter. Differential Revision: https://reviews.llvm.org/D51771 Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/adc-builtins.c cfe/trunk/test/CodeGen/adx-builtins.c Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=341678=341677=341678=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Sep 7 09:58:57 2018 @@ -10405,6 +10405,41 @@ Value *CodeGenFunction::EmitX86BuiltinEx Ops[0]); return Builder.CreateExtractValue(Call, 1); } + case X86::BI__builtin_ia32_addcarryx_u32: + case X86::BI__builtin_ia32_addcarryx_u64: + case X86::BI__builtin_ia32_addcarry_u32: + case X86::BI__builtin_ia32_addcarry_u64: + case X86::BI__builtin_ia32_subborrow_u32: + case X86::BI__builtin_ia32_subborrow_u64: { +Intrinsic::ID IID; +switch (BuiltinID) { +default: llvm_unreachable("Unsupported intrinsic!"); +case X86::BI__builtin_ia32_addcarryx_u32: + IID = Intrinsic::x86_addcarryx_u32; + break; +case X86::BI__builtin_ia32_addcarryx_u64: + IID = Intrinsic::x86_addcarryx_u64; + break; +case X86::BI__builtin_ia32_addcarry_u32: + IID = Intrinsic::x86_addcarry_u32; + break; +case X86::BI__builtin_ia32_addcarry_u64: + IID = Intrinsic::x86_addcarry_u64; + break; +case X86::BI__builtin_ia32_subborrow_u32: + IID = Intrinsic::x86_subborrow_u32; + break; +case X86::BI__builtin_ia32_subborrow_u64: + IID = Intrinsic::x86_subborrow_u64; + break; +} + +Value *Call = Builder.CreateCall(CGM.getIntrinsic(IID), + { Ops[0], Ops[1], Ops[2] }); +Builder.CreateDefaultAlignedStore(Builder.CreateExtractValue(Call, 1), + Ops[3]); +return Builder.CreateExtractValue(Call, 0); + } case X86::BI__builtin_ia32_fpclassps128_mask: case X86::BI__builtin_ia32_fpclassps256_mask: Modified: cfe/trunk/test/CodeGen/adc-builtins.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/adc-builtins.c?rev=341678=341677=341678=diff == --- cfe/trunk/test/CodeGen/adc-builtins.c (original) +++ cfe/trunk/test/CodeGen/adc-builtins.c Fri Sep 7 09:58:57 2018 @@ -5,7 +5,10 @@ unsigned char test_addcarry_u32(unsigned char __cf, unsigned int __x, unsigned int __y, unsigned int *__p) { // CHECK-LABEL: test_addcarry_u32 -// CHECK: call i8 @llvm.x86.addcarry.u32 +// CHECK: [[ADC:%.*]] = call { i8, i32 } @llvm.x86.addcarry.u32 +// CHECK: [[DATA:%.*]] = extractvalue { i8, i32 } [[ADC]], 1 +// CHECK: store i32 [[DATA]], i32* %{{.*}} +// CHECK: [[CF:%.*]] = extractvalue { i8, i32 } [[ADC]], 0 return _addcarry_u32(__cf, __x, __y, __p); } @@ -13,14 +16,20 @@ unsigned char test_addcarry_u64(unsigned unsigned long long __y, unsigned long long *__p) { // CHECK-LABEL: test_addcarry_u64 -// CHECK: call i8 @llvm.x86.addcarry.u64 +// CHECK: [[ADC:%.*]] = call { i8, i64 } @llvm.x86.addcarry.u64 +// CHECK: [[DATA:%.*]] = extractvalue { i8, i64 } [[ADC]], 1 +// CHECK: store i64 [[DATA]], i64* %{{.*}} +// CHECK: [[CF:%.*]] = extractvalue { i8, i64 } [[ADC]], 0 return _addcarry_u64(__cf, __x, __y, __p); } unsigned char test_subborrow_u32(unsigned char __cf, unsigned int __x, unsigned int __y, unsigned int *__p) { // CHECK-LABEL: test_subborrow_u32 -// CHECK: call i8 @llvm.x86.subborrow.u32 +// CHECK: [[SBB:%.*]] = call { i8, i32 } @llvm.x86.subborrow.u32 +// CHECK: [[DATA:%.*]] = extractvalue { i8, i32 } [[SBB]], 1 +// CHECK: store i32 [[DATA]], i32* %{{.*}} +// CHECK: [[CF:%.*]] = extractvalue { i8, i32 } [[SBB]], 0 return _subborrow_u32(__cf, __x, __y, __p); } @@ -28,6 +37,9 @@ unsigned char test_subborrow_u64(unsigne unsigned long long __y, unsigned long long *__p) { // CHECK-LABEL: test_subborrow_u64 -// CHECK: call i8 @llvm.x86.subborrow.u64 +// CHECK: [[SBB:%.*]] = call { i8, i64 } @llvm.x86.subborrow.u64 +// CHECK: [[DATA:%.*]] = extractvalue { i8, i64 } [[SBB]], 1 +// CHECK: store i64 [[DATA]], i64* %{{.*}} +// CHECK: [[CF:%.*]] = extractvalue { i8, i64 } [[SBB]], 0 return _subborrow_u64(__cf, __x, __y, __p); } Modified: cfe/trunk/test/CodeGen/adx-builtins.c URL:
[PATCH] D50101: [asan] Update a vector's storage annotation during destruction.
mclow.lists closed this revision. mclow.lists added a comment. landed as revision 341671. Repository: rCXX libc++ https://reviews.llvm.org/D50101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r341671 - [asan] Update a vector's storage annotation during destruction. Reviewed as https://reviews.llvm.org/D50101. Thanks to bobsayshilol (Ben) for the patch.
Author: marshall Date: Fri Sep 7 08:47:59 2018 New Revision: 341671 URL: http://llvm.org/viewvc/llvm-project?rev=341671=rev Log: [asan] Update a vector's storage annotation during destruction. Reviewed as https://reviews.llvm.org/D50101. Thanks to bobsayshilol (Ben) for the patch. Modified: libcxx/trunk/include/vector Modified: libcxx/trunk/include/vector URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=341671=341670=341671=diff == --- libcxx/trunk/include/vector (original) +++ libcxx/trunk/include/vector Fri Sep 7 08:47:59 2018 @@ -540,13 +540,14 @@ public: value_type, typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0); -#if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY ~vector() { +__annotate_delete(); +#if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__erase_c(this); -} #endif +} vector(const vector& __x); vector(const vector& __x, const allocator_type& __a); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51789: [WIP][clang] Add the no_extern_template attribute
dexonsmith edited subscribers, added: cfe-commits; removed: llvm-commits. dexonsmith added a comment. +cfe-commits -llvm-commits Repository: rL LLVM https://reviews.llvm.org/D51789 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51531: [analyzer][UninitializedObjectChecker] Uninit regions are only reported once
Szelethus added a comment. Polite ping :) https://reviews.llvm.org/D51531 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51544: [OpenCL] Split opencl-c.h header
asavonic added a comment. In https://reviews.llvm.org/D51544#1227313, @Anastasia wrote: > Currently the main header still contains everything, so the size of the PCH > won't change. The idea is that we don't pre-compile the whole opencl-c.h, we split it into several headers (3 of them are target independent) and pre-compile them instead. With this approach, we can reuse target-independent PCHs (common, fp16, fp64) and only duplicate target-specific PCHs if needed (opencl-c-platform.h). The idea is basically: 1. Compile target-independent headers into modules: - opencl-c-common.h -> opencl-c-common.pcm - opencl-c-fp16.h -> opencl-c-fp16.pcm - opencl-c-fp64.h -> opencl-c-fp64.pcm 2. Implicitly include opencl-c.h (plain header), which has the following content: #include "opencl-c-common.h" #if cl_khr_fp16 #include "opencl-c-fp16.h" #endif #if cl_khr_fp64 #include "opencl-c-fp16.h" #endif #include "opencl-c-platform.h" When compiler reaches an #include statement in opencl-c.h, it loads a corresponding PCH. Headers that were not pre-compiled are included as usual. Repository: rC Clang https://reviews.llvm.org/D51544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r341668 - Revert "[OPENMP][NVPTX] Disable runtime-type info for CUDA devices."
Author: abataev Date: Fri Sep 7 07:50:25 2018 New Revision: 341668 URL: http://llvm.org/viewvc/llvm-project?rev=341668=rev Log: Revert "[OPENMP][NVPTX] Disable runtime-type info for CUDA devices." Still need the RTTI for NVPTX target to pass sema checks. Removed: cfe/trunk/test/OpenMP/nvptx_target_rtti_messages.cpp Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=341668=341667=341668=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Sep 7 07:50:25 2018 @@ -2648,11 +2648,6 @@ static void ParseLangArgs(LangOptions Opts.Exceptions = 0; Opts.CXXExceptions = 0; } - // NVPTX does not support RTTI. - if (Opts.OpenMPIsDevice && T.isNVPTX()) { -Opts.RTTI = 0; -Opts.RTTIData = 0; - } // Get the OpenMP target triples if any. if (Arg *A = Args.getLastArg(options::OPT_fopenmp_targets_EQ)) { Removed: cfe/trunk/test/OpenMP/nvptx_target_rtti_messages.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_target_rtti_messages.cpp?rev=341667=auto == --- cfe/trunk/test/OpenMP/nvptx_target_rtti_messages.cpp (original) +++ cfe/trunk/test/OpenMP/nvptx_target_rtti_messages.cpp (removed) @@ -1,68 +0,0 @@ -// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -fexceptions -fcxx-exceptions -// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -ferror-limit 100 - -#ifndef HEADER -#define HEADER - -namespace std { - class type_info; -} - -template -class TemplateClass { - T a; -public: - TemplateClass() { (void)typeid(int); } // expected-error {{use of typeid requires -frtti}} - T f_method() const { return a; } -}; - -int foo(); - -int baz1(); - -int baz2(); - -int baz4() { return 5; } - -template -T FA() { - TemplateClass s; - return s.f_method(); -} - -#pragma omp declare target -struct S { - int a; - S(int a) : a(a) { (void)typeid(int); } // expected-error {{use of typeid requires -frtti}} -}; - -int foo() { return 0; } -int b = 15; -int d; -#pragma omp end declare target -int c; - -int bar() { return 1 + foo() + bar() + baz1() + baz2(); } - -int maini1() { - int a; - static long aa = 32; -#pragma omp target map(tofrom \ - : a, b) - { -S s(a); -static long aaa = 23; -a = foo() + bar() + b + c + d + aa + aaa + FA(); -(void)typeid(int); // expected-error {{use of typeid requires -frtti}} - } - return baz4(); -} - -int baz3() { return 2 + baz2(); } -int baz2() { -#pragma omp target - (void)typeid(int); // expected-error {{use of typeid requires -frtti}} - return 2 + baz3(); -} - -#endif // HEADER ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51628: [clangd] Implement a Proof-of-Concept tool for symbol index exploration
ilya-biryukov added a comment. Definitely like the idea of the tool. The main complication seems to be parsing of user input at this point. I suggest we explore an option proposed before, that is reusing the LLVM command-line parser (see inline comment too). If that turns out to be much work, we could explore rolling out a simple parser for commands on our own. Comment at: clang-tools-extra/clangd/dexplorer/Dexplorer.cpp:39 + +// FIXME(kbobyrev): Make this an actual REPL: probably use LLVM Command Line +// library for parsing flags and arguments. Maybe we could expose `CommandLineParser` from `llvm/lib/Support/CommandLine.cpp` as a public API and use it here? Not sure if there are any obstacles to doing so or how much work is it, though. E.g. `cl::opt` seem to rely on being registered in the global parser and I'm not sure if there's an easy way out of it. Comment at: clang-tools-extra/clangd/dexplorer/Dexplorer.cpp:147 + + // FIXME(kbobyrev): Wrap time measurements into something like + // measureTime(Function, Arguments...). +1 to this FIXME. Something like: ``` template auto reportTime(StringRef Name, Func F) -> decltype(F()) { auto Result = F(); llvm::outs() << Name << " took " << ... return Result; } ``` The code calling this API would be quite readable: ``` auto Index = reportTime("Build stage", []() { return buildStaticIndex(...); }); ``` https://reviews.llvm.org/D51628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51544: [OpenCL] Split opencl-c.h header
Anastasia added a comment. In https://reviews.llvm.org/D51544#1224780, @asavonic wrote: > In https://reviews.llvm.org/D51544#1224730, @Anastasia wrote: > > > It seems generally good to partition this big header but I am trying to > > understand what problem is it trying to solve now? > > > Main motivation is to reduce memory footprint by factoring out everything > that is 'common' between PCHs compiled for different targets (CL1.2/2.0 and > spir/spir64). > > > So if we want to add these 2 devices, we now need 4*2 different PCHs, > > since every combination of -cl-std and -triple must be compiled twice > > with different OpenCL extensions defines. > > > > Size of each PCH is 2.5M, so we need ~20M of memory to store our > > PCHs. If we want to add more devices or support another OpenCL C > > version, the size will double. > > This also allows to do 'partial' pre-compilation, where 'common' part is > pre-compiled into a single target independent PCH, and plain header is used > for all target-specific things. > In this case, you no longer need to maintain different target-specific PCHs > and this greatly simplifies the whole process. > > > opencl-c-platform.h (5K LOC) must still be pre-compiled for each > > supported combination, but since it is a lot smaller (~0.5M vs > > original 2.5M), it is not that bad. Or we can sacrifice some > > performance and leave this header without pre-compilation: large > > portion of opencl-c-platform.h contains vendor extensions, so it will > > be removed by preprocessor anyway. Currently the main header still contains everything, so the size of the PCH won't change. So I was wondering what would be the way to avoid this... other than adding explicit `#include`. Repository: rC Clang https://reviews.llvm.org/D51544 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51771: [X86] Modify addcarry/subborrow builtins to emit an 2 result and intrinsic and an store instruction.
RKSimon accepted this revision. RKSimon added a comment. This revision is now accepted and ready to land. LGTM Repository: rC Clang https://reviews.llvm.org/D51771 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.
ilya-biryukov added inline comments. Comment at: test/Index/complete-block-property-assignment.m:71 +// RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck -check-prefix=CHECK-NO1 %s +// CHECK-NO1: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35) ilya-biryukov wrote: > ilya-biryukov wrote: > > kadircet wrote: > > > ilya-biryukov wrote: > > > > ilya-biryukov wrote: > > > > > Any idea why behavior changed in that case? > > > > Looked at it more thoroughly now... > > > > So we're now showing both the signature help and the completion, right? > > > > If that the case, LG, but can we include the rest of completion items > > > > from CHECK-N0? > > > > > > > > Maybe also add a comment that the last item is from overload set > > > > completion, rather than the ordinary code completion? (To avoid > > > > confusion and make it clear why we need an extra check there) > > > Yes, c-index-test binary collects results from both > > > ProcessOverloadCandidate and ProcessCodeCompleteResults. Therefore they > > > are merged. Adding the same set of results on the above is not enough for > > > that particular case, due to the clever nature of > > > CodeCompleteOverloadResult at > > > https://github.com/llvm-mirror/clang/blob/master/lib/Sema/SemaCodeComplete.cpp#L4439. > > > > > > It doesn't just try to tell you the overloads of that particular function > > > but also tries to complete the current argument. Therefore the list > > > simply gets huge by expansion of all the macros and other stuff. > > > > > > But when looking into it I found out I was checking for wrong return > > > values fixing that with the new diff. > > I don't think it's correct to call CodeCompleteExpression and > > CodeCompleteOrdinaryName in this context. > > This completion assume we're at the start of the argument, which is not > > true anymore. > > E.g. we can be producing weird results in the middle of expressions. Some > > examples from the top of my head: > > ``` > > func(var.^); // <-- (1) we add top-level completions in addition to members > > of bar > > func(&^); // <-- (2) we provide incorrect ParamType > > ``` > > For (2) if ParamType is `int*`, we would incorrectly uprank items of type > > `int*` (should uprank items of type `int` instead). > > > > I'll investigate a bit more to see if we can refactor the code to untangle > > signature help from code completion. > D51782 removes completion-specific bits out of functions that produce > signature help. > After it lands, it should be significantly easier to produce results for > these cases. > > Specifically, we will be able to only run signature help in the middle of the > args, and signature help followed by a normal completion at the start of the > args. Landed D51782. This change should be easier now. We can now call both signature help and code completion at the start of the arguments and only signature help in the middle of the arguments. Repository: rC Clang https://reviews.llvm.org/D51038 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51782: [CodeComplete] Clearly distinguish signature help and code completion.
This revision was automatically updated to reflect the committed changes. Closed by commit rC341660: [CodeComplete] Clearly distinguish signature help and code completion. (authored by ibiryukov, committed by ). Changed prior to commit: https://reviews.llvm.org/D51782?vs=164398=164415#toc Repository: rC Clang https://reviews.llvm.org/D51782 Files: include/clang/Sema/Sema.h lib/Parse/ParseDecl.cpp lib/Parse/ParseExpr.cpp lib/Parse/ParseExprCXX.cpp lib/Parse/ParseOpenMP.cpp lib/Sema/SemaCodeComplete.cpp test/CodeCompletion/call.cpp Index: include/clang/Sema/Sema.h === --- include/clang/Sema/Sema.h +++ include/clang/Sema/Sema.h @@ -10231,6 +10231,7 @@ struct CodeCompleteExpressionData; void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData ); + void CodeCompleteExpression(Scope *S, QualType PreferredType); void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase, SourceLocation OpLoc, bool IsArrow, bool IsBaseExprStatement); @@ -10241,11 +10242,14 @@ const VirtSpecifiers *VS = nullptr); void CodeCompleteBracketDeclarator(Scope *S); void CodeCompleteCase(Scope *S); - void CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef Args, -SourceLocation OpenParLoc); - void CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc, - ArrayRef Args, - SourceLocation OpenParLoc); + /// Reports signatures for a call to CodeCompleteConsumer and returns the + /// preferred type for the current argument. Returned type can be null. + QualType ProduceCallSignatureHelp(Scope *S, Expr *Fn, ArrayRef Args, +SourceLocation OpenParLoc); + QualType ProduceConstructorSignatureHelp(Scope *S, QualType Type, + SourceLocation Loc, + ArrayRef Args, + SourceLocation OpenParLoc); void CodeCompleteInitializer(Scope *S, Decl *D); void CodeCompleteReturn(Scope *S); void CodeCompleteAfterIf(Scope *S); Index: test/CodeCompletion/call.cpp === --- test/CodeCompletion/call.cpp +++ test/CodeCompletion/call.cpp @@ -18,10 +18,10 @@ void test() { f(Y(), 0, 0); // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s - // CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>) // CHECK-CC1: f(Y y, <#int ZZ#>) // CHECK-CC1-NEXT: f(int i, <#int j#>, int k) // CHECK-CC1-NEXT: f(float x, <#float y#>) + // CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>) // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s // CHECK-CC2-NOT: f(Y y, int ZZ) // CHECK-CC2: f(int i, int j, <#int k#>) Index: lib/Parse/ParseExpr.cpp === --- lib/Parse/ParseExpr.cpp +++ lib/Parse/ParseExpr.cpp @@ -1650,17 +1650,19 @@ CommaLocsTy CommaLocs; if (Tok.is(tok::code_completion)) { -Actions.CodeCompleteCall(getCurScope(), LHS.get(), None, - PT.getOpenLocation()); +QualType PreferredType = Actions.ProduceCallSignatureHelp( +getCurScope(), LHS.get(), None, PT.getOpenLocation()); +Actions.CodeCompleteExpression(getCurScope(), PreferredType); cutOffParsing(); return ExprError(); } if (OpKind == tok::l_paren || !LHS.isInvalid()) { if (Tok.isNot(tok::r_paren)) { if (ParseExpressionList(ArgExprs, CommaLocs, [&] { -Actions.CodeCompleteCall(getCurScope(), LHS.get(), ArgExprs, - PT.getOpenLocation()); +QualType PreferredType = Actions.ProduceCallSignatureHelp( +getCurScope(), LHS.get(), ArgExprs, PT.getOpenLocation()); +Actions.CodeCompleteExpression(getCurScope(), PreferredType); })) { (void)Actions.CorrectDelayedTyposInExpr(LHS); LHS = ExprError(); Index: lib/Parse/ParseDecl.cpp === --- lib/Parse/ParseDecl.cpp +++ lib/Parse/ParseDecl.cpp @@ -2302,16 +2302,17 @@ llvm::function_ref ExprListCompleter; auto ThisVarDecl = dyn_cast_or_null(ThisDecl); auto ConstructorCompleter = [&, ThisVarDecl] { - Actions.CodeCompleteConstructor( + QualType PreferredType = Actions.ProduceConstructorSignatureHelp( getCurScope(),
r341660 - [CodeComplete] Clearly distinguish signature help and code completion.
Author: ibiryukov Date: Fri Sep 7 07:04:39 2018 New Revision: 341660 URL: http://llvm.org/viewvc/llvm-project?rev=341660=rev Log: [CodeComplete] Clearly distinguish signature help and code completion. Summary: Code completion in clang is actually a mix of two features: - Code completion is a familiar feature. Results are exposed via the CodeCompleteConsumer::ProcessCodeCompleteResults callback. - Signature help figures out if the current expression is an argument of some function call and shows corresponding signatures if so. Results are exposed via CodeCompleteConsumer::ProcessOverloadCandidates. This patch refactors the implementation to untangle those two from each other and makes some naming tweaks to avoid confusion when reading the code. The refactoring is required for signature help fixes, see D51038. The only intended behavior change is the order of callbacks. ProcessOverloadCandidates is now called before ProcessCodeCompleteResults. Reviewers: sammccall, kadircet Reviewed By: sammccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51782 Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Parse/ParseExpr.cpp cfe/trunk/lib/Parse/ParseExprCXX.cpp cfe/trunk/lib/Parse/ParseOpenMP.cpp cfe/trunk/lib/Sema/SemaCodeComplete.cpp cfe/trunk/test/CodeCompletion/call.cpp Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=341660=341659=341660=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Fri Sep 7 07:04:39 2018 @@ -10231,6 +10231,7 @@ public: struct CodeCompleteExpressionData; void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData ); + void CodeCompleteExpression(Scope *S, QualType PreferredType); void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase, SourceLocation OpLoc, bool IsArrow, bool IsBaseExprStatement); @@ -10241,11 +10242,14 @@ public: const VirtSpecifiers *VS = nullptr); void CodeCompleteBracketDeclarator(Scope *S); void CodeCompleteCase(Scope *S); - void CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef Args, -SourceLocation OpenParLoc); - void CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc, - ArrayRef Args, - SourceLocation OpenParLoc); + /// Reports signatures for a call to CodeCompleteConsumer and returns the + /// preferred type for the current argument. Returned type can be null. + QualType ProduceCallSignatureHelp(Scope *S, Expr *Fn, ArrayRef Args, +SourceLocation OpenParLoc); + QualType ProduceConstructorSignatureHelp(Scope *S, QualType Type, + SourceLocation Loc, + ArrayRef Args, + SourceLocation OpenParLoc); void CodeCompleteInitializer(Scope *S, Decl *D); void CodeCompleteReturn(Scope *S); void CodeCompleteAfterIf(Scope *S); Modified: cfe/trunk/lib/Parse/ParseDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=341660=341659=341660=diff == --- cfe/trunk/lib/Parse/ParseDecl.cpp (original) +++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri Sep 7 07:04:39 2018 @@ -2302,16 +2302,17 @@ Decl *Parser::ParseDeclarationAfterDecla llvm::function_ref ExprListCompleter; auto ThisVarDecl = dyn_cast_or_null(ThisDecl); auto ConstructorCompleter = [&, ThisVarDecl] { - Actions.CodeCompleteConstructor( + QualType PreferredType = Actions.ProduceConstructorSignatureHelp( getCurScope(), ThisVarDecl->getType()->getCanonicalTypeInternal(), ThisDecl->getLocation(), Exprs, T.getOpenLocation()); + Actions.CodeCompleteExpression(getCurScope(), PreferredType); }; if (ThisVarDecl) { // ParseExpressionList can sometimes succeed even when ThisDecl is not // VarDecl. This is an error and it is reported in a call to // Actions.ActOnInitializerError(). However, we call - // CodeCompleteConstructor only on VarDecls, falling back to default - // completer in other cases. + // ProduceConstructorSignatureHelp only on VarDecls, falling back to + // default completer in other cases. ExprListCompleter = ConstructorCompleter; } Modified: cfe/trunk/lib/Parse/ParseExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=341660=341659=341660=diff
[PATCH] D51090: [clangd] Add index benchmarks
kbobyrev updated this revision to Diff 164414. kbobyrev added a comment. Sync with HEAD https://reviews.llvm.org/D51090 Files: clang-tools-extra/clangd/CMakeLists.txt clang-tools-extra/clangd/benchmarks/CMakeLists.txt clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp Index: clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp === --- /dev/null +++ clang-tools-extra/clangd/benchmarks/IndexBenchmark.cpp @@ -0,0 +1,173 @@ +//===--- DexBenchmark.cpp - DexIndex benchmarks -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "../index/SymbolYAML.h" +#include "../index/dex/DexIndex.h" +#include "benchmark/benchmark.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/Regex.h" +#include +#include +#include + +std::string IndexFilename; +std::string LogFilename; +std::string LLVMRootPath; + +std::unique_ptr buildMem() { + return clang::clangd::loadIndex(IndexFilename, {}, false); +} + +std::unique_ptr buildDex() { + return clang::clangd::loadIndex(IndexFilename, {}, true); +} + +std::vector extractQueriesFromLogs() { + llvm::Regex RequestMatcher("fuzzyFind\\(\"([a-zA-Z]*)\", scopes=\\[(.*)\\]"); + llvm::SmallVector Matches; + std::ifstream InputStream(LogFilename); + std::string Log((std::istreambuf_iterator(InputStream)), + std::istreambuf_iterator()); + llvm::StringRef Temporary(Log); + llvm::SmallVector Strings; + Temporary.split(Strings, '\n'); + + clang::clangd::FuzzyFindRequest R; + R.MaxCandidateCount = 100; + + llvm::SmallVector CommaSeparatedValues; + + std::vector RealRequests; + for (auto Line : Strings) { +if (RequestMatcher.match(Line, )) { + R.Query = Matches[1]; + CommaSeparatedValues.clear(); + Line.split(CommaSeparatedValues, ','); + R.Scopes.clear(); + for (auto C : CommaSeparatedValues) { +R.Scopes.push_back(C); + } + RealRequests.push_back(R); +} + } + return RealRequests; +} + +std::vector generateArtificialRequests() { + std::vector Requests; + // FXIME(kbobyrev): Add more requests. + clang::clangd::FuzzyFindRequest Request; + Request.MaxCandidateCount = 100; + Requests.push_back(Request); + Request.Scopes = {"::"}; + Requests.push_back(Request); + Request.Scopes = {"::", "llvm::", "clang::", "clangd::"}; + Requests.push_back(Request); + Request.Scopes = {"::", "clang::", "llvm::", "std::"}; + Request.Query = "TUDec"; + Requests.push_back(Request); + Request.Query = "non-existent symbol"; + Requests.push_back(Request); + + llvm::SmallVector Path(begin(LLVMRootPath), end(LLVMRootPath)); + Request.ProximityPaths.push_back(std::string(Path.begin(), Path.end())); + llvm::sys::path::append(Path, "include"); + Request.ProximityPaths.push_back(std::string(Path.begin(), Path.end())); + llvm::sys::path::append(Path, "llvm"); + Request.ProximityPaths.push_back(std::string(Path.begin(), Path.end())); + llvm::sys::path::append(Path, "Support"); + Request.ProximityPaths.push_back(std::string(Path.begin(), Path.end())); + + Request.Query = "str"; + Request.Scopes = {"::", "llvm::", "llvm::sys::", "std::sys::path::"}; + Requests.push_back(Request); + + Request.Query = "file"; + Requests.push_back(Request); + + Request.Query = "path"; + Requests.push_back(Request); + + return Requests; +} + +namespace clang { +namespace clangd { +namespace dex { + +static void BuildMem(benchmark::State ) { + for (auto _ : State) +buildMem(); +} +BENCHMARK(BuildMem); + +static void MemArtificialQueries(benchmark::State ) { + const auto Mem = buildMem(); + const auto Requests = generateArtificialRequests(); + for (auto _ : State) +for (const auto : Requests) + Mem->fuzzyFind(Request, [](const Symbol ) {}); +} +BENCHMARK(MemArtificialQueries); + +static void MemRealQueries(benchmark::State ) { + const auto Mem = buildMem(); + const auto Requests = extractQueriesFromLogs(); + for (auto _ : State) +for (const auto : Requests) + Mem->fuzzyFind(Request, [](const Symbol ) {}); +} +BENCHMARK(MemRealQueries); + +static void BuildDex(benchmark::State ) { + for (auto _ : State) +buildDex(); +} +BENCHMARK(BuildDex); + +static void DexArtificialQueries(benchmark::State ) { + const auto Dex = buildDex(); + const auto Requests = generateArtificialRequests(); + for (auto _ : State) +for (const auto : Requests) + Dex->fuzzyFind(Request, [](const Symbol ) {}); +} +BENCHMARK(DexArtificialQueries); + +static void DexRealQueries(benchmark::State ) { + const auto Dex = buildDex(); + const auto Requests = extractQueriesFromLogs(); + for (auto _ : State) +for (const auto
[PATCH] D51784: ms: Insert $$Z in mangling between directly consecutive parameter packs.
thakis added inline comments. Comment at: clang/test/CodeGenCXX/mangle-ms-templates.cpp:201 + multi_variadic_mixed(1, 2, 3); + multi_variadic_mixed(1, 2, 3, 4); } These notably don't get a $$Z because there's a regular template parameter in between. https://reviews.llvm.org/D51784 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51784: ms: Insert $$Z in mangling between directly consecutive parameter packs.
thakis created this revision. thakis added a reviewer: rnk. Fixes PR38783. For comparing: https://godbolt.org/z/XBSdiq https://reviews.llvm.org/D51784 Files: clang/lib/AST/MicrosoftMangle.cpp clang/test/CodeGenCXX/mangle-ms-templates.cpp Index: clang/test/CodeGenCXX/mangle-ms-templates.cpp === --- clang/test/CodeGenCXX/mangle-ms-templates.cpp +++ clang/test/CodeGenCXX/mangle-ms-templates.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -fms-extensions -fdelayed-template-parsing -triple=i386-pc-win32 | FileCheck %s -// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -fms-extensions -fdelayed-template-parsing -triple=x86_64-pc-win32 | FileCheck -check-prefix X64 %s +// RUN: %clang_cc1 -std=c++11 -fms-compatibility-version=19 -emit-llvm %s -o - -fms-extensions -fdelayed-template-parsing -triple=i386-pc-win32 | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -fms-compatibility-version=19 -emit-llvm %s -o - -fms-extensions -fdelayed-template-parsing -triple=x86_64-pc-win32 | FileCheck -check-prefix X64 %s template class Class { @@ -185,13 +185,33 @@ // Unlike Itanium, there is no character code to indicate an argument pack. // Tested with MSVC 2013, the first version which supports variadic templates. -template void variadic_fn_template(const Ts &...args) { } +template void variadic_fn_template(const Ts &...args); +template +void multi_variadic_fn(Ts... ts, Us... us); +template +void multi_variadic_mixed(Ts... ts, C c, Us... us); void variadic_fn_instantiate() { variadic_fn_template(0, 1, 3, 4); variadic_fn_template(0, 1, 'a', "b"); + + multi_variadic_fn(1, 2, 3, 4, 5); + multi_variadic_fn(1, 2, 3, 4, 5); + + multi_variadic_mixed(1, 2, 3); + multi_variadic_mixed(1, 2, 3, 4); } // CHECK: "??$variadic_fn_template@@@YAXABH000@Z" +// X64: "??$variadic_fn_template@@@YAXAEBH000@Z" // CHECK: "??$variadic_fn_template@HHD$$BY01D@@YAXABH0ABDAAY01$$CBD@Z" +// X64: "??$variadic_fn_template@HHD$$BY01D@@YAXAEBH0AEBDAEAY01$$CBD@Z" +// CHECK: "??$multi_variadic_fn@HH$$ZHHH@@YAXH@Z" +// X64: "??$multi_variadic_fn@HH$$ZHHH@@YAXH@Z" +// CHECK: "??$multi_variadic_fn@HHH$$ZHH@@YAXH@Z" +// X64: "??$multi_variadic_fn@HHH$$ZHH@@YAXH@Z" +// CHECK: "??$multi_variadic_mixed@HHH$$V@@YAXHHH@Z" +// X64: "??$multi_variadic_mixed@HHH$$V@@YAXHHH@Z" +// CHECK: "??$multi_variadic_mixed@@@YAX@Z" +// X64: "??$multi_variadic_mixed@@@YAX@Z" template struct VariadicClass { Index: clang/lib/AST/MicrosoftMangle.cpp === --- clang/lib/AST/MicrosoftMangle.cpp +++ clang/lib/AST/MicrosoftMangle.cpp @@ -1384,9 +1384,16 @@ assert(TPL->size() == TemplateArgs.size() && "size mismatch between args and parms!"); - unsigned Idx = 0; - for (const TemplateArgument : TemplateArgs.asArray()) -mangleTemplateArg(TD, TA, TPL->getParam(Idx++)); + for (size_t i = 0; i < TemplateArgs.size(); ++i) { +const TemplateArgument = TemplateArgs[i]; + +// Separate consecutive packs by $$Z. +if (i > 0 && TA.getKind() == TemplateArgument::Pack && +TemplateArgs[i - 1].getKind() == TemplateArgument::Pack) + Out << "$$Z"; + +mangleTemplateArg(TD, TA, TPL->getParam(i)); + } } void MicrosoftCXXNameMangler::mangleTemplateArg(const TemplateDecl *TD, Index: clang/test/CodeGenCXX/mangle-ms-templates.cpp === --- clang/test/CodeGenCXX/mangle-ms-templates.cpp +++ clang/test/CodeGenCXX/mangle-ms-templates.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -fms-extensions -fdelayed-template-parsing -triple=i386-pc-win32 | FileCheck %s -// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -fms-extensions -fdelayed-template-parsing -triple=x86_64-pc-win32 | FileCheck -check-prefix X64 %s +// RUN: %clang_cc1 -std=c++11 -fms-compatibility-version=19 -emit-llvm %s -o - -fms-extensions -fdelayed-template-parsing -triple=i386-pc-win32 | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -fms-compatibility-version=19 -emit-llvm %s -o - -fms-extensions -fdelayed-template-parsing -triple=x86_64-pc-win32 | FileCheck -check-prefix X64 %s template class Class { @@ -185,13 +185,33 @@ // Unlike Itanium, there is no character code to indicate an argument pack. // Tested with MSVC 2013, the first version which supports variadic templates. -template void variadic_fn_template(const Ts &...args) { } +template void variadic_fn_template(const Ts &...args); +template +void multi_variadic_fn(Ts... ts, Us... us); +template +void multi_variadic_mixed(Ts... ts, C c, Us... us); void variadic_fn_instantiate() { variadic_fn_template(0, 1, 3, 4); variadic_fn_template(0, 1, 'a', "b"); + + multi_variadic_fn(1, 2, 3, 4, 5); + multi_variadic_fn(1, 2, 3, 4, 5); + + multi_variadic_mixed(1, 2, 3); + multi_variadic_mixed(1, 2, 3, 4); } //
[PATCH] D51281: [libclang] Return the proper pointee type for 'auto' deduced to pointer
This revision was automatically updated to reflect the committed changes. Closed by commit rL341656: [libclang] Return the proper pointee type for auto deduced to pointer (authored by yvvan, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D51281?vs=164151=164399#toc Repository: rL LLVM https://reviews.llvm.org/D51281 Files: cfe/trunk/test/Index/print-type.cpp cfe/trunk/tools/libclang/CXType.cpp Index: cfe/trunk/tools/libclang/CXType.cpp === --- cfe/trunk/tools/libclang/CXType.cpp +++ cfe/trunk/tools/libclang/CXType.cpp @@ -442,6 +442,7 @@ if (!TP) return MakeCXType(QualType(), GetTU(CT)); +try_again: switch (TP->getTypeClass()) { case Type::Pointer: T = cast(TP)->getPointeeType(); @@ -459,6 +460,12 @@ case Type::MemberPointer: T = cast(TP)->getPointeeType(); break; +case Type::Auto: +case Type::DeducedTemplateSpecialization: + TP = cast(TP)->getDeducedType().getTypePtrOrNull(); + if (TP) +goto try_again; + break; default: T = QualType(); break; Index: cfe/trunk/test/Index/print-type.cpp === --- cfe/trunk/test/Index/print-type.cpp +++ cfe/trunk/test/Index/print-type.cpp @@ -75,6 +75,8 @@ template using C = T; using baz = C>; +auto autoTemplPointer = + // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] [isPOD=0] // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] [isPOD=0] @@ -182,3 +184,4 @@ // CHECK: UnexposedExpr=templRefParam:71:40 [type=const Specialization &>] [typekind=Unexposed] const [templateargs/1= [type=Specialization &] [typekind=LValueReference]] [canonicaltype=const Specialization &>] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization &] [typekind=LValueReference]] [isPOD=1] // CHECK: DeclRefExpr=templRefParam:71:40 [type=Specialization &>] [typekind=Unexposed] [templateargs/1= [type=Specialization &] [typekind=LValueReference]] [canonicaltype=Specialization &>] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization &] [typekind=LValueReference]] [isPOD=1] // CHECK: TypeAliasDecl=baz:76:7 (Definition) [type=baz] [typekind=Typedef] [templateargs/1= [type=A] [typekind=Unexposed]] [canonicaltype=A] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=void] [typekind=Void]] [isPOD=0] +// CHECK: VarDecl=autoTemplPointer:78:6 (Definition) [type=Specialization &> *] [typekind=Auto] [canonicaltype=Specialization &> *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=Specialization &>] [pointeekind=Record] Index: cfe/trunk/tools/libclang/CXType.cpp === --- cfe/trunk/tools/libclang/CXType.cpp +++ cfe/trunk/tools/libclang/CXType.cpp @@ -442,6 +442,7 @@ if (!TP) return MakeCXType(QualType(), GetTU(CT)); +try_again: switch (TP->getTypeClass()) { case Type::Pointer: T = cast(TP)->getPointeeType(); @@ -459,6 +460,12 @@ case Type::MemberPointer: T = cast(TP)->getPointeeType(); break; +case Type::Auto: +case Type::DeducedTemplateSpecialization: + TP = cast(TP)->getDeducedType().getTypePtrOrNull(); + if (TP) +goto try_again; + break; default: T = QualType(); break; Index: cfe/trunk/test/Index/print-type.cpp === --- cfe/trunk/test/Index/print-type.cpp +++ cfe/trunk/test/Index/print-type.cpp @@ -75,6 +75,8 @@ template using C = T; using baz = C>; +auto autoTemplPointer = + // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] [isPOD=0] // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] [isPOD=0] @@ -182,3 +184,4 @@ // CHECK: UnexposedExpr=templRefParam:71:40 [type=const Specialization &>] [typekind=Unexposed] const [templateargs/1= [type=Specialization &] [typekind=LValueReference]] [canonicaltype=const Specialization &>] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization &] [typekind=LValueReference]] [isPOD=1] // CHECK: DeclRefExpr=templRefParam:71:40 [type=Specialization &>] [typekind=Unexposed] [templateargs/1= [type=Specialization &] [typekind=LValueReference]] [canonicaltype=Specialization &>] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization &] [typekind=LValueReference]] [isPOD=1] // CHECK: TypeAliasDecl=baz:76:7 (Definition) [type=baz] [typekind=Typedef] [templateargs/1= [type=A] [typekind=Unexposed]] [canonicaltype=A] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=void] [typekind=Void]] [isPOD=0] +// CHECK: VarDecl=autoTemplPointer:78:6
r341656 - [libclang] Return the proper pointee type for 'auto' deduced to pointer
Author: yvvan Date: Fri Sep 7 06:23:51 2018 New Revision: 341656 URL: http://llvm.org/viewvc/llvm-project?rev=341656=rev Log: [libclang] Return the proper pointee type for 'auto' deduced to pointer Currently the resulting type is always invalid in such case. Differential Revision: https://reviews.llvm.org/D51281 Modified: cfe/trunk/test/Index/print-type.cpp cfe/trunk/tools/libclang/CXType.cpp Modified: cfe/trunk/test/Index/print-type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type.cpp?rev=341656=341655=341656=diff == --- cfe/trunk/test/Index/print-type.cpp (original) +++ cfe/trunk/test/Index/print-type.cpp Fri Sep 7 06:23:51 2018 @@ -75,6 +75,8 @@ template struct A {}; template using C = T; using baz = C>; +auto autoTemplPointer = + // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] [isPOD=0] // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] [isPOD=0] @@ -182,3 +184,4 @@ using baz = C>; // CHECK: UnexposedExpr=templRefParam:71:40 [type=const Specialization &>] [typekind=Unexposed] const [templateargs/1= [type=Specialization &] [typekind=LValueReference]] [canonicaltype=const Specialization &>] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization &] [typekind=LValueReference]] [isPOD=1] // CHECK: DeclRefExpr=templRefParam:71:40 [type=Specialization &>] [typekind=Unexposed] [templateargs/1= [type=Specialization &] [typekind=LValueReference]] [canonicaltype=Specialization &>] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization &] [typekind=LValueReference]] [isPOD=1] // CHECK: TypeAliasDecl=baz:76:7 (Definition) [type=baz] [typekind=Typedef] [templateargs/1= [type=A] [typekind=Unexposed]] [canonicaltype=A] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=void] [typekind=Void]] [isPOD=0] +// CHECK: VarDecl=autoTemplPointer:78:6 (Definition) [type=Specialization &> *] [typekind=Auto] [canonicaltype=Specialization &> *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=Specialization &>] [pointeekind=Record] Modified: cfe/trunk/tools/libclang/CXType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=341656=341655=341656=diff == --- cfe/trunk/tools/libclang/CXType.cpp (original) +++ cfe/trunk/tools/libclang/CXType.cpp Fri Sep 7 06:23:51 2018 @@ -442,6 +442,7 @@ CXType clang_getPointeeType(CXType CT) { if (!TP) return MakeCXType(QualType(), GetTU(CT)); +try_again: switch (TP->getTypeClass()) { case Type::Pointer: T = cast(TP)->getPointeeType(); @@ -459,6 +460,12 @@ CXType clang_getPointeeType(CXType CT) { case Type::MemberPointer: T = cast(TP)->getPointeeType(); break; +case Type::Auto: +case Type::DeducedTemplateSpecialization: + TP = cast(TP)->getDeducedType().getTypePtrOrNull(); + if (TP) +goto try_again; + break; default: T = QualType(); break; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.
ilya-biryukov added inline comments. Comment at: test/Index/complete-block-property-assignment.m:71 +// RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck -check-prefix=CHECK-NO1 %s +// CHECK-NO1: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35) ilya-biryukov wrote: > kadircet wrote: > > ilya-biryukov wrote: > > > ilya-biryukov wrote: > > > > Any idea why behavior changed in that case? > > > Looked at it more thoroughly now... > > > So we're now showing both the signature help and the completion, right? > > > If that the case, LG, but can we include the rest of completion items > > > from CHECK-N0? > > > > > > Maybe also add a comment that the last item is from overload set > > > completion, rather than the ordinary code completion? (To avoid confusion > > > and make it clear why we need an extra check there) > > Yes, c-index-test binary collects results from both > > ProcessOverloadCandidate and ProcessCodeCompleteResults. Therefore they are > > merged. Adding the same set of results on the above is not enough for that > > particular case, due to the clever nature of CodeCompleteOverloadResult at > > https://github.com/llvm-mirror/clang/blob/master/lib/Sema/SemaCodeComplete.cpp#L4439. > > > > It doesn't just try to tell you the overloads of that particular function > > but also tries to complete the current argument. Therefore the list simply > > gets huge by expansion of all the macros and other stuff. > > > > But when looking into it I found out I was checking for wrong return values > > fixing that with the new diff. > I don't think it's correct to call CodeCompleteExpression and > CodeCompleteOrdinaryName in this context. > This completion assume we're at the start of the argument, which is not true > anymore. > E.g. we can be producing weird results in the middle of expressions. Some > examples from the top of my head: > ``` > func(var.^); // <-- (1) we add top-level completions in addition to members > of bar > func(&^); // <-- (2) we provide incorrect ParamType > ``` > For (2) if ParamType is `int*`, we would incorrectly uprank items of type > `int*` (should uprank items of type `int` instead). > > I'll investigate a bit more to see if we can refactor the code to untangle > signature help from code completion. D51782 removes completion-specific bits out of functions that produce signature help. After it lands, it should be significantly easier to produce results for these cases. Specifically, we will be able to only run signature help in the middle of the args, and signature help followed by a normal completion at the start of the args. Repository: rC Clang https://reviews.llvm.org/D51038 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51782: [CodeComplete] Clearly distinguish signature help and code completion.
ilya-biryukov created this revision. ilya-biryukov added reviewers: sammccall, kadircet. Code completion in clang is actually a mix of two features: - Code completion is a familiar feature. Results are exposed via the CodeCompleteConsumer::ProcessCodeCompleteResults callback. - Signature help figures out if the current expression is an argument of some function call and shows corresponding signatures if so. Results are exposed via CodeCompleteConsumer::ProcessOverloadCandidates. This patch refactors the implementation to untangle those two from each other and makes some naming tweaks to avoid confusion when reading the code. The refactoring is required for signature help fixes, see https://reviews.llvm.org/D51038. The only intended behavior change is the order of callbacks. ProcessOverloadCandidates is now called before ProcessCodeCompleteResults. Repository: rC Clang https://reviews.llvm.org/D51782 Files: include/clang/Sema/Sema.h lib/Parse/ParseDecl.cpp lib/Parse/ParseExpr.cpp lib/Parse/ParseExprCXX.cpp lib/Parse/ParseOpenMP.cpp lib/Sema/SemaCodeComplete.cpp test/CodeCompletion/call.cpp Index: test/CodeCompletion/call.cpp === --- test/CodeCompletion/call.cpp +++ test/CodeCompletion/call.cpp @@ -18,10 +18,10 @@ void test() { f(Y(), 0, 0); // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s - // CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>) // CHECK-CC1: f(Y y, <#int ZZ#>) // CHECK-CC1-NEXT: f(int i, <#int j#>, int k) // CHECK-CC1-NEXT: f(float x, <#float y#>) + // CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>) // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s // CHECK-CC2-NOT: f(Y y, int ZZ) // CHECK-CC2: f(int i, int j, <#int k#>) Index: lib/Sema/SemaCodeComplete.cpp === --- lib/Sema/SemaCodeComplete.cpp +++ lib/Sema/SemaCodeComplete.cpp @@ -3752,6 +3752,10 @@ Results.data(), Results.size()); } +void Sema::CodeCompleteExpression(Scope *S, QualType PreferredType) { + return CodeCompleteExpression(S, CodeCompleteExpressionData(PreferredType)); +} + void Sema::CodeCompletePostfixExpression(Scope *S, ExprResult E) { if (E.isInvalid()) CodeCompleteOrdinaryName(S, PCC_RecoveryInFunction); @@ -4435,42 +4439,28 @@ return ParamType; } -static void -CodeCompleteOverloadResults(Sema , Scope *S, -MutableArrayRef Candidates, -unsigned CurrentArg, SourceLocation OpenParLoc, -bool CompleteExpressionWithCurrentArg = true) { - QualType ParamType; - if (CompleteExpressionWithCurrentArg) -ParamType = getParamType(SemaRef, Candidates, CurrentArg); - - if (ParamType.isNull()) -SemaRef.CodeCompleteOrdinaryName(S, Sema::PCC_Expression); - else -SemaRef.CodeCompleteExpression(S, ParamType); - - if (!Candidates.empty()) -SemaRef.CodeCompleter->ProcessOverloadCandidates( -SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc); +static QualType +ProduceSignatureHelp(Sema , Scope *S, + MutableArrayRef Candidates, + unsigned CurrentArg, SourceLocation OpenParLoc) { + if (Candidates.empty()) +return QualType(); + SemaRef.CodeCompleter->ProcessOverloadCandidates( + SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc); + return getParamType(SemaRef, Candidates, CurrentArg); } -void Sema::CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef Args, -SourceLocation OpenParLoc) { +QualType Sema::ProduceCallSignatureHelp(Scope *S, Expr *Fn, +ArrayRef Args, +SourceLocation OpenParLoc) { if (!CodeCompleter) -return; - - // When we're code-completing for a call, we fall back to ordinary - // name code-completion whenever we can't produce specific - // results. We may want to revisit this strategy in the future, - // e.g., by merging the two kinds of results. +return QualType(); // FIXME: Provide support for variadic template functions. - // Ignore type-dependent call expressions entirely. if (!Fn || Fn->isTypeDependent() || anyNullArguments(Args) || Expr::hasAnyTypeDependentArguments(Args)) { -CodeCompleteOrdinaryName(S, PCC_Expression); -return; +return QualType(); } // Build an overload candidate set based on the functions we find. @@ -4551,25 +4541,24 @@ Results.push_back(ResultCandidate(FT)); } } - mergeCandidatesWithResults(*this, Results, CandidateSet, Loc); - CodeCompleteOverloadResults(*this, S, Results, Args.size(), OpenParLoc, -
[PATCH] D50246: [RISCV] Add support for computing sysroot for riscv32-unknown-elf
kristina closed this revision. kristina added a comment. Closed by https://reviews.llvm.org/rC341655. Repository: rC Clang https://reviews.llvm.org/D50246 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r341655 - Differential Revision: https://reviews.llvm.org/D50246
Author: kristina Date: Fri Sep 7 06:03:31 2018 New Revision: 341655 URL: http://llvm.org/viewvc/llvm-project?rev=341655=rev Log: Differential Revision: https://reviews.llvm.org/D50246 [RISCV] Add support for computing sysroot for riscv32-unknown-elf Extends r338385 to allow the driver to compute the sysroot when an explicit path is not provided. This allows the linker to find C runtime files and the correct include directory for header files. Patch by lewis-revill (Lewis Revill) Modified: cfe/trunk/lib/Driver/ToolChains/RISCV.cpp cfe/trunk/lib/Driver/ToolChains/RISCV.h cfe/trunk/test/Driver/riscv32-toolchain.c Modified: cfe/trunk/lib/Driver/ToolChains/RISCV.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/RISCV.cpp?rev=341655=341654=341655=diff == --- cfe/trunk/lib/Driver/ToolChains/RISCV.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/RISCV.cpp Fri Sep 7 06:03:31 2018 @@ -13,6 +13,7 @@ #include "clang/Driver/Compilation.h" #include "clang/Driver/Options.h" #include "llvm/Option/ArgList.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" @@ -27,7 +28,7 @@ RISCVToolChain::RISCVToolChain(const Dri const ArgList ) : Generic_ELF(D, Triple, Args) { GCCInstallation.init(Triple, Args); - getFilePaths().push_back(D.SysRoot + "/lib"); + getFilePaths().push_back(computeSysRoot() + "/lib"); if (GCCInstallation.isValid()) { getFilePaths().push_back(GCCInstallation.getInstallPath().str()); getProgramPaths().push_back( @@ -39,13 +40,21 @@ Tool *RISCVToolChain::buildLinker() cons return new tools::RISCV::Linker(*this); } +void RISCVToolChain::addClangTargetOptions( +const llvm::opt::ArgList , +llvm::opt::ArgStringList , +Action::OffloadKind) const { + CC1Args.push_back("-nostdsysteminc"); + CC1Args.push_back("-fuse-init-array"); +} + void RISCVToolChain::AddClangSystemIncludeArgs(const ArgList , ArgStringList ) const { if (DriverArgs.hasArg(options::OPT_nostdinc)) return; if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) { -SmallString<128> Dir(getDriver().SysRoot); +SmallString<128> Dir(computeSysRoot()); llvm::sys::path::append(Dir, "include"); addSystemInclude(DriverArgs, CC1Args, Dir.str()); } @@ -54,15 +63,30 @@ void RISCVToolChain::AddClangSystemInclu void RISCVToolChain::addLibStdCxxIncludePaths( const llvm::opt::ArgList , llvm::opt::ArgStringList ) const { - StringRef LibDir = GCCInstallation.getParentLibPath(); const GCCVersion = GCCInstallation.getVersion(); StringRef TripleStr = GCCInstallation.getTriple().str(); const Multilib = GCCInstallation.getMultilib(); - addLibStdCXXIncludePaths( - LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.Text, + addLibStdCXXIncludePaths(computeSysRoot() + "/include/c++/" + Version.Text, "", TripleStr, "", "", Multilib.includeSuffix(), DriverArgs, CC1Args); } +std::string RISCVToolChain::computeSysRoot() const { + if (!getDriver().SysRoot.empty()) +return getDriver().SysRoot; + + if (!GCCInstallation.isValid()) +return std::string(); + + StringRef LibDir = GCCInstallation.getParentLibPath(); + StringRef TripleStr = GCCInstallation.getTriple().str(); + std::string SysRootDir = LibDir.str() + "/../" + TripleStr.str(); + + if (!llvm::sys::fs::exists(SysRootDir)) +return std::string(); + + return SysRootDir; +} + void RISCV::Linker::ConstructJob(Compilation , const JobAction , const InputInfo , const InputInfoList , Modified: cfe/trunk/lib/Driver/ToolChains/RISCV.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/RISCV.h?rev=341655=341654=341655=diff == --- cfe/trunk/lib/Driver/ToolChains/RISCV.h (original) +++ cfe/trunk/lib/Driver/ToolChains/RISCV.h Fri Sep 7 06:03:31 2018 @@ -23,6 +23,9 @@ public: const llvm::opt::ArgList ); bool IsIntegratedAssemblerDefault() const override { return true; } + void addClangTargetOptions(const llvm::opt::ArgList , + llvm::opt::ArgStringList , + Action::OffloadKind) const override; void AddClangSystemIncludeArgs(const llvm::opt::ArgList , llvm::opt::ArgStringList ) const override; @@ -32,6 +35,9 @@ public: protected: Tool *buildLinker() const override; + +private: + std::string computeSysRoot() const; }; } // end namespace toolchains Modified: cfe/trunk/test/Driver/riscv32-toolchain.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv32-toolchain.c?rev=341655=341654=341655=diff
[PATCH] D50246: [RISCV] Add support for computing sysroot for riscv32-unknown-elf
kristina added a comment. Going to land it as it's approved by code owner. Repository: rC Clang https://reviews.llvm.org/D50246 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl
takuto.ikuta added a comment. In https://reviews.llvm.org/D51340#1226989, @takuto.ikuta wrote: > In https://reviews.llvm.org/D51340#1222013, @hans wrote: > > > Did both your builds use PCH? It'd be interesting to see the difference > > without PCH too; the effect should be even larger. > > > Added stats of without PCH build. > > > The summary should probably reference > > https://bugs.llvm.org/show_bug.cgi?id=33628 and it needs to mention how it > > affects dllimport too. > > Added to description, thanks! > > > Okay, after reading through the patch, it seems we're still marking class > > members dllexport, and then you selectively remove the attribute later. > > That does feel a little bit backward... Does -fvisibility-inlines-hidden > > also have the static local problem, or how does that flag handle it? > > Ah, maybe I can get performance improvement just support > fvisibility-inlines-hidden in clang-cl. Let me try. I just support fvisibility-inlines-hidden in clang-cl and that looks to work intended. https://reviews.llvm.org/D51340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r341654 - Reland r341390 clang-cl: Pass /Brepro to linker if it was passed to the compiler
Author: nico Date: Fri Sep 7 05:47:02 2018 New Revision: 341654 URL: http://llvm.org/viewvc/llvm-project?rev=341654=rev Log: Reland r341390 clang-cl: Pass /Brepro to linker if it was passed to the compiler The test was missing '--' on mac as pointed out by -Wslash-u-filename: :5:69: note: possible intended match here clang: warning: '/Users/thakis/src/llvm-mono/clang/test/Driver/msvc-link.c' treated as the '/U' option [-Wslash-u-filename] Differential Revision: https://reviews.llvm.org/D51635 Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp cfe/trunk/test/Driver/msvc-link.c Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=341654=341653=341654=diff == --- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Fri Sep 7 05:47:02 2018 @@ -355,6 +355,15 @@ void visualstudio::Linker::ConstructJob( options::OPT__SLASH_Zd)) CmdArgs.push_back("-debug"); + // Pass on /Brepro if it was passed to the compiler. + // Note that /Brepro maps to -mno-incremental-linker-compatible. + bool DefaultIncrementalLinkerCompatible = + C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment(); + if (!Args.hasFlag(options::OPT_mincremental_linker_compatible, +options::OPT_mno_incremental_linker_compatible, +DefaultIncrementalLinkerCompatible)) +CmdArgs.push_back("-Brepro"); + bool DLL = Args.hasArg(options::OPT__SLASH_LD, options::OPT__SLASH_LDd, options::OPT_shared); if (DLL) { Modified: cfe/trunk/test/Driver/msvc-link.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/msvc-link.c?rev=341654=341653=341654=diff == --- cfe/trunk/test/Driver/msvc-link.c (original) +++ cfe/trunk/test/Driver/msvc-link.c Fri Sep 7 05:47:02 2018 @@ -3,6 +3,7 @@ // BASIC: "-out:a.exe" // BASIC: "-defaultlib:libcmt" // BASIC: "-nologo" +// BASIC-NOT: "-Brepro" // RUN: %clang -target i686-pc-windows-msvc -shared -o a.dll -### %s 2>&1 | FileCheck --check-prefix=DLL %s // DLL: link.exe" @@ -16,3 +17,14 @@ // LIBPATH: "-libpath:/usr/lib" // LIBPATH: "-nologo" +// RUN: %clang_cl /Brepro -### -- %s 2>&1 | FileCheck --check-prefix=REPRO %s +// REPRO: link.exe" +// REPRO: "-out:msvc-link.exe" +// REPRO: "-nologo" +// REPRO: "-Brepro" + +// RUN: %clang_cl /Brepro- -### -- %s 2>&1 | FileCheck --check-prefix=NOREPRO %s +// NOREPRO: link.exe" +// NOREPRO: "-out:msvc-link.exe" +// NOREPRO: "-nologo" +// NOREPRO-NOT: "-Brepro" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r341560 - Reverting r 341390 because it is causing test failures on GreenDragon.
Relanded with a fix attempt at 341654. On Thu, Sep 6, 2018 at 12:31 PM A Bergen via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: sudofortune > Date: Thu Sep 6 09:29:40 2018 > New Revision: 341560 > > URL: http://llvm.org/viewvc/llvm-project?rev=341560=rev > Log: > Reverting r 341390 because it is causing test failures on GreenDragon. > > http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental/52810/ > > > Modified: > cfe/trunk/lib/Driver/ToolChains/MSVC.cpp > cfe/trunk/test/Driver/msvc-link.c > > Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=341560=341559=341560=diff > > == > --- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original) > +++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Thu Sep 6 09:29:40 2018 > @@ -355,15 +355,6 @@ void visualstudio::Linker::ConstructJob( >options::OPT__SLASH_Zd)) > CmdArgs.push_back("-debug"); > > - // Pass on /Brepro if it was passed to the compiler. > - // Note that /Brepro maps to -mno-incremental-linker-compatible. > - bool DefaultIncrementalLinkerCompatible = > - C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment(); > - if (!Args.hasFlag(options::OPT_mincremental_linker_compatible, > -options::OPT_mno_incremental_linker_compatible, > -DefaultIncrementalLinkerCompatible)) > -CmdArgs.push_back("-Brepro"); > - >bool DLL = Args.hasArg(options::OPT__SLASH_LD, options::OPT__SLASH_LDd, > options::OPT_shared); >if (DLL) { > > Modified: cfe/trunk/test/Driver/msvc-link.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/msvc-link.c?rev=341560=341559=341560=diff > > == > --- cfe/trunk/test/Driver/msvc-link.c (original) > +++ cfe/trunk/test/Driver/msvc-link.c Thu Sep 6 09:29:40 2018 > @@ -3,7 +3,6 @@ > // BASIC: "-out:a.exe" > // BASIC: "-defaultlib:libcmt" > // BASIC: "-nologo" > -// BASIC-NOT: "-Brepro" > > // RUN: %clang -target i686-pc-windows-msvc -shared -o a.dll -### %s 2>&1 > | FileCheck --check-prefix=DLL %s > // DLL: link.exe" > @@ -17,14 +16,3 @@ > // LIBPATH: "-libpath:/usr/lib" > // LIBPATH: "-nologo" > > -// RUN: %clang_cl /Brepro -### %s 2>&1 | FileCheck --check-prefix=REPRO %s > -// REPRO: link.exe" > -// REPRO: "-out:msvc-link.exe" > -// REPRO: "-nologo" > -// REPRO: "-Brepro" > - > -// RUN: %clang_cl /Brepro- -### %s 2>&1 | FileCheck > --check-prefix=NOREPRO %s > -// NOREPRO: link.exe" > -// NOREPRO: "-out:msvc-link.exe" > -// NOREPRO: "-nologo" > -// NOREPRO-NOT: "-Brepro" > > > ___ > 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: r335081 - Recommit r335063: [Darwin] Add a warning for missing include path for libstdc++
On Wed, Sep 5, 2018 at 9:25 PM Alex L wrote: > Sorry for the late response, > > On Sat, 18 Aug 2018 at 20:10, Nico Weber wrote: > >> Also, the diag text should probably say "pass '-stdlib=libc++' " not >> "pass '-std=libc++' "? >> > > Good catch, thanks! I'll commit a fixup for it. > > >> >> On Sat, Aug 18, 2018 at 11:06 PM Nico Weber wrote: >> >>> Should this maybe not be emitted when compiling e.g. .ii files >>> (preprocessed output)? I just got this when I built a standalone .ii file >>> with some bug repro after I deleted all -I and -isysroot flags and whatnot, >>> since they aren't needed for preprocessed files. >>> >> > That would make sense, but I'm not sure how easy it is to determine if a > file is already preprocessed. I'll try to create a patch for this fixup. > Probably you'd want something like http://llvm-cs.pcc.me.uk/tools/clang/lib/Driver/Types.cpp#123 that returns true for all (or most) of the TY_PP_ types, and then just rely on lookupTypeForExtension. > > > >> >>> On Tue, Jun 19, 2018 at 6:52 PM Alex Lorenz via cfe-commits < >>> cfe-commits@lists.llvm.org> wrote: >>> Author: arphaman Date: Tue Jun 19 15:47:53 2018 New Revision: 335081 URL: http://llvm.org/viewvc/llvm-project?rev=335081=rev Log: Recommit r335063: [Darwin] Add a warning for missing include path for libstdc++ The recommit ensures that the tests that failed on bots don't trigger the warning. Xcode 10 removes support for libstdc++, but the users just get a confusing include not file warning when including an STL header (when building for iOS6 which uses libstdc++ by default for example). This patch adds a new warning that lets the user know that the libstdc++ include path was not found to ensure that the user is more aware of why the error occurs. rdar://40830462 Differential Revision: https://reviews.llvm.org/D48297 Added: cfe/trunk/test/Frontend/warning-stdlibcxx-darwin.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td cfe/trunk/include/clang/Lex/HeaderSearch.h cfe/trunk/lib/Frontend/InitHeaderSearch.cpp cfe/trunk/test/CodeGenCXX/apple-kext-guard-variable.cpp cfe/trunk/test/Misc/backend-stack-frame-diagnostics.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=335081=335080=335081=diff == --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Tue Jun 19 15:47:53 2018 @@ -236,4 +236,9 @@ def err_invalid_vfs_overlay : Error< def warn_option_invalid_ocl_version : Warning< "OpenCL version %0 does not support the option '%1'">, InGroup; + +def warn_stdlibcxx_not_found : Warning< + "include path for stdlibc++ headers not found; pass '-std=libc++' on the " + "command line to use the libc++ standard library instead">, + InGroup>; } Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=335081=335080=335081=diff == --- cfe/trunk/include/clang/Lex/HeaderSearch.h (original) +++ cfe/trunk/include/clang/Lex/HeaderSearch.h Tue Jun 19 15:47:53 2018 @@ -272,6 +272,8 @@ public: FileManager () const { return FileMgr; } + DiagnosticsEngine () const { return Diags; } + /// Interface for setting the file search paths. void SetSearchPaths(const std::vector , unsigned angledDirIdx, unsigned systemDirIdx, Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=335081=335080=335081=diff == --- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original) +++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Tue Jun 19 15:47:53 2018 @@ -14,6 +14,7 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/LangOptions.h" #include "clang/Config/config.h" // C_INCLUDE_DIRS +#include "clang/Frontend/FrontendDiagnostic.h" #include "clang/Frontend/Utils.h" #include "clang/Lex/HeaderMap.h" #include "clang/Lex/HeaderSearch.h" @@ -55,11 +56,13 @@ public: /// AddPath - Add the specified path to the specified group list, prefixing /// the sysroot if used. - void AddPath(const Twine , IncludeDirGroup Group, bool
[PATCH] D50246: [RISCV] Add support for computing sysroot for riscv32-unknown-elf
lewis-revill added a comment. @asb can we get this committed? Repository: rC Clang https://reviews.llvm.org/D50246 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51038: [clang] Make sure codecompletion is called for calls even when inside a token.
ilya-biryukov added inline comments. Comment at: test/Index/complete-block-property-assignment.m:71 +// RUN: c-index-test -code-completion-at=%s:54:15 %s | FileCheck -check-prefix=CHECK-NO1 %s +// CHECK-NO1: ObjCPropertyDecl:{ResultType int}{TypedText foo} (35) kadircet wrote: > ilya-biryukov wrote: > > ilya-biryukov wrote: > > > Any idea why behavior changed in that case? > > Looked at it more thoroughly now... > > So we're now showing both the signature help and the completion, right? > > If that the case, LG, but can we include the rest of completion items from > > CHECK-N0? > > > > Maybe also add a comment that the last item is from overload set > > completion, rather than the ordinary code completion? (To avoid confusion > > and make it clear why we need an extra check there) > Yes, c-index-test binary collects results from both ProcessOverloadCandidate > and ProcessCodeCompleteResults. Therefore they are merged. Adding the same > set of results on the above is not enough for that particular case, due to > the clever nature of CodeCompleteOverloadResult at > https://github.com/llvm-mirror/clang/blob/master/lib/Sema/SemaCodeComplete.cpp#L4439. > > It doesn't just try to tell you the overloads of that particular function but > also tries to complete the current argument. Therefore the list simply gets > huge by expansion of all the macros and other stuff. > > But when looking into it I found out I was checking for wrong return values > fixing that with the new diff. I don't think it's correct to call CodeCompleteExpression and CodeCompleteOrdinaryName in this context. This completion assume we're at the start of the argument, which is not true anymore. E.g. we can be producing weird results in the middle of expressions. Some examples from the top of my head: ``` func(var.^); // <-- (1) we add top-level completions in addition to members of bar func(&^); // <-- (2) we provide incorrect ParamType ``` For (2) if ParamType is `int*`, we would incorrectly uprank items of type `int*` (should uprank items of type `int` instead). I'll investigate a bit more to see if we can refactor the code to untangle signature help from code completion. Repository: rC Clang https://reviews.llvm.org/D51038 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51057: [analyzer][UninitializedObjectChecker] Fixed dereferencing
Szelethus added inline comments. Comment at: test/Analysis/cxx-uninitialized-object.cpp:879-902 +struct LambdaWrapper { + void *func; // no-crash + int dontGetFilteredByNonPedanticMode = 0; + + LambdaWrapper(void *ptr) : func(ptr) {} // expected-warning{{1 uninitialized field}} +}; + NoQ wrote: > Szelethus wrote: > > I'm 99% sure this is a FP, but it doesn't originate from the checker. > > Shouldn't `*ptr` be undef after the end of the code block as `lambda`'s > > lifetime ends? > > > > Nevertheless, it did cause a crash, so here's a quick fix for it. > I'm pretty sure that all sorts of contents of `lambda` aka `*ptr` are > undefined once it goes out of scope. Moreover, `ptr` is now a dangling > pointer, and reading from it would cause undefined behavior. I'm not sure if > the analyzer actually models this though. > > But on the other hand, even if it didn't go out of scope, i don't really see > where field `a` was initialized here. > > Soo what makes you think it's a false positive? > Soo what makes you think it's a false positive? Poor choice of words I guess. Its not a false positive (as the entire region of that lambda is undefined), but rather a false negative, as the analyzer doesn't pick up that `*ptr` is a dangling pointer. https://reviews.llvm.org/D51057 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51747: [clangd] Implement deprecation diagnostics with lower severity.
ilya-biryukov added a comment. Not sure if it's fine to hijack our own diagnostic-specific flags in to clang command args. Const that I see: 1. There is no way for the users to turn them off if they find them non-useful. If we add a way, it would be more config parameters which overlap with other mechanism that we have - compiler flags. 2. Users who are used to having them as warnings will now see them as notes. Again, no way to tweak this behavior. What's our use-case? Maybe we should ask the clients to add -Wdeprecated if they care about those? PS In case I'm missing the context here, please let me know. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D51747 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51539: [clangd] Add symbol slab size to index memory consumption estimates
kbobyrev updated this revision to Diff 164383. kbobyrev marked an inline comment as done. kbobyrev added a comment. Oh, I thought they're empty. https://reviews.llvm.org/D51539 Files: clang-tools-extra/clangd/index/FileIndex.cpp clang-tools-extra/clangd/index/Index.cpp clang-tools-extra/clangd/index/Index.h clang-tools-extra/clangd/index/MemIndex.cpp clang-tools-extra/clangd/index/MemIndex.h clang-tools-extra/clangd/index/dex/DexIndex.cpp clang-tools-extra/clangd/index/dex/DexIndex.h clang-tools-extra/unittests/clangd/IndexTests.cpp Index: clang-tools-extra/unittests/clangd/IndexTests.cpp === --- clang-tools-extra/unittests/clangd/IndexTests.cpp +++ clang-tools-extra/unittests/clangd/IndexTests.cpp @@ -10,11 +10,11 @@ #include "Annotations.h" #include "TestIndex.h" #include "TestTU.h" -#include "gmock/gmock.h" #include "index/FileIndex.h" #include "index/Index.h" #include "index/MemIndex.h" #include "index/Merge.h" +#include "gmock/gmock.h" #include "gtest/gtest.h" using testing::_; @@ -58,11 +58,11 @@ auto Token = std::make_shared(); std::weak_ptr WeakToken = Token; - SwapIndex S( - llvm::make_unique(SymbolSlab(), RefSlab(), std::move(Token))); - EXPECT_FALSE(WeakToken.expired()); // Current MemIndex keeps it alive. + SwapIndex S(llvm::make_unique( + SymbolSlab(), RefSlab(), std::move(Token), /*BackingDataSize=*/0)); + EXPECT_FALSE(WeakToken.expired()); // Current MemIndex keeps it alive. S.reset(llvm::make_unique()); // Now the MemIndex is destroyed. - EXPECT_TRUE(WeakToken.expired()); // So the token is too. + EXPECT_TRUE(WeakToken.expired()); // So the token is too. } TEST(MemIndexTest, MemIndexDeduplicate) { @@ -281,7 +281,7 @@ FileURI("unittest:///test2.cc")); } -MATCHER_P2(IncludeHeaderWithRef, IncludeHeader, References, "") { +MATCHER_P2(IncludeHeaderWithRef, IncludeHeader, References, "") { return (arg.IncludeHeader == IncludeHeader) && (arg.References == References); } Index: clang-tools-extra/clangd/index/dex/DexIndex.h === --- clang-tools-extra/clangd/index/dex/DexIndex.h +++ clang-tools-extra/clangd/index/dex/DexIndex.h @@ -55,17 +55,21 @@ } // Symbols are owned by BackingData, Index takes ownership. template - DexIndex(Range &, Payload &, + DexIndex(Range &, Payload &, size_t BackingDataSize, llvm::ArrayRef URISchemes) : DexIndex(std::forward(Symbols), URISchemes) { KeepAlive = std::shared_ptr( std::make_shared(std::move(BackingData)), nullptr); +this->BackingDataSize = BackingDataSize; } /// Builds an index from a slab. The index takes ownership of the slab. static std::unique_ptr build(SymbolSlab Slab, llvm::ArrayRef URISchemes) { -return llvm::make_unique(Slab, std::move(Slab), URISchemes); +// Store Slab size before it is moved. +const auto BackingDataSize = Slab.bytes(); +return llvm::make_unique(Slab, std::move(Slab), BackingDataSize, + URISchemes); } bool @@ -96,6 +100,8 @@ /// during the fuzzyFind process. llvm::DenseMap InvertedIndex; std::shared_ptr KeepAlive; // poor man's move-only std::any + // Size of memory retained by KeepAlive. + size_t BackingDataSize = 0; std::vector URISchemes; }; Index: clang-tools-extra/clangd/index/dex/DexIndex.cpp === --- clang-tools-extra/clangd/index/dex/DexIndex.cpp +++ clang-tools-extra/clangd/index/dex/DexIndex.cpp @@ -228,15 +228,13 @@ } size_t DexIndex::estimateMemoryUsage() const { - size_t Bytes = - LookupTable.size() * sizeof(std::pair); - Bytes += SymbolQuality.size() * sizeof(std::pair); - Bytes += InvertedIndex.size() * sizeof(Token); - - for (const auto : InvertedIndex) { + size_t Bytes = Symbols.size() * sizeof(const Symbol *); + Bytes += SymbolQuality.size() * sizeof(float); + Bytes += LookupTable.getMemorySize(); + Bytes += InvertedIndex.getMemorySize(); + for (const auto : InvertedIndex) Bytes += P.second.size() * sizeof(DocID); - } - return Bytes; + return Bytes + BackingDataSize; } std::vector generateProximityURIs(llvm::StringRef URIPath) { Index: clang-tools-extra/clangd/index/MemIndex.h === --- clang-tools-extra/clangd/index/MemIndex.h +++ clang-tools-extra/clangd/index/MemIndex.h @@ -30,11 +30,13 @@ } // Symbols are owned by BackingData, Index takes ownership. template - MemIndex(SymbolRange &, RefRange &, Payload &) + MemIndex(SymbolRange &, RefRange &, Payload &, + size_t BackingDataSize) : MemIndex(std::forward(Symbols), std::forward(Refs)) { KeepAlive = std::shared_ptr(
[PATCH] D51340: Add /Zc:DllexportInlines option to clang-cl
takuto.ikuta updated this revision to Diff 164379. takuto.ikuta edited the summary of this revision. https://reviews.llvm.org/D51340 Files: clang/include/clang/Driver/CLCompatOptions.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/test/CodeGenCXX/dllexport-no-inline.cpp clang/test/CodeGenCXX/hidden-dllimport.cpp Index: clang/test/CodeGenCXX/hidden-dllimport.cpp === --- clang/test/CodeGenCXX/hidden-dllimport.cpp +++ clang/test/CodeGenCXX/hidden-dllimport.cpp @@ -1,8 +1,8 @@ // RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -emit-llvm -fvisibility-inlines-hidden -o - %s | FileCheck %s -// We used to declare this hidden dllimport, which is contradictory. +// We don't declare this hidden dllimport. -// CHECK: declare dllimport void @"?bar@foo@@QEAAXXZ"(%struct.foo*) +// CHECK-NOT: declare dllimport void @"?bar@foo@@QEAAXXZ"(%struct.foo*) struct __attribute__((dllimport)) foo { void bar() {} Index: clang/test/CodeGenCXX/dllexport-no-inline.cpp === --- /dev/null +++ clang/test/CodeGenCXX/dllexport-no-inline.cpp @@ -0,0 +1,148 @@ +// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc \ +// RUN: -fvisibility-inlines-hidden -emit-llvm -O0 -o - | \ +// RUN: FileCheck --check-prefix=DEFAULT --check-prefix=NOINLINE %s + +// RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc \ +// RUN: -emit-llvm -O0 -o - | \ +// RUN: FileCheck --check-prefix=DEFAULT --check-prefix=INLINE %s + + +// Function + +// DEFAULT-DAG: define dso_local dllexport void @"?NormalFunction@@YAXXZ"() +void __declspec(dllexport) NormalFunction() {} + + +// NOINLINE-DAG: define weak_odr hidden dllexport void @"?AlwaysInlineFunction@@YAXXZ" +// INLINE-DAG: define weak_odr dso_local dllexport void @"?AlwaysInlineFunction@@YAXXZ" +__forceinline void __declspec(dllexport) AlwaysInlineFunction() {} + +// Class member function + +// check for local static variables +// NOINLINE-DAG: @"?static_variable@?1??InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4HA" = linkonce_odr dso_local global i32 0, comdat, align 4 +// INLINE-DAG: @"?static_variable@?1??InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4 +// NOINLINE-DAG: @"?static_const_variable@?1??InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4HB" = linkonce_odr dso_local constant i32 1, comdat, align 4 +// INLINE-DAG: @"?static_const_variable@?1??InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4HB" = weak_odr dso_local dllexport constant i32 1, comdat, align 4 +// NOINLINE-DAG: @"?static_const_array@?1??InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4QBHB" = linkonce_odr dso_local constant [3 x i32] [i32 1, i32 2, i32 3], comdat, align 4 +// INLINE-DAG: @"?static_const_array@?1??InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4QBHB" = weak_odr dso_local dllexport constant [3 x i32] [i32 1, i32 2, i32 3], comdat, align 4 +// NOINLINE-DAG: @"?static_variable_non_const_cse@?1??InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4HA" = linkonce_odr dso_local global i32 4, comdat, align 4 +// INLINE-DAG: @"?static_variable_non_const_cse@?1??InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 4, comdat, align 4 +// NOINLINE-DAG: @"?static_variable@?1??InlineOutclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4HA" = linkonce_odr dso_local global i32 0, comdat, align 4 +// INLINE-DAG: @"?static_variable@?1??InlineOutclassDefFuncWithStaticVariable@NoTemplateExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4 + +class __declspec(dllexport) NoTemplateExportedClass { + public: + // DEFAULT-NOT: NoTemplateExportedClass@NoTemplateExportedClass@@ + NoTemplateExportedClass() = default; + + // NOINLINE-NOT: InclassDefFunc@NoTemplateExportedClass + // INLINE-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@NoTemplateExportedClass@@ + void InclassDefFunc() {} + + int f(); + + // NOINLINE-NOT: InclassDefFuncWithStaticVariable@NoTemplateExportedClass + // INLINE-DAG: define weak_odr dso_local dllexport i32 @"?InclassDefFuncWithStaticVariable@NoTemplateExportedClass@@ + int InclassDefFuncWithStaticVariable() { +static int static_variable = f(); +static const int static_const_variable = 1; +// DEFAULT-NOT: static_constexpr_variable +static constexpr int static_constexpr_variable = 2; +static const int static_const_array[] = {1, 2, 3}; +static int static_variable_non_const_cse = 4; + +++static_variable_non_const_cse; +++static_variable; +return static_const_variable + static_constexpr_variable + +
[PATCH] D45719: [clang-Format] Fix indentation of member call after block
ank added a comment. ping Repository: rC Clang https://reviews.llvm.org/D45719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen(), size() or equal length
whisperity added a comment. https://reviews.llvm.org/D50353 has landed, so after a rebase this patch will not compile. https://reviews.llvm.org/D45050 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51539: [clangd] Add symbol slab size to index memory consumption estimates
sammccall added inline comments. Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:131 + size_t StorageSize = 0; + for (const auto : SymbolSlabs) +StorageSize += Slab->bytes(); also the refslabs and refsstorage https://reviews.llvm.org/D51539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51539: [clangd] Add symbol slab size to index memory consumption estimates
kbobyrev updated this revision to Diff 164377. kbobyrev marked an inline comment as done. https://reviews.llvm.org/D51539 Files: clang-tools-extra/clangd/index/FileIndex.cpp clang-tools-extra/clangd/index/Index.cpp clang-tools-extra/clangd/index/Index.h clang-tools-extra/clangd/index/MemIndex.cpp clang-tools-extra/clangd/index/MemIndex.h clang-tools-extra/clangd/index/dex/DexIndex.cpp clang-tools-extra/clangd/index/dex/DexIndex.h clang-tools-extra/unittests/clangd/IndexTests.cpp Index: clang-tools-extra/unittests/clangd/IndexTests.cpp === --- clang-tools-extra/unittests/clangd/IndexTests.cpp +++ clang-tools-extra/unittests/clangd/IndexTests.cpp @@ -10,11 +10,11 @@ #include "Annotations.h" #include "TestIndex.h" #include "TestTU.h" -#include "gmock/gmock.h" #include "index/FileIndex.h" #include "index/Index.h" #include "index/MemIndex.h" #include "index/Merge.h" +#include "gmock/gmock.h" #include "gtest/gtest.h" using testing::_; @@ -58,11 +58,11 @@ auto Token = std::make_shared(); std::weak_ptr WeakToken = Token; - SwapIndex S( - llvm::make_unique(SymbolSlab(), RefSlab(), std::move(Token))); - EXPECT_FALSE(WeakToken.expired()); // Current MemIndex keeps it alive. + SwapIndex S(llvm::make_unique( + SymbolSlab(), RefSlab(), std::move(Token), /*BackingDataSize=*/0)); + EXPECT_FALSE(WeakToken.expired()); // Current MemIndex keeps it alive. S.reset(llvm::make_unique()); // Now the MemIndex is destroyed. - EXPECT_TRUE(WeakToken.expired()); // So the token is too. + EXPECT_TRUE(WeakToken.expired()); // So the token is too. } TEST(MemIndexTest, MemIndexDeduplicate) { @@ -281,7 +281,7 @@ FileURI("unittest:///test2.cc")); } -MATCHER_P2(IncludeHeaderWithRef, IncludeHeader, References, "") { +MATCHER_P2(IncludeHeaderWithRef, IncludeHeader, References, "") { return (arg.IncludeHeader == IncludeHeader) && (arg.References == References); } Index: clang-tools-extra/clangd/index/dex/DexIndex.h === --- clang-tools-extra/clangd/index/dex/DexIndex.h +++ clang-tools-extra/clangd/index/dex/DexIndex.h @@ -55,17 +55,21 @@ } // Symbols are owned by BackingData, Index takes ownership. template - DexIndex(Range &, Payload &, + DexIndex(Range &, Payload &, size_t BackingDataSize, llvm::ArrayRef URISchemes) : DexIndex(std::forward(Symbols), URISchemes) { KeepAlive = std::shared_ptr( std::make_shared(std::move(BackingData)), nullptr); +this->BackingDataSize = BackingDataSize; } /// Builds an index from a slab. The index takes ownership of the slab. static std::unique_ptr build(SymbolSlab Slab, llvm::ArrayRef URISchemes) { -return llvm::make_unique(Slab, std::move(Slab), URISchemes); +// Store Slab size before it is moved. +const auto BackingDataSize = Slab.bytes(); +return llvm::make_unique(Slab, std::move(Slab), BackingDataSize, + URISchemes); } bool @@ -96,6 +100,8 @@ /// during the fuzzyFind process. llvm::DenseMap InvertedIndex; std::shared_ptr KeepAlive; // poor man's move-only std::any + // Size of memory retained by KeepAlive. + size_t BackingDataSize = 0; std::vector URISchemes; }; Index: clang-tools-extra/clangd/index/dex/DexIndex.cpp === --- clang-tools-extra/clangd/index/dex/DexIndex.cpp +++ clang-tools-extra/clangd/index/dex/DexIndex.cpp @@ -228,15 +228,13 @@ } size_t DexIndex::estimateMemoryUsage() const { - size_t Bytes = - LookupTable.size() * sizeof(std::pair); - Bytes += SymbolQuality.size() * sizeof(std::pair); - Bytes += InvertedIndex.size() * sizeof(Token); - - for (const auto : InvertedIndex) { + size_t Bytes = Symbols.size() * sizeof(const Symbol *); + Bytes += SymbolQuality.size() * sizeof(float); + Bytes += LookupTable.getMemorySize(); + Bytes += InvertedIndex.getMemorySize(); + for (const auto : InvertedIndex) Bytes += P.second.size() * sizeof(DocID); - } - return Bytes; + return Bytes + BackingDataSize; } std::vector generateProximityURIs(llvm::StringRef URIPath) { Index: clang-tools-extra/clangd/index/MemIndex.h === --- clang-tools-extra/clangd/index/MemIndex.h +++ clang-tools-extra/clangd/index/MemIndex.h @@ -30,11 +30,13 @@ } // Symbols are owned by BackingData, Index takes ownership. template - MemIndex(SymbolRange &, RefRange &, Payload &) + MemIndex(SymbolRange &, RefRange &, Payload &, + size_t BackingDataSize) : MemIndex(std::forward(Symbols), std::forward(Refs)) { KeepAlive = std::shared_ptr( std::make_shared(std::move(BackingData)), nullptr); +this->BackingDataSize =
[PATCH] D51683: Fix arm_neon.h and arm_fp16.h generation for compiling with std=c89
dnsampaio added a comment. In https://reviews.llvm.org/D51683#1226329, @joerg wrote: > Correct. The protected name is double underscore as both suffix and prefix. Ok, fixed. Cheers. https://reviews.llvm.org/D51683 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r341645 - [clangd] Canonicalize include paths in clangd.
Author: ioeric Date: Fri Sep 7 02:40:36 2018 New Revision: 341645 URL: http://llvm.org/viewvc/llvm-project?rev=341645=rev Log: [clangd] Canonicalize include paths in clangd. Get rid of "../" and "../../". Modified: clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp clang-tools-extra/trunk/clangd/index/FileIndex.cpp clang-tools-extra/trunk/clangd/index/FileIndex.h clang-tools-extra/trunk/clangd/index/MemIndex.cpp clang-tools-extra/trunk/clangd/index/Merge.cpp clang-tools-extra/trunk/clangd/index/Serialization.cpp clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp clang-tools-extra/trunk/clangd/index/dex/DexIndex.cpp clang-tools-extra/trunk/clangd/index/dex/DexIndex.h clang-tools-extra/trunk/clangd/index/dex/Token.h clang-tools-extra/trunk/clangd/index/dex/Trigram.cpp Modified: clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp?rev=341645=341644=341645=diff == --- clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp (original) +++ clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp Fri Sep 7 02:40:36 2018 @@ -8,7 +8,7 @@ //===--===// #include "CanonicalIncludes.h" -#include "../Headers.h" +#include "Headers.h" #include "clang/Driver/Types.h" #include "llvm/Support/Path.h" #include Modified: clang-tools-extra/trunk/clangd/index/FileIndex.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.cpp?rev=341645=341644=341645=diff == --- clang-tools-extra/trunk/clangd/index/FileIndex.cpp (original) +++ clang-tools-extra/trunk/clangd/index/FileIndex.cpp Fri Sep 7 02:40:36 2018 @@ -8,7 +8,7 @@ //===--===// #include "FileIndex.h" -#include "../Logger.h" +#include "Logger.h" #include "SymbolCollector.h" #include "clang/Index/IndexingAction.h" #include "clang/Lex/Preprocessor.h" Modified: clang-tools-extra/trunk/clangd/index/FileIndex.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.h?rev=341645=341644=341645=diff == --- clang-tools-extra/trunk/clangd/index/FileIndex.h (original) +++ clang-tools-extra/trunk/clangd/index/FileIndex.h Fri Sep 7 02:40:36 2018 @@ -16,7 +16,7 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_FILEINDEX_H #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_FILEINDEX_H -#include "../ClangdUnit.h" +#include "ClangdUnit.h" #include "Index.h" #include "MemIndex.h" #include "clang/Lex/Preprocessor.h" Modified: clang-tools-extra/trunk/clangd/index/MemIndex.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/MemIndex.cpp?rev=341645=341644=341645=diff == --- clang-tools-extra/trunk/clangd/index/MemIndex.cpp (original) +++ clang-tools-extra/trunk/clangd/index/MemIndex.cpp Fri Sep 7 02:40:36 2018 @@ -8,9 +8,9 @@ //===---===// #include "MemIndex.h" -#include "../FuzzyMatch.h" -#include "../Logger.h" -#include "../Quality.h" +#include "FuzzyMatch.h" +#include "Logger.h" +#include "Quality.h" namespace clang { namespace clangd { Modified: clang-tools-extra/trunk/clangd/index/Merge.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Merge.cpp?rev=341645=341644=341645=diff == --- clang-tools-extra/trunk/clangd/index/Merge.cpp (original) +++ clang-tools-extra/trunk/clangd/index/Merge.cpp Fri Sep 7 02:40:36 2018 @@ -8,7 +8,7 @@ //===--===// #include "Merge.h" -#include "../Logger.h" +#include "Logger.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringSet.h" #include "llvm/Support/raw_ostream.h" Modified: clang-tools-extra/trunk/clangd/index/Serialization.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Serialization.cpp?rev=341645=341644=341645=diff == --- clang-tools-extra/trunk/clangd/index/Serialization.cpp (original) +++ clang-tools-extra/trunk/clangd/index/Serialization.cpp Fri Sep 7 02:40:36 2018 @@ -7,8 +7,8 @@ // //===--===// #include "Serialization.h" -#include "../RIFF.h" #include "Index.h" +#include "RIFF.h" #include "llvm/Support/Compression.h" #include
r341644 - Replaces __inline by __inline__ / C89 compatible
Author: dnsampaio Date: Fri Sep 7 02:37:27 2018 New Revision: 341644 URL: http://llvm.org/viewvc/llvm-project?rev=341644=rev Log: Replaces __inline by __inline__ / C89 compatible Modified: cfe/trunk/utils/TableGen/NeonEmitter.cpp Modified: cfe/trunk/utils/TableGen/NeonEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/NeonEmitter.cpp?rev=341644=341643=341644=diff == --- cfe/trunk/utils/TableGen/NeonEmitter.cpp (original) +++ cfe/trunk/utils/TableGen/NeonEmitter.cpp Fri Sep 7 02:37:27 2018 @@ -2409,7 +2409,7 @@ void NeonEmitter::run(raw_ostream ) { OS << "#endif\n"; OS << "\n"; - OS << "#define __ai static __inline __attribute__((__always_inline__, " + OS << "#define __ai static __inline__ __attribute__((__always_inline__, " "__nodebug__))\n\n"; SmallVector Defs; @@ -2518,7 +2518,7 @@ void NeonEmitter::runFP16(raw_ostream OS << "typedef __fp16 float16_t;\n"; - OS << "#define __ai static __inline __attribute__((__always_inline__, " + OS << "#define __ai static __inline__ __attribute__((__always_inline__, " "__nodebug__))\n\n"; SmallVector Defs; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51539: [clangd] Add symbol slab size to index memory consumption estimates
sammccall added inline comments. Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:135 + std::move(RefsStorage)), + /*BackingDataSize=*/0); } this size should be calculated from the slabs above https://reviews.llvm.org/D51539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r341643 - [clang-tidy] Abseil: Allow macros inside of absl to use internal absl things
Author: d0k Date: Fri Sep 7 02:25:23 2018 New Revision: 341643 URL: http://llvm.org/viewvc/llvm-project?rev=341643=rev Log: [clang-tidy] Abseil: Allow macros inside of absl to use internal absl things Modified: clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/strings/internal-file.h clang-tools-extra/trunk/test/clang-tidy/abseil-no-internal-dependencies.cpp Modified: clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h?rev=341643=341642=341643=diff == --- clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h (original) +++ clang-tools-extra/trunk/clang-tidy/abseil/AbseilMatcher.h Fri Sep 7 02:25:23 2018 @@ -33,7 +33,7 @@ AST_POLYMORPHIC_MATCHER( isInAbseilFile, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc, NestedNameSpecifierLoc)) { auto = Finder->getASTContext().getSourceManager(); - SourceLocation Loc = Node.getBeginLoc(); + SourceLocation Loc = SourceManager.getSpellingLoc(Node.getBeginLoc()); if (Loc.isInvalid()) return false; const FileEntry *FileEntry = Modified: clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/strings/internal-file.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/strings/internal-file.h?rev=341643=341642=341643=diff == --- clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/strings/internal-file.h (original) +++ clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/strings/internal-file.h Fri Sep 7 02:25:23 2018 @@ -31,3 +31,5 @@ class FriendUsageInternal { namespace absl { void OpeningNamespaceInternally() { strings_internal::InternalFunction(); } } // namespace absl + +#define USE_INTERNAL(x) absl::strings_internal::Internal##x() Modified: clang-tools-extra/trunk/test/clang-tidy/abseil-no-internal-dependencies.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/abseil-no-internal-dependencies.cpp?rev=341643=341642=341643=diff == --- clang-tools-extra/trunk/test/clang-tidy/abseil-no-internal-dependencies.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/abseil-no-internal-dependencies.cpp Fri Sep 7 02:25:23 2018 @@ -37,3 +37,11 @@ namespace absl { SomeContainer b; std::string Str = absl::StringsFunction("a"); } // namespace absl + +#define USE_EXTERNAL(x) absl::strings_internal::Internal##x() + +void MacroUse() { + USE_INTERNAL(Function); // no-warning + USE_EXTERNAL(Function); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51691: [clangd] NFC: Document URIDistance
This revision was automatically updated to reflect the committed changes. Closed by commit rL341639: [clangd] NFC: Document URIDistance (authored by omtcyfz, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D51691?vs=164197=164372#toc Repository: rL LLVM https://reviews.llvm.org/D51691 Files: clang-tools-extra/trunk/clangd/FileDistance.h Index: clang-tools-extra/trunk/clangd/FileDistance.h === --- clang-tools-extra/trunk/clangd/FileDistance.h +++ clang-tools-extra/trunk/clangd/FileDistance.h @@ -89,6 +89,7 @@ // comparison on the bodies. class URIDistance { public: + // \p Sources must contain absolute paths, not URIs. URIDistance(llvm::StringMap Sources, const FileDistanceOptions = {}) : Sources(Sources), Opts(Opts) {} Index: clang-tools-extra/trunk/clangd/FileDistance.h === --- clang-tools-extra/trunk/clangd/FileDistance.h +++ clang-tools-extra/trunk/clangd/FileDistance.h @@ -89,6 +89,7 @@ // comparison on the bodies. class URIDistance { public: + // \p Sources must contain absolute paths, not URIs. URIDistance(llvm::StringMap Sources, const FileDistanceOptions = {}) : Sources(Sources), Opts(Opts) {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51691: [clangd] NFC: Document URIDistance
This revision was automatically updated to reflect the committed changes. Closed by commit rCTE341639: [clangd] NFC: Document URIDistance (authored by omtcyfz, committed by ). Changed prior to commit: https://reviews.llvm.org/D51691?vs=164197=164373#toc Repository: rL LLVM https://reviews.llvm.org/D51691 Files: clangd/FileDistance.h Index: clangd/FileDistance.h === --- clangd/FileDistance.h +++ clangd/FileDistance.h @@ -89,6 +89,7 @@ // comparison on the bodies. class URIDistance { public: + // \p Sources must contain absolute paths, not URIs. URIDistance(llvm::StringMap Sources, const FileDistanceOptions = {}) : Sources(Sources), Opts(Opts) {} Index: clangd/FileDistance.h === --- clangd/FileDistance.h +++ clangd/FileDistance.h @@ -89,6 +89,7 @@ // comparison on the bodies. class URIDistance { public: + // \p Sources must contain absolute paths, not URIs. URIDistance(llvm::StringMap Sources, const FileDistanceOptions = {}) : Sources(Sources), Opts(Opts) {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51211: [Sema] Emit -Wformat properly for bitfield promotions.
ebevhan added a comment. Ping. Repository: rC Clang https://reviews.llvm.org/D51211 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r341641 - [MSan] add KMSAN support to Clang driver
Author: glider Date: Fri Sep 7 02:21:09 2018 New Revision: 341641 URL: http://llvm.org/viewvc/llvm-project?rev=341641=rev Log: [MSan] add KMSAN support to Clang driver Boilerplate code for using KMSAN instrumentation in Clang. We add a new command line flag, -fsanitize=kernel-memory, with a corresponding SanitizerKind::KernelMemory, which, along with SanitizerKind::Memory, maps to the memory_sanitizer feature. KMSAN is only supported on x86_64 Linux. It's incompatible with other sanitizers, but supports code coverage instrumentation. Modified: cfe/trunk/include/clang/Basic/Features.def cfe/trunk/include/clang/Basic/Sanitizers.def cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/Driver/SanitizerArgs.cpp cfe/trunk/lib/Driver/ToolChains/Linux.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/CodeGen/cleanup-destslot-simple.c cfe/trunk/test/Driver/fsanitize-coverage.c cfe/trunk/test/Driver/fsanitize.c cfe/trunk/test/Driver/msan.c cfe/trunk/test/Lexer/has_feature_memory_sanitizer.cpp Modified: cfe/trunk/include/clang/Basic/Features.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Features.def?rev=341641=341640=341641=diff == --- cfe/trunk/include/clang/Basic/Features.def (original) +++ cfe/trunk/include/clang/Basic/Features.def Fri Sep 7 02:21:09 2018 @@ -72,7 +72,9 @@ FEATURE(cxx_rtti, LangOpts.RTTI & FEATURE(enumerator_attributes, true) FEATURE(nullability, true) FEATURE(nullability_on_arrays, true) -FEATURE(memory_sanitizer, LangOpts.Sanitize.has(SanitizerKind::Memory)) +FEATURE(memory_sanitizer, +LangOpts.Sanitize.hasOneOf(SanitizerKind::Memory | + SanitizerKind::KernelMemory)) FEATURE(thread_sanitizer, LangOpts.Sanitize.has(SanitizerKind::Thread)) FEATURE(dataflow_sanitizer, LangOpts.Sanitize.has(SanitizerKind::DataFlow)) FEATURE(efficiency_sanitizer, Modified: cfe/trunk/include/clang/Basic/Sanitizers.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=341641=341640=341641=diff == --- cfe/trunk/include/clang/Basic/Sanitizers.def (original) +++ cfe/trunk/include/clang/Basic/Sanitizers.def Fri Sep 7 02:21:09 2018 @@ -53,6 +53,9 @@ SANITIZER("kernel-hwaddress", KernelHWAd // MemorySanitizer SANITIZER("memory", Memory) +// Kernel MemorySanitizer (KMSAN) +SANITIZER("kernel-memory", KernelMemory) + // libFuzzer SANITIZER("fuzzer", Fuzzer) Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=341641=341640=341641=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Sep 7 02:21:09 2018 @@ -265,14 +265,15 @@ static void addKernelHWAddressSanitizerP /*CompileKernel*/ true, /*Recover*/ true)); } -static void addMemorySanitizerPass(const PassManagerBuilder , - legacy::PassManagerBase ) { +static void addGeneralOptsForMemorySanitizer(const PassManagerBuilder , + legacy::PassManagerBase , + bool CompileKernel) { const PassManagerBuilderWrapper = static_cast(Builder); const CodeGenOptions = BuilderWrapper.getCGOpts(); int TrackOrigins = CGOpts.SanitizeMemoryTrackOrigins; bool Recover = CGOpts.SanitizeRecover.has(SanitizerKind::Memory); - PM.add(createMemorySanitizerPass(TrackOrigins, Recover)); + PM.add(createMemorySanitizerPass(TrackOrigins, Recover, CompileKernel)); // MemorySanitizer inserts complex instrumentation that mostly follows // the logic of the original code, but operates on "shadow" values. @@ -287,6 +288,16 @@ static void addMemorySanitizerPass(const } } +static void addMemorySanitizerPass(const PassManagerBuilder , + legacy::PassManagerBase ) { + addGeneralOptsForMemorySanitizer(Builder, PM, /*CompileKernel*/ false); +} + +static void addKernelMemorySanitizerPass(const PassManagerBuilder , + legacy::PassManagerBase ) { + addGeneralOptsForMemorySanitizer(Builder, PM, /*CompileKernel*/ true); +} + static void addThreadSanitizerPass(const PassManagerBuilder , legacy::PassManagerBase ) { PM.add(createThreadSanitizerPass()); @@ -614,6 +625,13 @@ void EmitAssemblyHelper::CreatePasses(le addMemorySanitizerPass); } + if (LangOpts.Sanitize.has(SanitizerKind::KernelMemory)) { +PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast, +
[clang-tools-extra] r341639 - [clangd] NFC: Document URIDistance
Author: omtcyfz Date: Fri Sep 7 02:18:58 2018 New Revision: 341639 URL: http://llvm.org/viewvc/llvm-project?rev=341639=rev Log: [clangd] NFC: Document URIDistance `URIDistance` constructor should mention that `Sources` must contain *absolute paths*, not URIs. This is not very clear when looking at the interface, especially given that `distance(...)` accepts `URI`, not an absolute path which can give the wrong impression. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D51691 Modified: clang-tools-extra/trunk/clangd/FileDistance.h Modified: clang-tools-extra/trunk/clangd/FileDistance.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FileDistance.h?rev=341639=341638=341639=diff == --- clang-tools-extra/trunk/clangd/FileDistance.h (original) +++ clang-tools-extra/trunk/clangd/FileDistance.h Fri Sep 7 02:18:58 2018 @@ -89,6 +89,7 @@ private: // comparison on the bodies. class URIDistance { public: + // \p Sources must contain absolute paths, not URIs. URIDistance(llvm::StringMap Sources, const FileDistanceOptions = {}) : Sources(Sources), Opts(Opts) {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51539: [clangd] Add symbol slab size to index memory consumption estimates
kbobyrev updated this revision to Diff 164369. kbobyrev marked 9 inline comments as done. kbobyrev added a comment. Address a round of comments. https://reviews.llvm.org/D51539 Files: clang-tools-extra/clangd/index/FileIndex.cpp clang-tools-extra/clangd/index/Index.cpp clang-tools-extra/clangd/index/Index.h clang-tools-extra/clangd/index/MemIndex.cpp clang-tools-extra/clangd/index/MemIndex.h clang-tools-extra/clangd/index/dex/DexIndex.cpp clang-tools-extra/clangd/index/dex/DexIndex.h clang-tools-extra/unittests/clangd/IndexTests.cpp Index: clang-tools-extra/unittests/clangd/IndexTests.cpp === --- clang-tools-extra/unittests/clangd/IndexTests.cpp +++ clang-tools-extra/unittests/clangd/IndexTests.cpp @@ -10,11 +10,11 @@ #include "Annotations.h" #include "TestIndex.h" #include "TestTU.h" -#include "gmock/gmock.h" #include "index/FileIndex.h" #include "index/Index.h" #include "index/MemIndex.h" #include "index/Merge.h" +#include "gmock/gmock.h" #include "gtest/gtest.h" using testing::_; @@ -58,11 +58,11 @@ auto Token = std::make_shared(); std::weak_ptr WeakToken = Token; - SwapIndex S( - llvm::make_unique(SymbolSlab(), RefSlab(), std::move(Token))); - EXPECT_FALSE(WeakToken.expired()); // Current MemIndex keeps it alive. + SwapIndex S(llvm::make_unique( + SymbolSlab(), RefSlab(), std::move(Token), /*BackingDataSize=*/0)); + EXPECT_FALSE(WeakToken.expired()); // Current MemIndex keeps it alive. S.reset(llvm::make_unique()); // Now the MemIndex is destroyed. - EXPECT_TRUE(WeakToken.expired()); // So the token is too. + EXPECT_TRUE(WeakToken.expired()); // So the token is too. } TEST(MemIndexTest, MemIndexDeduplicate) { @@ -281,7 +281,7 @@ FileURI("unittest:///test2.cc")); } -MATCHER_P2(IncludeHeaderWithRef, IncludeHeader, References, "") { +MATCHER_P2(IncludeHeaderWithRef, IncludeHeader, References, "") { return (arg.IncludeHeader == IncludeHeader) && (arg.References == References); } Index: clang-tools-extra/clangd/index/dex/DexIndex.h === --- clang-tools-extra/clangd/index/dex/DexIndex.h +++ clang-tools-extra/clangd/index/dex/DexIndex.h @@ -55,17 +55,21 @@ } // Symbols are owned by BackingData, Index takes ownership. template - DexIndex(Range &, Payload &, + DexIndex(Range &, Payload &, size_t BackingDataSize, llvm::ArrayRef URISchemes) : DexIndex(std::forward(Symbols), URISchemes) { KeepAlive = std::shared_ptr( std::make_shared(std::move(BackingData)), nullptr); +this->BackingDataSize = BackingDataSize; } /// Builds an index from a slab. The index takes ownership of the slab. static std::unique_ptr build(SymbolSlab Slab, llvm::ArrayRef URISchemes) { -return llvm::make_unique(Slab, std::move(Slab), URISchemes); +// Store Slab size before it is moved. +const auto BackingDataSize = Slab.bytes(); +return llvm::make_unique(Slab, std::move(Slab), BackingDataSize, + URISchemes); } bool @@ -96,6 +100,8 @@ /// during the fuzzyFind process. llvm::DenseMap InvertedIndex; std::shared_ptr KeepAlive; // poor man's move-only std::any + // Size of memory retained by KeepAlive. + size_t BackingDataSize = 0; std::vector URISchemes; }; Index: clang-tools-extra/clangd/index/dex/DexIndex.cpp === --- clang-tools-extra/clangd/index/dex/DexIndex.cpp +++ clang-tools-extra/clangd/index/dex/DexIndex.cpp @@ -228,15 +228,13 @@ } size_t DexIndex::estimateMemoryUsage() const { - size_t Bytes = - LookupTable.size() * sizeof(std::pair); - Bytes += SymbolQuality.size() * sizeof(std::pair); - Bytes += InvertedIndex.size() * sizeof(Token); - - for (const auto : InvertedIndex) { + size_t Bytes = Symbols.size() * sizeof(const Symbol *); + Bytes += SymbolQuality.size() * sizeof(float); + Bytes += LookupTable.getMemorySize(); + Bytes += InvertedIndex.getMemorySize(); + for (const auto : InvertedIndex) Bytes += P.second.size() * sizeof(DocID); - } - return Bytes; + return Bytes + BackingDataSize; } std::vector generateProximityURIs(llvm::StringRef URIPath) { Index: clang-tools-extra/clangd/index/MemIndex.h === --- clang-tools-extra/clangd/index/MemIndex.h +++ clang-tools-extra/clangd/index/MemIndex.h @@ -30,11 +30,13 @@ } // Symbols are owned by BackingData, Index takes ownership. template - MemIndex(SymbolRange &, RefRange &, Payload &) + MemIndex(SymbolRange &, RefRange &, Payload &, + size_t BackingDataSize) : MemIndex(std::forward(Symbols), std::forward(Refs)) { KeepAlive = std::shared_ptr(
[PATCH] D51774: [clangd] NFC: Rename DexIndex to Dex
sammccall accepted this revision. sammccall added inline comments. This revision is now accepted and ready to land. Comment at: clang-tools-extra/clangd/index/dex/Dex.h:20 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_DEXINDEX_H #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_DEXINDEX_H update header guards https://reviews.llvm.org/D51774 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51539: [clangd] Add symbol slab size to index memory consumption estimates
ioeric added inline comments. Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:144 +size_t FileIndex::estimateMemoryUsage() const { + return FSymbols.estimateMemoryUsage(); +} sammccall wrote: > ioeric wrote: > > This can be a bit tricky. Generally, the size of a `FileIndex` is the size > > of FSymbols plus the overhead of the underlying index, but there can be > > multiple snapshots of symbols in `SwapIndex`. I think we can treat them as > > burst and only consider the size of the latest snapshot. > > > > `FSymbols` and the index have shared ownership to the symbol corpus. We can > > make either of them bookkeep the size, but I think it might be more > > straightforward to let the index "own" the size. You could set the payload > > size when creating the index, and you wouldn't need to expose > > `estimateMemoryUsage` from `FSymbols`. > (I had trouble parsing this at first - If I understand right, you want the > *memIndex* to own the size, and FileIndex to just inherit > SwapIndex::estimateMemoryUsage which delegates to > MemIndex::estimateMemoryUsage?) > > I like this idea, it's simpler and also means one less place you need to > lock, which is always nice. Yes, that's correct. Thanks for the clarification! https://reviews.llvm.org/D51539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51539: [clangd] Add symbol slab size to index memory consumption estimates
sammccall added a comment. LG with a few nits Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:121 +size_t FileSymbols::estimateMemoryUsage() const { + size_t Result = 0; + for (const auto : FileToSlabs) this isn't safe as it doesn't acquire the mutex Comment at: clang-tools-extra/clangd/index/FileIndex.cpp:144 +size_t FileIndex::estimateMemoryUsage() const { + return FSymbols.estimateMemoryUsage(); +} ioeric wrote: > This can be a bit tricky. Generally, the size of a `FileIndex` is the size of > FSymbols plus the overhead of the underlying index, but there can be multiple > snapshots of symbols in `SwapIndex`. I think we can treat them as burst and > only consider the size of the latest snapshot. > > `FSymbols` and the index have shared ownership to the symbol corpus. We can > make either of them bookkeep the size, but I think it might be more > straightforward to let the index "own" the size. You could set the payload > size when creating the index, and you wouldn't need to expose > `estimateMemoryUsage` from `FSymbols`. (I had trouble parsing this at first - If I understand right, you want the *memIndex* to own the size, and FileIndex to just inherit SwapIndex::estimateMemoryUsage which delegates to MemIndex::estimateMemoryUsage?) I like this idea, it's simpler and also means one less place you need to lock, which is always nice. Comment at: clang-tools-extra/clangd/index/MemIndex.h:32 + MemIndex(SymbolRange &, OccurrenceMap Occurrences, + size_t BackingMemory = 0) + : Occurrences(std::move(Occurrences)), BackingMemory(BackingMemory) { I don't think defaulting this parameter makes sense, seems like an easy source of bugs (and in 3 other cases) Comment at: clang-tools-extra/clangd/index/MemIndex.h:70 std::shared_ptr KeepAlive; // poor man's move-only std::any + /// When paired with the SymbolSlab, the index owns underlying SymbolSlab and + /// keeps it alive. BackingMemory is the only way to know the size of that just `// Size of memory retained by KeepAlive`? Don't mention Slab, this class doesn't know about it. (similar in Dex) https://reviews.llvm.org/D51539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51747: [clangd] Implement deprecation diagnostics with lower severity.
ioeric added inline comments. Comment at: clangd/Diagnostics.cpp:299 +D.Severity = +D.Category == "Deprecations" ? DiagnosticsEngine::Note : DiagLevel; return D; kadircet wrote: > Couldn't find a better way to check for this one. Category types are coming > from tablegen file > https://github.com/llvm-mirror/clang/blob/master/include/clang/Basic/DiagnosticGroups.td#L128 > which does not expose category id, at least I couldn't find even if it does. Have you tried the Diagnostic ID (i.e. `Info.getID()`)? It matches the diag kinds defined in `DiagnosticSemaKinds.inc` (e.g. `warn_deprecated`). Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D51747 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits