[PATCH] D37192: [clang-format] Add support for generic Obj-C categories
djasper accepted this revision. djasper added a comment. This revision is now accepted and ready to land. Looks good. Comment at: lib/Format/UnwrappedLineParser.cpp:2099 + // After a protocol list, we can have a category (Obj-C generic + // category). nit: Seems like this comment would fit on one line. https://reviews.llvm.org/D37192 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36336: [X86] Add support for __builtin_cpu_init
This revision was automatically updated to reflect the committed changes. Closed by commit rL311874: [X86] Add support for __builtin_cpu_init (authored by ctopper). Changed prior to commit: https://reviews.llvm.org/D36336?vs=109800&id=112851#toc Repository: rL LLVM https://reviews.llvm.org/D36336 Files: cfe/trunk/include/clang/Basic/BuiltinsX86.def cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/builtin-cpu-supports.c Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp === --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp @@ -7404,9 +7404,6 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E) { - if (BuiltinID == X86::BI__builtin_cpu_is) -return EmitX86CpuIs(*this, E); - SmallVector Ops; // Find out if any arguments are required to be integer constant expressions. @@ -7457,6 +7454,15 @@ switch (BuiltinID) { default: return nullptr; + case X86::BI__builtin_cpu_init: { +llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, + /*Variadic*/false); +llvm::Constant *Func = CGM.CreateRuntimeFunction(FTy, + "__cpu_indicator_init"); +return Builder.CreateCall(Func); + } + case X86::BI__builtin_cpu_is: +return EmitX86CpuIs(*this, E); case X86::BI__builtin_cpu_supports: { const Expr *FeatureExpr = E->getArg(0)->IgnoreParenCasts(); StringRef FeatureStr = cast(FeatureExpr)->getString(); Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def === --- cfe/trunk/include/clang/Basic/BuiltinsX86.def +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def @@ -32,6 +32,7 @@ // Miscellaneous builtin for checking x86 cpu features. // TODO: Make this somewhat generic so that other backends // can use it? +BUILTIN(__builtin_cpu_init, "v", "n") BUILTIN(__builtin_cpu_supports, "bcC*", "nc") BUILTIN(__builtin_cpu_is, "bcC*", "nc") Index: cfe/trunk/test/CodeGen/builtin-cpu-supports.c === --- cfe/trunk/test/CodeGen/builtin-cpu-supports.c +++ cfe/trunk/test/CodeGen/builtin-cpu-supports.c @@ -5,6 +5,10 @@ extern void a(const char *); int main() { + __builtin_cpu_init(); + + // CHECK: call void @__cpu_indicator_init + if (__builtin_cpu_supports("sse4.2")) a("sse4.2"); Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp === --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp @@ -7404,9 +7404,6 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E) { - if (BuiltinID == X86::BI__builtin_cpu_is) -return EmitX86CpuIs(*this, E); - SmallVector Ops; // Find out if any arguments are required to be integer constant expressions. @@ -7457,6 +7454,15 @@ switch (BuiltinID) { default: return nullptr; + case X86::BI__builtin_cpu_init: { +llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, + /*Variadic*/false); +llvm::Constant *Func = CGM.CreateRuntimeFunction(FTy, + "__cpu_indicator_init"); +return Builder.CreateCall(Func); + } + case X86::BI__builtin_cpu_is: +return EmitX86CpuIs(*this, E); case X86::BI__builtin_cpu_supports: { const Expr *FeatureExpr = E->getArg(0)->IgnoreParenCasts(); StringRef FeatureStr = cast(FeatureExpr)->getString(); Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def === --- cfe/trunk/include/clang/Basic/BuiltinsX86.def +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def @@ -32,6 +32,7 @@ // Miscellaneous builtin for checking x86 cpu features. // TODO: Make this somewhat generic so that other backends // can use it? +BUILTIN(__builtin_cpu_init, "v", "n") BUILTIN(__builtin_cpu_supports, "bcC*", "nc") BUILTIN(__builtin_cpu_is, "bcC*", "nc") Index: cfe/trunk/test/CodeGen/builtin-cpu-supports.c === --- cfe/trunk/test/CodeGen/builtin-cpu-supports.c +++ cfe/trunk/test/CodeGen/builtin-cpu-supports.c @@ -5,6 +5,10 @@ extern void a(const char *); int main() { + __builtin_cpu_init(); + + // CHECK: call void @__cpu_indicator_init + if (__builtin_cpu_supports("sse4.2")) a("sse4.2"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311874 - [X86] Add support for __builtin_cpu_init
Author: ctopper Date: Sun Aug 27 22:43:23 2017 New Revision: 311874 URL: http://llvm.org/viewvc/llvm-project?rev=311874&view=rev Log: [X86] Add support for __builtin_cpu_init This adds builtin_cpu_init which will emit a call to cpu_indicator_init in libgcc or compiler-rt. This is needed to support builtin_cpu_supports/builtin_cpu_is in an ifunc resolver. Differential Revision: https://reviews.llvm.org/D36336 Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/builtin-cpu-supports.c Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=311874&r1=311873&r2=311874&view=diff == --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sun Aug 27 22:43:23 2017 @@ -32,6 +32,7 @@ // Miscellaneous builtin for checking x86 cpu features. // TODO: Make this somewhat generic so that other backends // can use it? +BUILTIN(__builtin_cpu_init, "v", "n") BUILTIN(__builtin_cpu_supports, "bcC*", "nc") BUILTIN(__builtin_cpu_is, "bcC*", "nc") Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=311874&r1=311873&r2=311874&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sun Aug 27 22:43:23 2017 @@ -7404,9 +7404,6 @@ static Value *EmitX86CpuIs(CodeGenFuncti Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E) { - if (BuiltinID == X86::BI__builtin_cpu_is) -return EmitX86CpuIs(*this, E); - SmallVector Ops; // Find out if any arguments are required to be integer constant expressions. @@ -7457,6 +7454,15 @@ Value *CodeGenFunction::EmitX86BuiltinEx switch (BuiltinID) { default: return nullptr; + case X86::BI__builtin_cpu_init: { +llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, + /*Variadic*/false); +llvm::Constant *Func = CGM.CreateRuntimeFunction(FTy, + "__cpu_indicator_init"); +return Builder.CreateCall(Func); + } + case X86::BI__builtin_cpu_is: +return EmitX86CpuIs(*this, E); case X86::BI__builtin_cpu_supports: { const Expr *FeatureExpr = E->getArg(0)->IgnoreParenCasts(); StringRef FeatureStr = cast(FeatureExpr)->getString(); Modified: cfe/trunk/test/CodeGen/builtin-cpu-supports.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-cpu-supports.c?rev=311874&r1=311873&r2=311874&view=diff == --- cfe/trunk/test/CodeGen/builtin-cpu-supports.c (original) +++ cfe/trunk/test/CodeGen/builtin-cpu-supports.c Sun Aug 27 22:43:23 2017 @@ -5,6 +5,10 @@ extern void a(const char *); int main() { + __builtin_cpu_init(); + + // CHECK: call void @__cpu_indicator_init + if (__builtin_cpu_supports("sse4.2")) a("sse4.2"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36336: [X86] Add support for __builtin_cpu_init
echristo accepted this revision. echristo added a comment. This revision is now accepted and ready to land. One inline comment, but go ahead and commit after fixing that up. Comment at: lib/CodeGen/CGBuiltin.cpp:7292 const CallExpr *E) { + if (BuiltinID == X86::BI__builtin_cpu_init) { +llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, I realize it makes sense to put this here because it doesn't require the setup, but let's go ahead and just put it in the switch statement below. I don't think avoiding the bit of setup/etc below is worth the inconsistency. :) https://reviews.llvm.org/D36336 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32788: Fix std::inplace_merge to be stable for all inputs
mclow.lists added a comment. Note: I suspect that the proposed change to `` fixes the problem, but the new tests don't check that. https://reviews.llvm.org/D32788 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32788: Fix std::inplace_merge to be stable for all inputs
mclow.lists added a comment. I applied the test change, but not the algorithm change, and the tests passed. https://reviews.llvm.org/D32788 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas
rsmith added inline comments. Comment at: lib/Parse/ParseExprCXX.cpp:638 /// lambda-introducer lambda-declarator[opt] compound-statement +/// lambda-introducer lambda-declarator[opt] +/// compound-statement We generally put terminals in single quotes in these grammar excerpts: ``` lambda-introducer '<' template-parameter-list '>' lambda-declarator[opt] ``` Comment at: lib/Parse/ParseExprCXX.cpp:1126-1127 + diag::err_lambda_template_parameter_list_empty); +} +else { + Actions.ActOnLambdaExplicitTemplateParameterList( No linebreak between `}` and `else`. Comment at: lib/Sema/SemaLambda.cpp:495 + reinterpret_cast(TParams.begin()), + reinterpret_cast(TParams.end())); + LSI->NumExplicitTemplateParams = TParams.size(); hamzasood wrote: > faisalv wrote: > > ack - avoid reinterpret cast please - why not just stick to Decl* for > > TemplateParams for now - and add some fixme's that suggest we should > > consider refactoring ParseTemplateParameterList to accept a vector of > > nameddecls - and update this when that gets updated ? > > > > Perhaps add an assert here that iterates through and checks to make sure > > each item in this list is some form of a template parameter decl - within > > an #ifndef NDEBUG block (or your conversion check to NameDecl should > > suffice?) > Unfortunately `TemplateParameterList::Create` expects an array of > `NamedDecl`, so there’ll need to be a forced downcast somewhere. By getting > that over with as soon as possible, any errors will be caught straight away > by that assertion instead of moving the problem down the line somewhere and > making it more difficult to see where it went wrong. OK, but please cast them one by one rather than type-punning the array (which results in UB). Comment at: lib/Sema/SemaLambda.cpp:845-846 + ->getTemplateParamParent() != nullptr; + } + else { +KnownDependent = CurScope->getTemplateParamParent() != nullptr; No linebreak between `}` and `else`. Comment at: test/CXX/temp/temp.decls/temp.variadic/p4.cpp:216 +#if __cplusplus >= 201707L //- in a template parameter pack that is a pack expansion Please use `__cplusplus > 201703L` rather than a number that will become meaningless once we have a real value for C++2a. https://reviews.llvm.org/D36527 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311868 - Add test for -Wc++17-compat warning for P0683R1.
Author: rsmith Date: Sun Aug 27 17:31:35 2017 New Revision: 311868 URL: http://llvm.org/viewvc/llvm-project?rev=311868&view=rev Log: Add test for -Wc++17-compat warning for P0683R1. Modified: cfe/trunk/test/SemaCXX/cxx17-compat.cpp Modified: cfe/trunk/test/SemaCXX/cxx17-compat.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx17-compat.cpp?rev=311868&r1=311867&r2=311868&view=diff == --- cfe/trunk/test/SemaCXX/cxx17-compat.cpp (original) +++ cfe/trunk/test/SemaCXX/cxx17-compat.cpp Sun Aug 27 17:31:35 2017 @@ -19,4 +19,11 @@ struct B { // expected-warning@-4 {{explicit capture of 'this' with a capture default of '=' is incompatible with C++ standards before C++2a}} #endif } + + int n : 5 = 0; +#if __cplusplus <= 201703L +// expected-warning@-2 {{default member initializer for bit-field is a C++2a extension}} +#else +// expected-warning@-4 {{default member initializer for bit-field is incompatible with C++ standards before C++2a}} +#endif }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311867 - [c++2a] P0683R1: Permit default member initializers for bit-fields.
Author: rsmith Date: Sun Aug 27 17:28:14 2017 New Revision: 311867 URL: http://llvm.org/viewvc/llvm-project?rev=311867&view=rev Log: [c++2a] P0683R1: Permit default member initializers for bit-fields. This would be trivial, except that our in-memory and serialized representations for FieldDecls assumed that this can't happen. Added: cfe/trunk/test/PCH/cxx2a-bitfield-init.cpp cfe/trunk/test/Parser/cxx2a-bitfield-init.cpp Modified: cfe/trunk/include/clang/AST/Decl.h cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td cfe/trunk/lib/AST/Decl.cpp cfe/trunk/lib/Parse/ParseDeclCXX.cpp cfe/trunk/lib/Serialization/ASTReaderDecl.cpp cfe/trunk/lib/Serialization/ASTWriterDecl.cpp cfe/trunk/test/SemaCXX/member-init.cpp cfe/trunk/www/cxx_status.html Modified: cfe/trunk/include/clang/AST/Decl.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=311867&r1=311866&r2=311867&view=diff == --- cfe/trunk/include/clang/AST/Decl.h (original) +++ cfe/trunk/include/clang/AST/Decl.h Sun Aug 27 17:28:14 2017 @@ -2364,9 +2364,9 @@ public: /// FieldDecl - An instance of this class is created by Sema::ActOnField to /// represent a member of a struct/union/class. class FieldDecl : public DeclaratorDecl, public Mergeable { - // FIXME: This can be packed into the bitfields in Decl. + unsigned BitField : 1; unsigned Mutable : 1; - mutable unsigned CachedFieldIndex : 31; + mutable unsigned CachedFieldIndex : 30; /// The kinds of value we can store in InitializerOrBitWidth. /// @@ -2376,7 +2376,7 @@ class FieldDecl : public DeclaratorDecl, /// If the pointer is null, there's nothing special. Otherwise, /// this is a bitfield and the pointer is the Expr* storing the /// bit-width. -ISK_BitWidthOrNothing = (unsigned) ICIS_NoInit, +ISK_NoInit = (unsigned) ICIS_NoInit, /// The pointer is an (optional due to delayed parsing) Expr* /// holding the copy-initializer. @@ -2391,27 +2391,34 @@ class FieldDecl : public DeclaratorDecl, ISK_CapturedVLAType, }; - /// \brief Storage for either the bit-width, the in-class - /// initializer, or the captured variable length array bound. - /// - /// We can safely combine these because in-class initializers are - /// not permitted for bit-fields, and both are exclusive with VLA - /// captures. + /// If this is a bitfield with a default member initializer, this + /// structure is used to represent the two expressions. + struct InitAndBitWidth { +Expr *Init; +Expr *BitWidth; + }; + + /// \brief Storage for either the bit-width, the in-class initializer, or + /// both (via InitAndBitWidth), or the captured variable length array bound. /// /// If the storage kind is ISK_InClassCopyInit or /// ISK_InClassListInit, but the initializer is null, then this - /// field has an in-class initializer which has not yet been parsed + /// field has an in-class initializer that has not yet been parsed /// and attached. + // FIXME: Tail-allocate this to reduce the size of FieldDecl in the + // overwhelmingly common case that we have none of these things. llvm::PointerIntPair InitStorage; + protected: FieldDecl(Kind DK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle) : DeclaratorDecl(DK, DC, IdLoc, Id, T, TInfo, StartLoc), - Mutable(Mutable), CachedFieldIndex(0), - InitStorage(BW, (InitStorageKind) InitStyle) { -assert((!BW || InitStyle == ICIS_NoInit) && "got initializer for bitfield"); + BitField(false), Mutable(Mutable), CachedFieldIndex(0), + InitStorage(nullptr, (InitStorageKind) InitStyle) { +if (BW) + setBitWidth(BW); } public: @@ -2431,10 +2438,7 @@ public: bool isMutable() const { return Mutable; } /// \brief Determines whether this field is a bitfield. - bool isBitField() const { -return InitStorage.getInt() == ISK_BitWidthOrNothing && - InitStorage.getPointer() != nullptr; - } + bool isBitField() const { return BitField; } /// @brief Determines whether this is an unnamed bitfield. bool isUnnamedBitfield() const { return isBitField() && !getDeclName(); } @@ -2446,66 +2450,76 @@ public: bool isAnonymousStructOrUnion() const; Expr *getBitWidth() const { -return isBitField() - ? static_cast(InitStorage.getPointer()) - : nullptr; +if (!BitField) + return nullptr; +void *Ptr = InitStorage.getPointer(); +if (getInClassInitStyle()) + return static_cast(Ptr)->BitWidth; +return static_cast(Ptr); } unsigned getBitWidthValue(const ASTContext &Ctx) const; /// setBitWidth - Set the bit-field width for this member. // Note: used by some clients (i.e., do not remove it)
[PATCH] D37005: [clang-diff] Initial implementation of patching
johannes updated this revision to Diff 112845. johannes retitled this revision from "Add include/clang/Tooling/ASTDiff/ASTPatch.h" to "[clang-diff] Initial implementation of patching". johannes edited the summary of this revision. johannes added a comment. use rewriter to patch a third AST https://reviews.llvm.org/D37005 Files: include/clang/Tooling/ASTDiff/ASTDiff.h lib/Tooling/ASTDiff/ASTDiff.cpp lib/Tooling/ASTDiff/CMakeLists.txt tools/clang-diff/CMakeLists.txt tools/clang-diff/ClangDiff.cpp unittests/Tooling/ASTDiffTest.cpp unittests/Tooling/CMakeLists.txt Index: unittests/Tooling/CMakeLists.txt === --- unittests/Tooling/CMakeLists.txt +++ unittests/Tooling/CMakeLists.txt @@ -11,6 +11,7 @@ endif() add_clang_unittest(ToolingTests + ASTDiffTest.cpp ASTSelectionTest.cpp CastExprTest.cpp CommentHandlerTest.cpp @@ -43,4 +44,5 @@ clangTooling clangToolingCore clangToolingRefactor + clangToolingASTDiff ) Index: unittests/Tooling/ASTDiffTest.cpp === --- /dev/null +++ unittests/Tooling/ASTDiffTest.cpp @@ -0,0 +1,85 @@ +//===- unittest/Tooling/ASTDiffTest.cpp ---===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "clang/Tooling/ASTDiff/ASTDiff.h" +#include "clang/Tooling/Tooling.h" +#include "gtest/gtest.h" + +using namespace clang; +using namespace tooling; + +static std::string patchResult(std::array Codes) { + diff::SyntaxTree Trees[3]; + std::unique_ptr ASTs[3]; + std::vector Args = {}; + for (int I = 0; I < 3; I++) { +ASTs[I] = buildASTFromCode(Codes[I]); +if (!ASTs[I]) { + llvm::errs() << "Failed to build AST from code:\n" << Codes[I] << "\n"; + return ""; +} +Trees[I] = diff::SyntaxTree(*ASTs[I]); + } + + diff::ComparisonOptions Options; + std::string TargetDstCode; + llvm::raw_string_ostream OS(TargetDstCode); + if (!diff::patch(/*ModelSrc=*/Trees[0], /*ModelDst=*/Trees[1], + /*TargetSrc=*/Trees[2], Options, OS)) +return ""; + return OS.str(); +} + +// abstract the EXPECT_EQ call so that the code snippets align properly +// use macros for this to make test failures have proper line numbers +#define PATCH(Preamble, ModelSrc, ModelDst, Target, Expected) \ + EXPECT_EQ(patchResult({{std::string(Preamble) + ModelSrc,\ + std::string(Preamble) + ModelDst,\ + std::string(Preamble) + Target}}), \ +std::string(Preamble) + Expected) + +TEST(ASTDiff, TestDeleteArguments) { + PATCH(R"(void printf(const char *, ...);)", +R"(void foo(int x) { printf("%d", x, x); })", +R"(void foo(int x) { printf("%d", x); })", +R"(void foo(int x) { printf("different string %d", x, x); })", +R"(void foo(int x) { printf("different string %d", x); })"); + + PATCH(R"(void foo(...);)", +R"(void test1() { foo ( 1 + 1); })", +R"(void test1() { foo ( ); })", +R"(void test2() { foo ( 1 + 1 ); })", +R"(void test2() { foo ( ); })"); + + PATCH(R"(void foo(...);)", +R"(void test1() { foo (1, 2 + 2); })", +R"(void test1() { foo (2 + 2); })", +R"(void test2() { foo (/*L*/ 0 /*R*/ , 2 + 2); })", +R"(void test2() { foo (/*L*/ 2 + 2); })"); + + PATCH(R"(void foo(...);)", +R"(void test1() { foo (1, 2); })", +R"(void test1() { foo (1); })", +R"(void test2() { foo (0, /*L*/ 0 /*R*/); })", +R"(void test2() { foo (0 /*R*/); })"); +} + +TEST(ASTDiff, TestDeleteDecls) { + PATCH(R"()", +R"()", +R"()", +R"()", +R"()"); + + PATCH(R"()", +R"(void foo(){})", +R"()", +R"(int x; void foo() {;;} int y;)", +R"(int x; int y;)"); +} Index: tools/clang-diff/ClangDiff.cpp === --- tools/clang-diff/ClangDiff.cpp +++ tools/clang-diff/ClangDiff.cpp @@ -42,6 +42,12 @@ cl::desc("Output a side-by-side diff in HTML."), cl::init(false), cl::cat(ClangDiffCategory)); +static cl::opt +Patch("patch", + cl::desc("Try to apply the edit actions between the two input " + "files to the specified target."), + cl::desc(""), cl::cat(ClangDiffCategory)); + static cl::opt SourcePath(cl::Positional, cl::desc(""), cl::Required, cl::cat(ClangDiffCategory)); @@ -563,6 +569,16 @@ } diff::SyntaxTree SrcTree(*Src); diff::Syntax
[PATCH] D37201: [clang-diff] Use correct SourceRange for CXXConstructExpr
johannes created this revision. Herald added a subscriber: klimek. This way the variable name of a declaration is not included https://reviews.llvm.org/D37201 Files: test/Tooling/Inputs/clang-diff-basic-src.cpp test/Tooling/clang-diff-basic.cpp test/Tooling/clang-diff-html.test Index: test/Tooling/clang-diff-html.test === --- test/Tooling/clang-diff-html.test +++ test/Tooling/clang-diff-html.test @@ -26,6 +26,20 @@ update + move CHECK: 2' class='u m'>2 +VarDecl of same type but different variable name +ensure that only the latter is marked changed +CHECK: VarDecl: s +CHECK: TypeLoc: class T +CHECK-NEXT: T{{.*}}CXXConstructExpr +CHECK-NEXT: CXXConstructExpr +CHECK: s +CHECK: CXXTemporaryObjectExpr +CHECK-NEXT: CXXTemporaryObjectExpr +CHECK-NEXT: +CHECK-NEXT: TypeLoc: class S +CHECK-NEXT: S + + insertion CHECK: 2 +VarDecl of same type but different variable name +ensure that only the latter is marked changed +CHECK: VarDecl: s +CHECK: TypeLoc: class T +CHECK-NEXT: T{{.*}}CXXConstructExpr +CHECK-NEXT: CXXConstructExpr +CHECK: s +CHECK: CXXTemporaryObjectExpr +CHECK-NEXT: CXXTemporaryObjectExpr +CHECK-NEXT: +CHECK-NEXT: TypeLoc: class S +CHECK-NEXT: S + + insertion CHECK:
[PATCH] D37200: [AST] Traverse CXXOperatorCallExpr in LexicallyOrderedRecursiveASTVisitor
johannes created this revision. Herald added a subscriber: klimek. This affects overloaded operators, which are represented by a CXXOperatorCallExpr whose first child is always a DeclRefExpr referring to the operator. For infix, postfix and call operators we want the first argument to be traversed before the operator. https://reviews.llvm.org/D37200 Files: include/clang/AST/LexicallyOrderedRecursiveASTVisitor.h include/clang/AST/RecursiveASTVisitor.h unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp Index: unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp === --- unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp +++ unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp @@ -21,9 +21,10 @@ : public LexicallyOrderedRecursiveASTVisitor { public: LexicallyOrderedDeclVisitor(DummyMatchVisitor &Matcher, - const SourceManager &SM, bool EmitIndices) + const SourceManager &SM, bool EmitDeclIndices, + bool EmitStmtIndices) : LexicallyOrderedRecursiveASTVisitor(SM), Matcher(Matcher), -EmitIndices(EmitIndices) {} +EmitDeclIndices(EmitDeclIndices), EmitStmtIndices(EmitStmtIndices) {} bool TraverseDecl(Decl *D) { TraversalStack.push_back(D); @@ -33,28 +34,33 @@ } bool VisitNamedDecl(const NamedDecl *D); + bool VisitDeclRefExpr(const DeclRefExpr *D); private: DummyMatchVisitor &Matcher; - bool EmitIndices; + bool EmitDeclIndices, EmitStmtIndices; unsigned Index = 0; llvm::SmallVector TraversalStack; }; class DummyMatchVisitor : public ExpectedLocationVisitor { - bool EmitIndices; + bool EmitDeclIndices, EmitStmtIndices; public: - DummyMatchVisitor(bool EmitIndices = false) : EmitIndices(EmitIndices) {} + DummyMatchVisitor(bool EmitDeclIndices = false, bool EmitStmtIndices = false) + : EmitDeclIndices(EmitDeclIndices), EmitStmtIndices(EmitStmtIndices) {} bool VisitTranslationUnitDecl(TranslationUnitDecl *TU) { const ASTContext &Context = TU->getASTContext(); const SourceManager &SM = Context.getSourceManager(); -LexicallyOrderedDeclVisitor SubVisitor(*this, SM, EmitIndices); +LexicallyOrderedDeclVisitor SubVisitor(*this, SM, EmitDeclIndices, + EmitStmtIndices); SubVisitor.TraverseDecl(TU); return false; } - void match(StringRef Path, const Decl *D) { Match(Path, D->getLocStart()); } + template void match(StringRef Path, const T *D) { +Match(Path, D->getLocStart()); + } }; bool LexicallyOrderedDeclVisitor::VisitNamedDecl(const NamedDecl *D) { @@ -73,7 +79,16 @@ if (isa(D) or isa(D)) OS << "/"; } - if (EmitIndices) + if (EmitDeclIndices) +OS << "@" << Index++; + Matcher.match(OS.str(), D); + return true; +} + +bool LexicallyOrderedDeclVisitor::VisitDeclRefExpr(const DeclRefExpr *D) { + std::string Name = D->getFoundDecl()->getNameAsString(); + llvm::raw_string_ostream OS(Name); + if (EmitStmtIndices) OS << "@" << Index++; Matcher.match(OS.str(), D); return true; @@ -151,13 +166,50 @@ template T f(); template class Class {}; )"; - DummyMatchVisitor Visitor(/*EmitIndices=*/true); + DummyMatchVisitor Visitor(/*EmitDeclIndices=*/true); Visitor.ExpectMatch("/f/T@0", 2, 11); Visitor.ExpectMatch("/f/f/@1", 2, 20); Visitor.ExpectMatch("/Class/U@2", 3, 11); Visitor.ExpectMatch("/Class/@3", 3, 20); Visitor.ExpectMatch("/Class/Class/@4", 3, 34); EXPECT_TRUE(Visitor.runOver(Source)); } +TEST(LexicallyOrderedRecursiveASTVisitor, VisitCXXOperatorCallExpr) { + StringRef Source = R"( +struct S { + S &operator+(S&); + S *operator->(); + S &operator++(); + S operator++(int); + void operator()(int, int); + void operator[](int); + void f(); +}; +S a, b, c; + +void test() { + a = b + c; + a->f(); + a(1, 2); + b[0]; + ++a; + b++; +} +)"; + DummyMatchVisitor Visitor(/*EmitDeclIndices=*/false, +/*EmitStmtIndices=*/true); + Visitor.ExpectMatch("a@0", 14, 3); + Visitor.ExpectMatch("operator=@1", 14, 5); + Visitor.ExpectMatch("b@2", 14, 7); + Visitor.ExpectMatch("operator+@3", 14, 9); + Visitor.ExpectMatch("c@4", 14, 11); + Visitor.ExpectMatch("operator->@6", 15, 4); + Visitor.ExpectMatch("operator()@8", 16, 4); + Visitor.ExpectMatch("operator[]@10", 17, 4); + Visitor.ExpectMatch("operator++@11", 18, 3); + Visitor.ExpectMatch("operator++@14", 19, 4); + EXPECT_TRUE(Visitor.runOver(Source)); +} + } // end anonymous namespace Index: include/clang/AST/RecursiveASTVisitor.h === --- include/clang/AST/RecursiveASTVisitor.h +++ include/clang/AST/RecursiveASTVisitor.h @@ -3209,7 +3209,6 @@ #undef DEF_TRAVERSE_STMT #undef TRAVERSE_STMT -#undef TRAVERSE_STMT_BASE #undef TRY_TO Index: include/clang/AST/L
[PATCH] D37002: [clang-diff] Treat CXXCtorInitializer as a node
This revision was automatically updated to reflect the committed changes. Closed by commit rL311865: [clang-diff] Treat CXXCtorInitializer as a node (authored by krobelus). Changed prior to commit: https://reviews.llvm.org/D37002?vs=112134&id=112841#toc Repository: rL LLVM https://reviews.llvm.org/D37002 Files: cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp cfe/trunk/test/Tooling/clang-diff-ast.cpp Index: cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp === --- cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp +++ cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp @@ -111,6 +111,7 @@ /// Represents the AST of a TranslationUnit. class SyntaxTree::Impl { public: + Impl(SyntaxTree *Parent, ASTContext &AST); /// Constructs a tree from an AST node. Impl(SyntaxTree *Parent, Decl *N, ASTContext &AST); Impl(SyntaxTree *Parent, Stmt *N, ASTContext &AST); @@ -127,6 +128,7 @@ SyntaxTree *Parent; ASTContext &AST; + PrintingPolicy TypePP; /// Nodes in preorder. std::vector Nodes; std::vector Leaves; @@ -163,12 +165,15 @@ static bool isSpecializedNodeExcluded(const Decl *D) { return D->isImplicit(); } static bool isSpecializedNodeExcluded(const Stmt *S) { return false; } +static bool isSpecializedNodeExcluded(CXXCtorInitializer *I) { + return !I->isWritten(); +} template static bool isNodeExcluded(const SourceManager &SrcMgr, T *N) { if (!N) return true; - SourceLocation SLoc = N->getLocStart(); + SourceLocation SLoc = N->getSourceRange().getBegin(); if (SLoc.isValid()) { // Ignore everything from other files. if (!SrcMgr.isInMainFile(SLoc)) @@ -243,18 +248,31 @@ return true; } bool TraverseType(QualType T) { return true; } + bool TraverseConstructorInitializer(CXXCtorInitializer *Init) { +if (isNodeExcluded(Tree.AST.getSourceManager(), Init)) + return true; +auto SavedState = PreTraverse(Init); +RecursiveASTVisitor::TraverseConstructorInitializer(Init); +PostTraverse(SavedState); +return true; + } }; } // end anonymous namespace +SyntaxTree::Impl::Impl(SyntaxTree *Parent, ASTContext &AST) +: Parent(Parent), AST(AST), TypePP(AST.getLangOpts()) { + TypePP.AnonymousTagLocations = false; +} + SyntaxTree::Impl::Impl(SyntaxTree *Parent, Decl *N, ASTContext &AST) -: Parent(Parent), AST(AST) { +: Impl(Parent, AST) { PreorderVisitor PreorderWalker(*this); PreorderWalker.TraverseDecl(N); initTree(); } SyntaxTree::Impl::Impl(SyntaxTree *Parent, Stmt *N, ASTContext &AST) -: Parent(Parent), AST(AST) { +: Impl(Parent, AST) { PreorderVisitor PreorderWalker(*this); PreorderWalker.TraverseStmt(N); initTree(); @@ -377,6 +395,17 @@ return nullptr; } +static std::string getInitializerValue(const CXXCtorInitializer *Init, + const PrintingPolicy &TypePP) { + if (Init->isAnyMemberInitializer()) +return Init->getAnyMember()->getName(); + if (Init->isBaseInitializer()) +return QualType(Init->getBaseClass(), 0).getAsString(TypePP); + if (Init->isDelegatingInitializer()) +return Init->getTypeSourceInfo()->getType().getAsString(TypePP); + llvm_unreachable("Unknown initializer type"); +} + std::string SyntaxTree::Impl::getNodeValue(NodeId Id) const { return getNodeValue(getNode(Id)); } @@ -387,34 +416,15 @@ return getStmtValue(S); if (auto *D = DTN.get()) return getDeclValue(D); + if (auto *Init = DTN.get()) +return getInitializerValue(Init, TypePP); llvm_unreachable("Fatal: unhandled AST node.\n"); } std::string SyntaxTree::Impl::getDeclValue(const Decl *D) const { std::string Value; - PrintingPolicy TypePP(AST.getLangOpts()); - TypePP.AnonymousTagLocations = false; - - if (auto *V = dyn_cast(D)) { -Value += getRelativeName(V) + "(" + V->getType().getAsString(TypePP) + ")"; -if (auto *C = dyn_cast(D)) { - for (auto *Init : C->inits()) { -if (!Init->isWritten()) - continue; -if (Init->isBaseInitializer()) { - Value += Init->getBaseClass()->getCanonicalTypeInternal().getAsString( - TypePP); -} else if (Init->isDelegatingInitializer()) { - Value += C->getNameAsString(); -} else { - assert(Init->isAnyMemberInitializer()); - Value += getRelativeName(Init->getMember()); -} -Value += ","; - } -} -return Value; - } + if (auto *V = dyn_cast(D)) +return getRelativeName(V) + "(" + V->getType().getAsString(TypePP) + ")"; if (auto *N = dyn_cast(D)) Value += getRelativeName(N) + ";"; if (auto *T = dyn_cast(D)) Index: cfe/trunk/test/Tooling/clang-diff-ast.cpp === --- cfe/trunk/test/Tooling/clang-diff-ast.cpp +++ cfe/trunk/test/Tooling/clang-diff-ast.cpp @@ -54,14 +54,20 @@ // CHECK: AccessSpecDecl: public( public: int not_initialized; - // All initialized
r311865 - [clang-diff] Treat CXXCtorInitializer as a node
Author: krobelus Date: Sun Aug 27 15:52:20 2017 New Revision: 311865 URL: http://llvm.org/viewvc/llvm-project?rev=311865&view=rev Log: [clang-diff] Treat CXXCtorInitializer as a node Reviewers: arphaman Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D37002 Modified: cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp cfe/trunk/test/Tooling/clang-diff-ast.cpp Modified: cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp?rev=311865&r1=311864&r2=311865&view=diff == --- cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp (original) +++ cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp Sun Aug 27 15:52:20 2017 @@ -111,6 +111,7 @@ private: /// Represents the AST of a TranslationUnit. class SyntaxTree::Impl { public: + Impl(SyntaxTree *Parent, ASTContext &AST); /// Constructs a tree from an AST node. Impl(SyntaxTree *Parent, Decl *N, ASTContext &AST); Impl(SyntaxTree *Parent, Stmt *N, ASTContext &AST); @@ -127,6 +128,7 @@ public: SyntaxTree *Parent; ASTContext &AST; + PrintingPolicy TypePP; /// Nodes in preorder. std::vector Nodes; std::vector Leaves; @@ -163,12 +165,15 @@ private: static bool isSpecializedNodeExcluded(const Decl *D) { return D->isImplicit(); } static bool isSpecializedNodeExcluded(const Stmt *S) { return false; } +static bool isSpecializedNodeExcluded(CXXCtorInitializer *I) { + return !I->isWritten(); +} template static bool isNodeExcluded(const SourceManager &SrcMgr, T *N) { if (!N) return true; - SourceLocation SLoc = N->getLocStart(); + SourceLocation SLoc = N->getSourceRange().getBegin(); if (SLoc.isValid()) { // Ignore everything from other files. if (!SrcMgr.isInMainFile(SLoc)) @@ -243,18 +248,31 @@ struct PreorderVisitor : public Recursiv return true; } bool TraverseType(QualType T) { return true; } + bool TraverseConstructorInitializer(CXXCtorInitializer *Init) { +if (isNodeExcluded(Tree.AST.getSourceManager(), Init)) + return true; +auto SavedState = PreTraverse(Init); +RecursiveASTVisitor::TraverseConstructorInitializer(Init); +PostTraverse(SavedState); +return true; + } }; } // end anonymous namespace +SyntaxTree::Impl::Impl(SyntaxTree *Parent, ASTContext &AST) +: Parent(Parent), AST(AST), TypePP(AST.getLangOpts()) { + TypePP.AnonymousTagLocations = false; +} + SyntaxTree::Impl::Impl(SyntaxTree *Parent, Decl *N, ASTContext &AST) -: Parent(Parent), AST(AST) { +: Impl(Parent, AST) { PreorderVisitor PreorderWalker(*this); PreorderWalker.TraverseDecl(N); initTree(); } SyntaxTree::Impl::Impl(SyntaxTree *Parent, Stmt *N, ASTContext &AST) -: Parent(Parent), AST(AST) { +: Impl(Parent, AST) { PreorderVisitor PreorderWalker(*this); PreorderWalker.TraverseStmt(N); initTree(); @@ -377,6 +395,17 @@ static const DeclContext *getEnclosingDe return nullptr; } +static std::string getInitializerValue(const CXXCtorInitializer *Init, + const PrintingPolicy &TypePP) { + if (Init->isAnyMemberInitializer()) +return Init->getAnyMember()->getName(); + if (Init->isBaseInitializer()) +return QualType(Init->getBaseClass(), 0).getAsString(TypePP); + if (Init->isDelegatingInitializer()) +return Init->getTypeSourceInfo()->getType().getAsString(TypePP); + llvm_unreachable("Unknown initializer type"); +} + std::string SyntaxTree::Impl::getNodeValue(NodeId Id) const { return getNodeValue(getNode(Id)); } @@ -387,34 +416,15 @@ std::string SyntaxTree::Impl::getNodeVal return getStmtValue(S); if (auto *D = DTN.get()) return getDeclValue(D); + if (auto *Init = DTN.get()) +return getInitializerValue(Init, TypePP); llvm_unreachable("Fatal: unhandled AST node.\n"); } std::string SyntaxTree::Impl::getDeclValue(const Decl *D) const { std::string Value; - PrintingPolicy TypePP(AST.getLangOpts()); - TypePP.AnonymousTagLocations = false; - - if (auto *V = dyn_cast(D)) { -Value += getRelativeName(V) + "(" + V->getType().getAsString(TypePP) + ")"; -if (auto *C = dyn_cast(D)) { - for (auto *Init : C->inits()) { -if (!Init->isWritten()) - continue; -if (Init->isBaseInitializer()) { - Value += Init->getBaseClass()->getCanonicalTypeInternal().getAsString( - TypePP); -} else if (Init->isDelegatingInitializer()) { - Value += C->getNameAsString(); -} else { - assert(Init->isAnyMemberInitializer()); - Value += getRelativeName(Init->getMember()); -} -Value += ","; - } -} -return Value; - } + if (auto *V = dyn_cast(D)) +return getRelativeName(V) + "(" + V->getType().getAsString(TypePP) + ")"; if (auto *N = dyn_cast(D)) Value += getRelativeName(N) + ";"; if (auto *T = dyn_cast(D)) Modif
[PATCH] D37104: [libc++] PR34298: Change std::function constructor and move assignment operator SFINAE checks to allow std::function with an incomplete return type
EricWF added a comment. @arphaman Do you mind if I commit my own version of this? Repository: rL LLVM https://reviews.llvm.org/D37104 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)
mgorny reopened this revision. mgorny added a comment. This revision is now accepted and ready to land. I have reverted the changes for now to fix Android. Repository: rL LLVM https://reviews.llvm.org/D26796 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26764: [compiler-rt] [cmake] Remove i686 target that is duplicate to i386
mgorny reopened this revision. mgorny added a comment. This revision is now accepted and ready to land. I have reverted the changes for now to fix Android. Repository: rL LLVM https://reviews.llvm.org/D26764 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34912: Handle cases where the value is too large to fit into the underlying type.
rsmith added inline comments. Comment at: lib/AST/TemplateBase.cpp:64 } else { Out << Val; +// Handle cases where the value is too large to fit into the underlying type If `Val` is `LLONG_MIN`, this will still produce an integer too large for any signed type. Comment at: lib/AST/TemplateBase.cpp:68 +if (const BuiltinType *BT = T->getAs()) { + if (Val.isUnsigned() && Val.getBitWidth() == 64 && Val.isNegative()) +Out << "ull"; rsmith wrote: > This is not sufficient to ensure a correct round-trip in all cases; for > `template`, we would need the type of the template argument to exactly > match the type of the printed expression. But if you don't want to address > that case now, that's fine. We shouldn't be assuming that `long long` is exactly 64 bits here. Perhaps we could produce an `U`/`L`/`UL`/`LL`/`ULL` suffix based on the particular builtin type, regardless of the value itself? Comment at: lib/AST/TemplateBase.cpp:68-69 +if (const BuiltinType *BT = T->getAs()) { + if (Val.isUnsigned() && Val.getBitWidth() == 64 && Val.isNegative()) +Out << "ull"; +} This is not sufficient to ensure a correct round-trip in all cases; for `template`, we would need the type of the template argument to exactly match the type of the printed expression. But if you don't want to address that case now, that's fine. Comment at: lib/AST/TemplateBase.cpp:69 + if (Val.isUnsigned() && Val.getBitWidth() == 64 && Val.isNegative()) +Out << "ull"; +} This should be uppercase, to match how we pretty-print `IntegerLiteral`s. https://reviews.llvm.org/D34912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34992: Emit static constexpr member as available_externally definition
mehdi_amini added a comment. > I'd like to also see a testcase for the situation where we trigger the > emission of a declaration with an available_externally definition and then > find we need to promote it to a "full" definition: Added! Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2448-2451 +if (InitExpr) { + GV->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage); + GV->setInitializer(EmitConstantInit(*InitDecl)); +} rsmith wrote: > mehdi_amini wrote: > > rsmith wrote: > > > In order for this transformation to be correct, you need to know that the > > > variable has static initialization, which means that it needs to formally > > > have a constant initializer. You can use `D->isInitKnownICE()` to check > > > this. > > Done! But couldn't find how to express it as a test-case though. > You'd need to use an initializer that we can constant-fold, such as: > > ``` > struct A { > static const int n; > }; > bool check() { > assert(A::n == 0 && "already initialized!"); > return true; > } > const int A::n = (check() || true) ? 1 : 2; > ``` But this wouldn't be an "available_externally". We need the initializer in the class definition. I tried multiple variant but couldn't get one that compile: ``` struct B { static bool check() { if (B::n == 0) return false; return true; } // error: in-class initializer for static data member is not a constant expression static const int n = (B::check() || true) ? 1 : 2; }; ``` ``` struct B { static constexpr bool check() { // "error: constexpr function never produces a constant expression" return (B::n == 0 || true) ? false : true; } //"note: initializer of 'n' is not a constant expression" static constexpr int n = (B::check() || true) ? 1 : 2; }; ``` Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2445 +!D->hasDefinition() && D->hasInit() && +/* C++17 static constexpr are inlined */ !D->isInline() && +!D->hasAttr() && D->isInitKnownICE()) { rsmith wrote: > Do we need to special-case this? Such declarations are definitions. We don't! Simplified after rebasing and adapting after John's changes. Repository: rL LLVM https://reviews.llvm.org/D34992 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311861 - Revert r311836 - [Driver] Use arch type to find compiler-rt libraries (on Linux)
Author: mgorny Date: Sun Aug 27 13:38:43 2017 New Revision: 311861 URL: http://llvm.org/viewvc/llvm-project?rev=311861&view=rev Log: Revert r311836 - [Driver] Use arch type to find compiler-rt libraries (on Linux) This causes a breakage on the Android build bot. Let's revert it until we figure out the correct solution there. Removed: cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o Modified: cfe/trunk/lib/Driver/ToolChain.cpp cfe/trunk/test/Driver/linux-ld.c cfe/trunk/test/Driver/nostdlib.c cfe/trunk/test/Driver/print-libgcc-file-name-clangrt.c cfe/trunk/test/Driver/windows-cross.c Modified: cfe/trunk/lib/Driver/ToolChain.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=311861&r1=311860&r2=311861&view=diff == --- cfe/trunk/lib/Driver/ToolChain.cpp (original) +++ cfe/trunk/lib/Driver/ToolChain.cpp Sun Aug 27 13:38:43 2017 @@ -297,12 +297,15 @@ static StringRef getArchNameForCompilerR const llvm::Triple &Triple = TC.getTriple(); bool IsWindows = Triple.isOSWindows(); + if (Triple.isWindowsMSVCEnvironment() && TC.getArch() == llvm::Triple::x86) +return "i386"; + if (TC.getArch() == llvm::Triple::arm || TC.getArch() == llvm::Triple::armeb) return (arm::getARMFloatABI(TC, Args) == arm::FloatABI::Hard && !IsWindows) ? "armhf" : "arm"; - return llvm::Triple::getArchTypeName(TC.getArch()); + return TC.getArchName(); } std::string ToolChain::getCompilerRTPath() const { Removed: cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep?rev=311860&view=auto == (empty) Removed: cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o?rev=311860&view=auto == (empty) Modified: cfe/trunk/test/Driver/linux-ld.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-ld.c?rev=311861&r1=311860&r2=311861&view=diff == --- cfe/trunk/test/Driver/linux-ld.c (original) +++ cfe/trunk/test/Driver/linux-ld.c Sun Aug 27 13:38:43 2017 @@ -71,27 +71,6 @@ // CHECK-LD-RT: libclang_rt.builtins-x86_64.a" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ -// RUN: --target=i686-unknown-linux \ -// RUN: --gcc-toolchain="" \ -// RUN: --sysroot=%S/Inputs/basic_linux_tree \ -// RUN: --rtlib=compiler-rt \ -// RUN: | FileCheck --check-prefix=CHECK-LD-RT-I686 %s -// CHECK-LD-RT-I686-NOT: warning: -// CHECK-LD-RT-I686: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" -// CHECK-LD-RT-I686: "--eh-frame-hdr" -// CHECK-LD-RT-I686: "-m" "elf_i386" -// CHECK-LD-RT-I686: "-dynamic-linker" -// CHECK-LD-RT-I686: "{{.*}}/usr/lib/gcc/i686-unknown-linux/4.6.0{{/|}}crtbegin.o" -// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0" -// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../../../i686-unknown-linux/lib" -// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../.." -// CHECK-LD-RT-I686: "-L[[SYSROOT]]/lib" -// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib" -// CHECK-LD-RT-I686: libclang_rt.builtins-i386.a" -// CHECK-LD-RT-I686: "-lc" -// CHECK-LD-RT-I686: libclang_rt.builtins-i386.a" -// -// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: --target=arm-linux-androideabi \ // RUN: --gcc-toolchain="" \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ Modified: cfe/trunk/test/Driver/nostdlib.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/nostdlib.c?rev=311861&r1=311860&r2=311861&view=diff == --- cfe/trunk/test/Driver/nostdlib.c (original) +++ cfe/trunk/test/Driver/nostdlib.c Sun Aug 27 13:38:43 2017 @@ -27,5 +27,5 @@ // // CHECK-LINUX-NOSTDLIB: warning: argument unused during compilation: '--rtlib=compiler-rt' // CHECK-LINUX-NOSTDLIB: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-LINUX-NOSTDLIB-NOT: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.builtins-i386.a" +// CHECK-LINUX-NOSTDLIB-NOT: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}linux{{/|}}libclang_rt.builtins-i686.a" // CHECK-MSVC-NOSTDLIB: warning: argument unused during compilation: '--rtlib=compiler-rt' Modified: cfe/trunk
r311858 - CMake: only try to find the Z3 package when `CLANG_ANALYZER_BUILD_Z3` is ON
Author: mehdi_amini Date: Sun Aug 27 13:24:23 2017 New Revision: 311858 URL: http://llvm.org/viewvc/llvm-project?rev=311858&view=rev Log: CMake: only try to find the Z3 package when `CLANG_ANALYZER_BUILD_Z3` is ON This avoids the spurious message: Could NOT find Z3 (missing: Z3_LIBRARIES Z3_INCLUDE_DIR) (Required is at least version "4.5") Modified: cfe/trunk/CMakeLists.txt Modified: cfe/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=311858&r1=311857&r2=311858&view=diff == --- cfe/trunk/CMakeLists.txt (original) +++ cfe/trunk/CMakeLists.txt Sun Aug 27 13:24:23 2017 @@ -187,8 +187,6 @@ if (LIBXML2_FOUND) set(CLANG_HAVE_LIBXML 1) endif() -find_package(Z3 4.5) - include(CheckIncludeFile) check_include_file(sys/resource.h CLANG_HAVE_RLIMITS) @@ -384,6 +382,7 @@ if(NOT CLANG_ENABLE_STATIC_ANALYZER AND endif() if(CLANG_ANALYZER_BUILD_Z3) + find_package(Z3 4.5) if(Z3_FOUND) set(CLANG_ANALYZER_WITH_Z3 1) else() ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34992: Emit static constexpr member as available_externally definition
This revision was automatically updated to reflect the committed changes. Closed by commit rL311857: Emit static constexpr member as available_externally definition (authored by mehdi_amini). Changed prior to commit: https://reviews.llvm.org/D34992?vs=109694&id=112836#toc Repository: rL LLVM https://reviews.llvm.org/D34992 Files: cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp === --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp @@ -2437,6 +2437,28 @@ D->getType().isConstant(Context) && isExternallyVisible(D->getLinkageAndVisibility().getLinkage())) GV->setSection(".cp.rodata"); + +// Check if we a have a const declaration with an initializer, we may be +// able to emit it as available_externally to expose it's value to the +// optimizer. +if (Context.getLangOpts().CPlusPlus && GV->hasExternalLinkage() && +D->getType().isConstQualified() && !GV->hasInitializer() && +!D->hasDefinition() && D->hasInit() && !D->hasAttr()) { + const auto *Record = + Context.getBaseElementType(D->getType())->getAsCXXRecordDecl(); + bool HasMutableFields = Record && Record->hasMutableFields(); + if (!HasMutableFields) { +const VarDecl *InitDecl; +const Expr *InitExpr = D->getAnyInitializer(InitDecl); +if (InitExpr) { + GV->setConstant(true); + GV->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage); + ConstantEmitter emitter(*this); + GV->setInitializer(emitter.tryEmitForInitializer(*InitDecl)); + emitter.finalize(GV); +} + } +} } auto ExpectedAS = Index: cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp === --- cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp +++ cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp @@ -0,0 +1,55 @@ +// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK --check-prefix=CXX11 +// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK --check-prefix=CXX17 + +struct A { + static const int Foo = 123; +}; +// CHECK: @_ZN1A3FooE = constant i32 123, align 4 +const int *p = &A::Foo; // emit available_externally +const int A::Foo; // convert to full definition + +struct Bar { + int b; +}; + +struct MutableBar { + mutable int b; +}; + +struct Foo { + // CXX11: @_ZN3Foo21ConstexprStaticMemberE = available_externally constant i32 42, + // CXX17: @_ZN3Foo21ConstexprStaticMemberE = linkonce_odr constant i32 42, + static constexpr int ConstexprStaticMember = 42; + // CHECK: @_ZN3Foo17ConstStaticMemberE = available_externally constant i32 43, + static const int ConstStaticMember = 43; + + // CXX11: @_ZN3Foo23ConstStaticStructMemberE = available_externally constant %struct.Bar { i32 44 }, + // CXX17: @_ZN3Foo23ConstStaticStructMemberE = linkonce_odr constant %struct.Bar { i32 44 }, + static constexpr Bar ConstStaticStructMember = {44}; + + // CXX11: @_ZN3Foo34ConstexprStaticMutableStructMemberE = external global %struct.MutableBar, + // CXX17: @_ZN3Foo34ConstexprStaticMutableStructMemberE = linkonce_odr global %struct.MutableBar { i32 45 }, + static constexpr MutableBar ConstexprStaticMutableStructMember = {45}; +}; +// CHECK: @_ZL15ConstStaticexpr = internal constant i32 46, +static constexpr int ConstStaticexpr = 46; +// CHECK: @_ZL9ConstExpr = internal constant i32 46, align 4 +static const int ConstExpr = 46; + +// CHECK: @_ZL21ConstexprStaticStruct = internal constant %struct.Bar { i32 47 }, +static constexpr Bar ConstexprStaticStruct = {47}; + +// CHECK: @_ZL28ConstexprStaticMutableStruct = internal global %struct.MutableBar { i32 48 }, +static constexpr MutableBar ConstexprStaticMutableStruct = {48}; + +void use(const int &); +void foo() { + use(Foo::ConstexprStaticMember); + use(Foo::ConstStaticMember); + use(Foo::ConstStaticStructMember.b); + use(Foo::ConstexprStaticMutableStructMember.b); + use(ConstStaticexpr); + use(ConstExpr); + use(ConstexprStaticStruct.b); + use(ConstexprStaticMutableStruct.b); +} Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp === --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp @@ -2437,6 +2437,28 @@ D->getType().isConstant(Context) && isExternallyVisible(D->getLinkageAndVisibility().getLinkage())) GV->setSection(".cp.rodata"); + +// Check if we a have a const declaration with an initializer, we may be +// able to emit it as available_externally to expose it's value to the +// optimizer. +if (Context.getLangOpts().CPlusPlus && GV->hasExterna
r311857 - Emit static constexpr member as available_externally definition
Author: mehdi_amini Date: Sun Aug 27 13:24:09 2017 New Revision: 311857 URL: http://llvm.org/viewvc/llvm-project?rev=311857&view=rev Log: Emit static constexpr member as available_externally definition By exposing the constant initializer, the optimizer can fold many of these constructs. Differential Revision: https://reviews.llvm.org/D34992 Added: cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=311857&r1=311856&r2=311857&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sun Aug 27 13:24:09 2017 @@ -2437,6 +2437,28 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str D->getType().isConstant(Context) && isExternallyVisible(D->getLinkageAndVisibility().getLinkage())) GV->setSection(".cp.rodata"); + +// Check if we a have a const declaration with an initializer, we may be +// able to emit it as available_externally to expose it's value to the +// optimizer. +if (Context.getLangOpts().CPlusPlus && GV->hasExternalLinkage() && +D->getType().isConstQualified() && !GV->hasInitializer() && +!D->hasDefinition() && D->hasInit() && !D->hasAttr()) { + const auto *Record = + Context.getBaseElementType(D->getType())->getAsCXXRecordDecl(); + bool HasMutableFields = Record && Record->hasMutableFields(); + if (!HasMutableFields) { +const VarDecl *InitDecl; +const Expr *InitExpr = D->getAnyInitializer(InitDecl); +if (InitExpr) { + GV->setConstant(true); + GV->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage); + ConstantEmitter emitter(*this); + GV->setInitializer(emitter.tryEmitForInitializer(*InitDecl)); + emitter.finalize(GV); +} + } +} } auto ExpectedAS = Added: cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp?rev=311857&view=auto == --- cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp (added) +++ cfe/trunk/test/CodeGenCXX/cxx11-extern-constexpr.cpp Sun Aug 27 13:24:09 2017 @@ -0,0 +1,55 @@ +// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK --check-prefix=CXX11 +// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s --check-prefix=CHECK --check-prefix=CXX17 + +struct A { + static const int Foo = 123; +}; +// CHECK: @_ZN1A3FooE = constant i32 123, align 4 +const int *p = &A::Foo; // emit available_externally +const int A::Foo; // convert to full definition + +struct Bar { + int b; +}; + +struct MutableBar { + mutable int b; +}; + +struct Foo { + // CXX11: @_ZN3Foo21ConstexprStaticMemberE = available_externally constant i32 42, + // CXX17: @_ZN3Foo21ConstexprStaticMemberE = linkonce_odr constant i32 42, + static constexpr int ConstexprStaticMember = 42; + // CHECK: @_ZN3Foo17ConstStaticMemberE = available_externally constant i32 43, + static const int ConstStaticMember = 43; + + // CXX11: @_ZN3Foo23ConstStaticStructMemberE = available_externally constant %struct.Bar { i32 44 }, + // CXX17: @_ZN3Foo23ConstStaticStructMemberE = linkonce_odr constant %struct.Bar { i32 44 }, + static constexpr Bar ConstStaticStructMember = {44}; + + // CXX11: @_ZN3Foo34ConstexprStaticMutableStructMemberE = external global %struct.MutableBar, + // CXX17: @_ZN3Foo34ConstexprStaticMutableStructMemberE = linkonce_odr global %struct.MutableBar { i32 45 }, + static constexpr MutableBar ConstexprStaticMutableStructMember = {45}; +}; +// CHECK: @_ZL15ConstStaticexpr = internal constant i32 46, +static constexpr int ConstStaticexpr = 46; +// CHECK: @_ZL9ConstExpr = internal constant i32 46, align 4 +static const int ConstExpr = 46; + +// CHECK: @_ZL21ConstexprStaticStruct = internal constant %struct.Bar { i32 47 }, +static constexpr Bar ConstexprStaticStruct = {47}; + +// CHECK: @_ZL28ConstexprStaticMutableStruct = internal global %struct.MutableBar { i32 48 }, +static constexpr MutableBar ConstexprStaticMutableStruct = {48}; + +void use(const int &); +void foo() { + use(Foo::ConstexprStaticMember); + use(Foo::ConstStaticMember); + use(Foo::ConstStaticStructMember.b); + use(Foo::ConstexprStaticMutableStructMember.b); + use(ConstStaticexpr); + use(ConstExpr); + use(ConstexprStaticStruct.b); + use(ConstexprStaticMutableStruct.b); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34984: Store token literal data in PCH. Avoids disk read on PreProc expansion.
v.g.vassilev updated this revision to Diff 112835. v.g.vassilev added a comment. Add a test case. https://reviews.llvm.org/D34984 Files: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp test/PCH/token-literal-data.c Index: test/PCH/token-literal-data.c === --- test/PCH/token-literal-data.c +++ test/PCH/token-literal-data.c @@ -0,0 +1,11 @@ +// RUN: rm -fr %s_tmp.h.pch +// RUN: echo '#define MACRO 42' > %s_tmp.h +// RUN: %clang_cc1 -emit-pch -o %s_tmp.h.pch %s_tmp.h +// RUN: rm %s_tmp.h +// RUN: %clang_cc1 -fno-validate-pch -include-pch %s_tmp.h.pch -fsyntax-only -verify %s + +// expected-no-diagnostics + +int f(int x) { return x; } +void g1() { f(MACRO); } +void g2() { f(12); } Index: lib/Serialization/ASTWriter.cpp === --- lib/Serialization/ASTWriter.cpp +++ lib/Serialization/ASTWriter.cpp @@ -4364,6 +4364,8 @@ Record.push_back(Tok.getKind()); // FIXME: Should translate token flags to a stable encoding. Record.push_back(Tok.getFlags()); + if (Tok.isLiteral()) +AddString(StringRef(Tok.getLiteralData(), Tok.getLength()), Record); } void ASTWriter::AddString(StringRef Str, RecordDataImpl &Record) { Index: lib/Serialization/ASTReader.cpp === --- lib/Serialization/ASTReader.cpp +++ lib/Serialization/ASTReader.cpp @@ -1508,6 +1508,12 @@ Tok.setIdentifierInfo(II); Tok.setKind((tok::TokenKind)Record[Idx++]); Tok.setFlag((Token::TokenFlags)Record[Idx++]); + if (Tok.isLiteral()) { +const RecordData &RD = reinterpret_cast(Record); +std::string *Lit = new std::string(ReadString(RD, Idx)); +TokenLiteralDataLoaded.push_back(Lit); +Tok.setLiteralData(Lit->c_str()); + } return Tok; } @@ -10372,6 +10378,9 @@ ASTReader::~ASTReader() { if (OwnsDeserializationListener) delete DeserializationListener; + for (auto PStr : TokenLiteralDataLoaded) { +delete PStr; + } } IdentifierResolver &ASTReader::getIdResolver() { Index: include/clang/Serialization/ASTReader.h === --- include/clang/Serialization/ASTReader.h +++ include/clang/Serialization/ASTReader.h @@ -612,6 +612,9 @@ /// files. llvm::DenseSet LoadedUndefs; + /// \brief Token literal data loaded and owned by us. + std::vector TokenLiteralDataLoaded; + typedef ContinuousRangeMap GlobalMacroMapType; Index: test/PCH/token-literal-data.c === --- test/PCH/token-literal-data.c +++ test/PCH/token-literal-data.c @@ -0,0 +1,11 @@ +// RUN: rm -fr %s_tmp.h.pch +// RUN: echo '#define MACRO 42' > %s_tmp.h +// RUN: %clang_cc1 -emit-pch -o %s_tmp.h.pch %s_tmp.h +// RUN: rm %s_tmp.h +// RUN: %clang_cc1 -fno-validate-pch -include-pch %s_tmp.h.pch -fsyntax-only -verify %s + +// expected-no-diagnostics + +int f(int x) { return x; } +void g1() { f(MACRO); } +void g2() { f(12); } Index: lib/Serialization/ASTWriter.cpp === --- lib/Serialization/ASTWriter.cpp +++ lib/Serialization/ASTWriter.cpp @@ -4364,6 +4364,8 @@ Record.push_back(Tok.getKind()); // FIXME: Should translate token flags to a stable encoding. Record.push_back(Tok.getFlags()); + if (Tok.isLiteral()) +AddString(StringRef(Tok.getLiteralData(), Tok.getLength()), Record); } void ASTWriter::AddString(StringRef Str, RecordDataImpl &Record) { Index: lib/Serialization/ASTReader.cpp === --- lib/Serialization/ASTReader.cpp +++ lib/Serialization/ASTReader.cpp @@ -1508,6 +1508,12 @@ Tok.setIdentifierInfo(II); Tok.setKind((tok::TokenKind)Record[Idx++]); Tok.setFlag((Token::TokenFlags)Record[Idx++]); + if (Tok.isLiteral()) { +const RecordData &RD = reinterpret_cast(Record); +std::string *Lit = new std::string(ReadString(RD, Idx)); +TokenLiteralDataLoaded.push_back(Lit); +Tok.setLiteralData(Lit->c_str()); + } return Tok; } @@ -10372,6 +10378,9 @@ ASTReader::~ASTReader() { if (OwnsDeserializationListener) delete DeserializationListener; + for (auto PStr : TokenLiteralDataLoaded) { +delete PStr; + } } IdentifierResolver &ASTReader::getIdResolver() { Index: include/clang/Serialization/ASTReader.h === --- include/clang/Serialization/ASTReader.h +++ include/clang/Serialization/ASTReader.h @@ -612,6 +612,9 @@ /// files. llvm::DenseSet LoadedUndefs; + /// \brief Token literal data loaded and owned by us. + std::vector TokenLiteralDataLoaded; + typedef ContinuousRangeMap GlobalMacroMapType; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.
r311855 - revert changes from r311851.
Author: faisalv Date: Sun Aug 27 12:00:08 2017 New Revision: 311855 URL: http://llvm.org/viewvc/llvm-project?rev=311855&view=rev Log: revert changes from r311851. The right answers here (and how clang needs to be tweaked) require further analysis (ongoing cwg thread). sorry. Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp cfe/trunk/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=311855&r1=311854&r2=311855&view=diff == --- cfe/trunk/lib/Sema/SemaExprMember.cpp (original) +++ cfe/trunk/lib/Sema/SemaExprMember.cpp Sun Aug 27 12:00:08 2017 @@ -102,15 +102,15 @@ static IMAKind ClassifyImplicitMemberAcc bool hasNonInstance = false; bool isField = false; BaseSet Classes; - for (const NamedDecl *const D : R) { + for (NamedDecl *D : R) { +// Look through any using decls. +D = D->getUnderlyingDecl(); + if (D->isCXXInstanceMember()) { - // Look through any using decls. - const NamedDecl *const UnderlyingDecl = D->getUnderlyingDecl(); - isField |= isa(UnderlyingDecl) || - isa(UnderlyingDecl) || - isa(UnderlyingDecl); + isField |= isa(D) || isa(D) || + isa(D); - const CXXRecordDecl *R = cast(D->getDeclContext()); + CXXRecordDecl *R = cast(D->getDeclContext()); Classes.insert(R->getCanonicalDecl()); } else hasNonInstance = true; Modified: cfe/trunk/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp?rev=311855&r1=311854&r2=311855&view=diff == --- cfe/trunk/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp (original) +++ cfe/trunk/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp Sun Aug 27 12:00:08 2017 @@ -64,26 +64,17 @@ namespace test2 { template struct A { void foo(); -void foo2(); -static void static_foo(); -static void static_foo2(); - + void test0() { Unrelated::foo(); // expected-error {{call to non-static member function without an object argument}} } void test1() { B::foo(); - B::foo2(); // expected-error {{call to non-static member function without an object argument}} - B::static_foo(); - B::static_foo2(); } static void test2() { B::foo(); // expected-error {{call to non-static member function without an object argument}} - B::foo2(); // expected-error {{call to non-static member function without an object argument}} - B::static_foo(); - B::static_foo2(); } void test3() { @@ -92,17 +83,15 @@ namespace test2 { }; template struct B : A { -using A::foo2; -using A::static_foo2; }; - + template struct C { }; int test() { A a; a.test0(); // no instantiation note here, decl is ill-formed -a.test1(); // expected-note {{in instantiation}} +a.test1(); a.test2(); // expected-note {{in instantiation}} a.test3(); // expected-note {{in instantiation}} } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D22638: Module: add debug_type to dump debugging messages related to modules being out of date
v.g.vassilev added a comment. @bruno, what's the fate of this? https://reviews.llvm.org/D22638 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34912: Handle cases where the value is too large to fit into the underlying type.
v.g.vassilev added a comment. @rsmith ping... https://reviews.llvm.org/D34912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34912: Handle cases where the value is too large to fit into the underlying type.
v.g.vassilev added a comment. Sorry, undo ping... we have a test case. https://reviews.llvm.org/D34912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34912: Handle cases where the value is too large to fit into the underlying type.
v.g.vassilev added a comment. ping... https://reviews.llvm.org/D34912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311854 - Fix two typos in the doc. Patch by kamleshbhalui on github
Author: sylvestre Date: Sun Aug 27 10:34:06 2017 New Revision: 311854 URL: http://llvm.org/viewvc/llvm-project?rev=311854&view=rev Log: Fix two typos in the doc. Patch by kamleshbhalui on github Modified: cfe/trunk/docs/UsersManual.rst Modified: cfe/trunk/docs/UsersManual.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=311854&r1=311853&r2=311854&view=diff == --- cfe/trunk/docs/UsersManual.rst (original) +++ cfe/trunk/docs/UsersManual.rst Sun Aug 27 10:34:06 2017 @@ -1438,7 +1438,7 @@ Sample Profile Text Format This section describes the ASCII text format for sampling profiles. It is, arguably, the easiest one to generate. If you are interested in generating any -of the other two, consult the ``ProfileData`` library in in LLVM's source tree +of the other two, consult the ``ProfileData`` library in LLVM's source tree (specifically, ``include/llvm/ProfileData/SampleProfReader.h``). .. code-block:: console @@ -1454,7 +1454,7 @@ of the other two, consult the ``ProfileD offsetB[.discriminator]: fnB:num_of_total_samples offsetB1[.discriminator]: number_of_samples [fn11:num fn12:num ... ] -This is a nested tree in which the identation represents the nesting level +This is a nested tree in which the indentation represents the nesting level of the inline stack. There are no blank lines in the file. And the spacing within a single line is fixed. Additional spaces will result in an error while reading the file. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311851 - Don't see through 'using member-declarations' when determining the relation of any potential implicit object expression to the parent class of the member function containing the function cal
Author: faisalv Date: Sun Aug 27 09:49:47 2017 New Revision: 311851 URL: http://llvm.org/viewvc/llvm-project?rev=311851&view=rev Log: Don't see through 'using member-declarations' when determining the relation of any potential implicit object expression to the parent class of the member function containing the function call. Prior to this patch clang would not error here: template struct B; template struct A { void foo(); void foo2(); void test1() { B::foo(); // OK, foo is declared in A - matches type of 'this'. B::foo2(); // This should be an error! // foo2 is found in B, 'base unrelated' to 'this'. } }; template struct B : A { using A::foo2; }; Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp cfe/trunk/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=311851&r1=311850&r2=311851&view=diff == --- cfe/trunk/lib/Sema/SemaExprMember.cpp (original) +++ cfe/trunk/lib/Sema/SemaExprMember.cpp Sun Aug 27 09:49:47 2017 @@ -102,15 +102,15 @@ static IMAKind ClassifyImplicitMemberAcc bool hasNonInstance = false; bool isField = false; BaseSet Classes; - for (NamedDecl *D : R) { -// Look through any using decls. -D = D->getUnderlyingDecl(); - + for (const NamedDecl *const D : R) { if (D->isCXXInstanceMember()) { - isField |= isa(D) || isa(D) || - isa(D); + // Look through any using decls. + const NamedDecl *const UnderlyingDecl = D->getUnderlyingDecl(); + isField |= isa(UnderlyingDecl) || + isa(UnderlyingDecl) || + isa(UnderlyingDecl); - CXXRecordDecl *R = cast(D->getDeclContext()); + const CXXRecordDecl *R = cast(D->getDeclContext()); Classes.insert(R->getCanonicalDecl()); } else hasNonInstance = true; Modified: cfe/trunk/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp?rev=311851&r1=311850&r2=311851&view=diff == --- cfe/trunk/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp (original) +++ cfe/trunk/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp Sun Aug 27 09:49:47 2017 @@ -64,17 +64,26 @@ namespace test2 { template struct A { void foo(); - +void foo2(); +static void static_foo(); +static void static_foo2(); + void test0() { Unrelated::foo(); // expected-error {{call to non-static member function without an object argument}} } void test1() { B::foo(); + B::foo2(); // expected-error {{call to non-static member function without an object argument}} + B::static_foo(); + B::static_foo2(); } static void test2() { B::foo(); // expected-error {{call to non-static member function without an object argument}} + B::foo2(); // expected-error {{call to non-static member function without an object argument}} + B::static_foo(); + B::static_foo2(); } void test3() { @@ -83,15 +92,17 @@ namespace test2 { }; template struct B : A { +using A::foo2; +using A::static_foo2; }; - + template struct C { }; int test() { A a; a.test0(); // no instantiation note here, decl is ill-formed -a.test1(); +a.test1(); // expected-note {{in instantiation}} a.test2(); // expected-note {{in instantiation}} a.test3(); // expected-note {{in instantiation}} } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37196: [Clang] Bug 32352 - Provide a way for OptimizationRemarkEmitter::allowExtraAnalysis to check if (specific) remarks are enabled
vivekvpandya created this revision. Herald added a subscriber: fhahn. Clang changes related to Bug 32352 - Provide a way for OptimizationRemarkEmitter::allowExtraAnalysis to check if (specific) remarks are enabled https://reviews.llvm.org/D37196 Files: lib/CodeGen/CodeGenAction.cpp Index: lib/CodeGen/CodeGenAction.cpp === --- lib/CodeGen/CodeGenAction.cpp +++ lib/CodeGen/CodeGenAction.cpp @@ -224,10 +224,10 @@ void *OldContext = Ctx.getInlineAsmDiagnosticContext(); Ctx.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, this); - LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler = - Ctx.getDiagnosticHandler(); - void *OldDiagnosticContext = Ctx.getDiagnosticContext(); - Ctx.setDiagnosticHandler(DiagnosticHandler, this); + //LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler = + //Ctx.getDiagnosticHandler(); + // void *OldDiagnosticContext = Ctx.getDiagnosticContext(); + // Ctx.setDiagnosticHandler(DiagnosticHandler, this); Ctx.setDiagnosticsHotnessRequested(CodeGenOpts.DiagnosticsWithHotness); if (CodeGenOpts.DiagnosticsHotnessThreshold != 0) Ctx.setDiagnosticsHotnessThreshold( @@ -264,7 +264,7 @@ Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext); - Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext); + //Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext); if (OptRecordFile) OptRecordFile->keep(); @@ -756,6 +756,30 @@ } #undef ComputeDiagID +class ClangDiagnosticHandler final : public DiagnosticHandler { + public: + ClangDiagnosticHandler(const CodeGenOptions &CGOpts) : CodeGenOpts(CGOpts) { + } + bool handleDiagnostics(const DiagnosticInfo &DI, void *Context) { +((BackendConsumer *)Context)->DiagnosticHandlerImpl(DI); +return true; + } + bool isAnalysisRemarkEnable(const std::string &PassName) { + return (CodeGenOpts.OptimizationRemarkAnalysisPattern +&& CodeGenOpts.OptimizationRemarkAnalysisPattern->match(PassName)); + } + bool isMissedOptRemarkEnable(const std::string &PassName) { +return (CodeGenOpts.OptimizationRemarkMissedPattern +&& CodeGenOpts.OptimizationRemarkMissedPattern->match(PassName)); + } + bool isPassedOptRemarkEnable(const std::string &PassName) { +return (CodeGenOpts.OptimizationRemarkPattern +&& CodeGenOpts.OptimizationRemarkPattern->match(PassName)); + } + private: +const CodeGenOptions &CodeGenOpts; +}; + CodeGenAction::CodeGenAction(unsigned _Act, LLVMContext *_VMContext) : Act(_Act), VMContext(_VMContext ? _VMContext : new LLVMContext), OwnsVMContext(!_VMContext) {} @@ -853,7 +877,7 @@ CI.getLangOpts(), CI.getFrontendOpts().ShowTimers, InFile, std::move(LinkModules), std::move(OS), *VMContext, CoverageInfo)); BEConsumer = Result.get(); - + VMContext->setDiagnosticHandler(llvm::make_unique(CI.getCodeGenOpts()), Result.get()); // Enable generating macro debug info only when debug info is not disabled and // also macro debug info is enabled. if (CI.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo && Index: lib/CodeGen/CodeGenAction.cpp === --- lib/CodeGen/CodeGenAction.cpp +++ lib/CodeGen/CodeGenAction.cpp @@ -224,10 +224,10 @@ void *OldContext = Ctx.getInlineAsmDiagnosticContext(); Ctx.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, this); - LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler = - Ctx.getDiagnosticHandler(); - void *OldDiagnosticContext = Ctx.getDiagnosticContext(); - Ctx.setDiagnosticHandler(DiagnosticHandler, this); + //LLVMContext::DiagnosticHandlerTy OldDiagnosticHandler = + //Ctx.getDiagnosticHandler(); + // void *OldDiagnosticContext = Ctx.getDiagnosticContext(); + // Ctx.setDiagnosticHandler(DiagnosticHandler, this); Ctx.setDiagnosticsHotnessRequested(CodeGenOpts.DiagnosticsWithHotness); if (CodeGenOpts.DiagnosticsHotnessThreshold != 0) Ctx.setDiagnosticsHotnessThreshold( @@ -264,7 +264,7 @@ Ctx.setInlineAsmDiagnosticHandler(OldHandler, OldContext); - Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext); + //Ctx.setDiagnosticHandler(OldDiagnosticHandler, OldDiagnosticContext); if (OptRecordFile) OptRecordFile->keep(); @@ -756,6 +756,30 @@ } #undef ComputeDiagID +class ClangDiagnosticHandler final : public DiagnosticHandler { + public: + ClangDiagnosticHandler(const CodeGenOptions &CGOpts) : CodeGenOpts(CGOpts) { + } + bool handleDiagnostics(const DiagnosticInfo &DI, void *Context) { +((BackendConsumer *)Context)->DiagnosticHandlerImpl(DI); +return true; + } + bool isAnalysisRemarkEnable(const std::string &PassName) { + return (CodeGenOpts.Optimization
[PATCH] D37180: [modules] Add test for using declaration in classes.
v.g.vassilev accepted this revision. v.g.vassilev added a comment. This revision is now accepted and ready to land. LGTM! I'd reword the commit message, saying that we intended to add a fast path in `DeclContext::removeDecl` which checks if the decl is hidden to avoid addition in the lookup tables. That caused problems with modules, because the modules system extends the definition of visibility and this is a test making sure we do not reintroduce such an issue. Repository: rL LLVM https://reviews.llvm.org/D37180 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37103: [StaticAnalyzer] LoopUnrolling fixes
szepet updated this revision to Diff 112824. szepet added a comment. Update based on comments. https://reviews.llvm.org/D37103 Files: lib/StaticAnalyzer/Core/AnalysisManager.cpp lib/StaticAnalyzer/Core/ExprEngine.cpp lib/StaticAnalyzer/Core/LoopUnrolling.cpp test/Analysis/loop-unrolling.cpp Index: test/Analysis/loop-unrolling.cpp === --- test/Analysis/loop-unrolling.cpp +++ test/Analysis/loop-unrolling.cpp @@ -272,3 +272,10 @@ int a = 22 / k; return 0; } + +int loop_exit_while_empty_loop_stack() { + if (getNum()) +for (int i = 1; i < 8; i++) + ; + return 0; +} Index: lib/StaticAnalyzer/Core/LoopUnrolling.cpp === --- lib/StaticAnalyzer/Core/LoopUnrolling.cpp +++ lib/StaticAnalyzer/Core/LoopUnrolling.cpp @@ -13,15 +13,11 @@ /// //===--===// -#include "clang/Analysis/CFGStmtMap.h" #include "clang/ASTMatchers/ASTMatchers.h" #include "clang/ASTMatchers/ASTMatchFinder.h" -#include "clang/AST/ParentMap.h" -#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" #include "clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h" -#include "llvm/ADT/Statistic.h" using namespace clang; using namespace ento; @@ -72,11 +68,8 @@ ProgramStateRef processLoopEnd(const Stmt *LoopStmt, ProgramStateRef State) { auto LS = State->get(); - assert(!LS.isEmpty() && "Loop not added to the stack."); - assert(LoopStmt == LS.getHead().getLoopStmt() && - "Loop is not on top of the stack."); - - State = State->set(LS.getTail()); + if (!LS.isEmpty() && LS.getHead().getLoopStmt() == LoopStmt) +State = State->set(LS.getTail()); return State; } Index: lib/StaticAnalyzer/Core/ExprEngine.cpp === --- lib/StaticAnalyzer/Core/ExprEngine.cpp +++ lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1527,8 +1527,11 @@ if (Term) { ProgramStateRef NewState = updateLoopStack(Term, AMgr.getASTContext(), Pred); - if (NewState != Pred->getState()){ -Pred = nodeBuilder.generateNode(NewState, Pred); + if (NewState != Pred->getState()) { +ExplodedNode *UpdatedNode = nodeBuilder.generateNode(NewState, Pred); +if (!UpdatedNode) + return; +Pred = UpdatedNode; } } // Is we are inside an unrolled loop then no need the check the counters. Index: lib/StaticAnalyzer/Core/AnalysisManager.cpp === --- lib/StaticAnalyzer/Core/AnalysisManager.cpp +++ lib/StaticAnalyzer/Core/AnalysisManager.cpp @@ -27,7 +27,9 @@ /*AddInitializers=*/true, Options.includeTemporaryDtorsInCFG(), Options.includeLifetimeInCFG(), - Options.includeLoopExitInCFG(), + // Adding LoopExit elements to the CFG is a requirement for loop + // unrolling. + Options.includeLoopExitInCFG() || Options.shouldUnrollLoops(), Options.shouldSynthesizeBodies(), Options.shouldConditionalizeStaticInitializers(), /*addCXXNewAllocator=*/true, Index: test/Analysis/loop-unrolling.cpp === --- test/Analysis/loop-unrolling.cpp +++ test/Analysis/loop-unrolling.cpp @@ -272,3 +272,10 @@ int a = 22 / k; return 0; } + +int loop_exit_while_empty_loop_stack() { + if (getNum()) +for (int i = 1; i < 8; i++) + ; + return 0; +} Index: lib/StaticAnalyzer/Core/LoopUnrolling.cpp === --- lib/StaticAnalyzer/Core/LoopUnrolling.cpp +++ lib/StaticAnalyzer/Core/LoopUnrolling.cpp @@ -13,15 +13,11 @@ /// //===--===// -#include "clang/Analysis/CFGStmtMap.h" #include "clang/ASTMatchers/ASTMatchers.h" #include "clang/ASTMatchers/ASTMatchFinder.h" -#include "clang/AST/ParentMap.h" -#include "clang/AST/StmtVisitor.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" #include "clang/StaticAnalyzer/Core/PathSensitive/LoopUnrolling.h" -#include "llvm/ADT/Statistic.h" using namespace clang; using namespace ento; @@ -72,11 +68,8 @@ ProgramStateRef processLoopEnd(const Stmt *LoopStmt, ProgramStateRef State) { auto LS = State->get(); - assert(!LS.isEmpty() && "Loop not added to the stack."); - assert(LoopStmt == LS.getHead().getLoopStmt() && - "Loop is not on top of the stack."); - - State = State->set(LS.getTail()); + if (!LS.isEmpty() && LS.getHead().getLoopStmt() == LoopS
[PATCH] D37192: [clang-format] Add support for generic Obj-C categories
danielmartin created this revision. Herald added a subscriber: klimek. Objective C supports lightweight generics in categories. This patch adds support for that in clang-format. https://reviews.llvm.org/D37192 Files: lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTestObjC.cpp Index: unittests/Format/FormatTestObjC.cpp === --- unittests/Format/FormatTestObjC.cpp +++ unittests/Format/FormatTestObjC.cpp @@ -821,6 +821,13 @@ " NSBundle.mainBundle.infoDictionary[@\"a\"]\n" "]];"); } + +TEST_F(FormatTestObjC, FormatGenericObjCCategory) { + verifyFormat( + "@interface NSHashTable (MYFoundation)\n" + "- (void)xyz_addObjectsFromArray:(nonnull NSArray *)array;\n" + "@end"); +} } // end namespace } // end namespace format } // end namespace clang Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -2096,6 +2096,11 @@ if (FormatTok->Tok.is(tok::less)) parseObjCProtocolList(); + // After a protocol list, we can have a category (Obj-C generic + // category). + if (FormatTok->Tok.is(tok::l_paren)) +parseParens(); + if (FormatTok->Tok.is(tok::l_brace)) { if (Style.BraceWrapping.AfterObjCDeclaration) addUnwrappedLine(); Index: unittests/Format/FormatTestObjC.cpp === --- unittests/Format/FormatTestObjC.cpp +++ unittests/Format/FormatTestObjC.cpp @@ -821,6 +821,13 @@ " NSBundle.mainBundle.infoDictionary[@\"a\"]\n" "]];"); } + +TEST_F(FormatTestObjC, FormatGenericObjCCategory) { + verifyFormat( + "@interface NSHashTable (MYFoundation)\n" + "- (void)xyz_addObjectsFromArray:(nonnull NSArray *)array;\n" + "@end"); +} } // end namespace } // end namespace format } // end namespace clang Index: lib/Format/UnwrappedLineParser.cpp === --- lib/Format/UnwrappedLineParser.cpp +++ lib/Format/UnwrappedLineParser.cpp @@ -2096,6 +2096,11 @@ if (FormatTok->Tok.is(tok::less)) parseObjCProtocolList(); + // After a protocol list, we can have a category (Obj-C generic + // category). + if (FormatTok->Tok.is(tok::l_paren)) +parseParens(); + if (FormatTok->Tok.is(tok::l_brace)) { if (Style.BraceWrapping.AfterObjCDeclaration) addUnwrappedLine(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37101: [clangd] [WIP] Add support for snippet completions
rwols added a comment. After digging into VSCode, I now think that presenting snippets is the wrong way forward, and I believe the right way is to implement the `signatureHelpProvider` protocol for method/function parameters. See: https://github.com/Microsoft/vscode-docs/blob/master/docs/extensionAPI/language-support.md#help-with-function-and-method-signatures. I'll update this diff accordingly. https://reviews.llvm.org/D37101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311846 - ClangCodeGenTests: Update libdeps.
Author: chapuni Date: Sun Aug 27 04:46:05 2017 New Revision: 311846 URL: http://llvm.org/viewvc/llvm-project?rev=311846&view=rev Log: ClangCodeGenTests: Update libdeps. Modified: cfe/trunk/unittests/CodeGen/CMakeLists.txt Modified: cfe/trunk/unittests/CodeGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/CodeGen/CMakeLists.txt?rev=311846&r1=311845&r2=311846&view=diff == --- cfe/trunk/unittests/CodeGen/CMakeLists.txt (original) +++ cfe/trunk/unittests/CodeGen/CMakeLists.txt Sun Aug 27 04:46:05 2017 @@ -12,5 +12,6 @@ target_link_libraries(ClangCodeGenTests clangBasic clangCodeGen clangFrontend + clangLex clangParse ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311845 - Add forgotten file in r311844.
Author: vvassilev Date: Sun Aug 27 04:31:01 2017 New Revision: 311845 URL: http://llvm.org/viewvc/llvm-project?rev=311845&view=rev Log: Add forgotten file in r311844. Added: cfe/trunk/unittests/CodeGen/IncrementalProcessingTest.cpp Added: cfe/trunk/unittests/CodeGen/IncrementalProcessingTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/CodeGen/IncrementalProcessingTest.cpp?rev=311845&view=auto == --- cfe/trunk/unittests/CodeGen/IncrementalProcessingTest.cpp (added) +++ cfe/trunk/unittests/CodeGen/IncrementalProcessingTest.cpp Sun Aug 27 04:31:01 2017 @@ -0,0 +1,174 @@ +//=== unittests/CodeGen/IncrementalProcessingTest.cpp - IncrementalCodeGen ===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/ASTContext.h" +#include "clang/AST/RecursiveASTVisitor.h" +#include "clang/Basic/TargetInfo.h" +#include "clang/CodeGen/ModuleBuilder.h" +#include "clang/Frontend/CompilerInstance.h" +#include "clang/Lex/Preprocessor.h" +#include "clang/Parse/Parser.h" +#include "clang/Sema/Sema.h" +#include "llvm/ADT/Triple.h" +#include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Module.h" +#include "llvm/Support/Host.h" +#include "llvm/Support/MemoryBuffer.h" +#include "gtest/gtest.h" + +#include + +using namespace llvm; +using namespace clang; + +namespace { + +// Incremental processing produces several modules, all using the same "main +// file". Make sure CodeGen can cope with that, e.g. for static initializers. +const char TestProgram1[] = +"extern \"C\" int funcForProg1() { return 17; }\n" +"struct EmitCXXGlobalInitFunc1 {\n" +" EmitCXXGlobalInitFunc1() {}\n" +"} test1;"; + +const char TestProgram2[] = +"extern \"C\" int funcForProg2() { return 42; }\n" +"struct EmitCXXGlobalInitFunc2 {\n" +" EmitCXXGlobalInitFunc2() {}\n" +"} test2;"; + + +/// An incremental version of ParseAST(). +static std::unique_ptr +IncrementalParseAST(CompilerInstance& CI, Parser& P, +CodeGenerator& CG, const char* code) { + static int counter = 0; + struct IncreaseCounterOnRet { +~IncreaseCounterOnRet() { + ++counter; +} + } ICOR; + + Sema& S = CI.getSema(); + clang::SourceManager &SM = S.getSourceManager(); + if (!code) { +// Main file +SM.setMainFileID(SM.createFileID( +llvm::MemoryBuffer::getMemBuffer(""), clang::SrcMgr::C_User)); + +S.getPreprocessor().EnterMainSourceFile(); +P.Initialize(); + } else { +FileID FID = SM.createFileID( +llvm::MemoryBuffer::getMemBuffer(code), clang::SrcMgr::C_User); +SourceLocation MainStartLoc = SM.getLocForStartOfFile(SM.getMainFileID()); +SourceLocation InclLoc = MainStartLoc.getLocWithOffset(counter); +S.getPreprocessor().EnterSourceFile(FID, 0, InclLoc); + } + + ExternalASTSource *External = S.getASTContext().getExternalSource(); + if (External) +External->StartTranslationUnit(&CG); + + Parser::DeclGroupPtrTy ADecl; + for (bool AtEOF = P.ParseFirstTopLevelDecl(ADecl); !AtEOF; + AtEOF = P.ParseTopLevelDecl(ADecl)) { +// If we got a null return and something *was* parsed, ignore it. This +// is due to a top-level semicolon, an action override, or a parse error +// skipping something. +if (ADecl && !CG.HandleTopLevelDecl(ADecl.get())) + return nullptr; + } + + // Process any TopLevelDecls generated by #pragma weak. + for (Decl *D : S.WeakTopLevelDecls()) +CG.HandleTopLevelDecl(DeclGroupRef(D)); + + CG.HandleTranslationUnit(S.getASTContext()); + + std::unique_ptr M(CG.ReleaseModule()); + // Switch to next module. + CG.StartModule("incremental-module-" + std::to_string(counter), + M->getContext()); + return M; +} + +const Function* getGlobalInit(llvm::Module& M) { + for (const auto& Func: M) +if (Func.hasName() && Func.getName().startswith("_GLOBAL__sub_I_")) + return &Func; + + return nullptr; +} + +TEST(IncrementalProcessing, EmitCXXGlobalInitFunc) { +LLVMContext Context; +CompilerInstance compiler; + +compiler.createDiagnostics(); +compiler.getLangOpts().CPlusPlus = 1; +compiler.getLangOpts().CPlusPlus11 = 1; + +compiler.getTargetOpts().Triple = llvm::Triple::normalize( +llvm::sys::getProcessTriple()); +compiler.setTarget(clang::TargetInfo::CreateTargetInfo( + compiler.getDiagnostics(), + std::make_shared( +compiler.getTargetOpts(; + +compiler.createFileManager(); +compiler.createSourceManager(compiler.getFileManager()); +compiler.createPreprocessor(clang::TU_Prefix); +compiler.getPreprocessor().enableIncrementalProcessing(); + +compiler.createASTContext(); +
[PATCH] D36820: [Bash-autocompletion] Add support for -std=
v.g.vassilev accepted this revision. v.g.vassilev added a comment. LGTM +ping! https://reviews.llvm.org/D36820 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34059: Get the file name for the symbol from the Module, not the SourceManager.
v.g.vassilev closed this revision. v.g.vassilev added a comment. Landed in r311844. https://reviews.llvm.org/D34059 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311844 - D34059: Get the file name for the symbol from the Module, not the SourceManager.
Author: vvassilev Date: Sun Aug 27 04:27:30 2017 New Revision: 311844 URL: http://llvm.org/viewvc/llvm-project?rev=311844&view=rev Log: D34059: Get the file name for the symbol from the Module, not the SourceManager. This allows multi-module / incremental compilation environments to have unique initializer symbols. Patch by Axel Naumann with minor modifications by me! Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/unittests/CodeGen/CMakeLists.txt Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=311844&r1=311843&r2=311844&view=diff == --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Sun Aug 27 04:27:30 2017 @@ -487,16 +487,12 @@ CodeGenModule::EmitCXXGlobalInitFunc() { PrioritizedCXXGlobalInits.clear(); } - SmallString<128> FileName; - SourceManager &SM = Context.getSourceManager(); - if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) { -// Include the filename in the symbol name. Including "sub_" matches gcc and -// makes sure these symbols appear lexicographically behind the symbols with -// priority emitted above. -FileName = llvm::sys::path::filename(MainFile->getName()); - } else { + // Include the filename in the symbol name. Including "sub_" matches gcc and + // makes sure these symbols appear lexicographically behind the symbols with + // priority emitted above. + SmallString<128> FileName = llvm::sys::path::filename(getModule().getName()); + if (FileName.empty()) FileName = ""; - } for (size_t i = 0; i < FileName.size(); ++i) { // Replace everything that's not [a-zA-Z0-9._] with a _. This set happens Modified: cfe/trunk/unittests/CodeGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/CodeGen/CMakeLists.txt?rev=311844&r1=311843&r2=311844&view=diff == --- cfe/trunk/unittests/CodeGen/CMakeLists.txt (original) +++ cfe/trunk/unittests/CodeGen/CMakeLists.txt Sun Aug 27 04:27:30 2017 @@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS add_clang_unittest(ClangCodeGenTests BufferSourceTest.cpp + IncrementalProcessingTest.cpp ) target_link_libraries(ClangCodeGenTests ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34444: Teach codegen to work in incremental processing mode.
v.g.vassilev added a comment. A version of this landed in r311843. I am keeping in mind this discussion and I'd like to follow up with @rjmccall once I open the more major review item (libInterpreter). https://reviews.llvm.org/D3 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311843 - D34444: Teach codegen to work in incremental processing mode.
Author: vvassilev Date: Sun Aug 27 03:58:03 2017 New Revision: 311843 URL: http://llvm.org/viewvc/llvm-project?rev=311843&view=rev Log: D3: Teach codegen to work in incremental processing mode. When isIncrementalProcessingEnabled is on we might want to produce multiple llvm::Modules. This patch allows the clients to start a new llvm::Module, allowing CodeGen to continue working after a HandleEndOfTranslationUnit call. This should give the necessary facilities to write a unittest for D34059. As discussed in the review this is meant to give us a way to proceed forward in our efforts to upstream our interpreter-related patches. The design of this will likely change soon. Modified: cfe/trunk/include/clang/CodeGen/ModuleBuilder.h cfe/trunk/lib/CodeGen/ModuleBuilder.cpp Modified: cfe/trunk/include/clang/CodeGen/ModuleBuilder.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/ModuleBuilder.h?rev=311843&r1=311842&r2=311843&view=diff == --- cfe/trunk/include/clang/CodeGen/ModuleBuilder.h (original) +++ cfe/trunk/include/clang/CodeGen/ModuleBuilder.h Sun Aug 27 03:58:03 2017 @@ -84,6 +84,10 @@ public: /// code generator will schedule the entity for emission if a /// definition has been registered with this code generator. llvm::Constant *GetAddrOfGlobal(GlobalDecl decl, bool isForDefinition); + + /// Create a new \c llvm::Module after calling HandleTranslationUnit. This + /// enable codegen in interactive processing environments. + llvm::Module* StartModule(llvm::StringRef ModuleName, llvm::LLVMContext &C); }; /// CreateLLVMCodeGen - Create a CodeGenerator instance. Modified: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ModuleBuilder.cpp?rev=311843&r1=311842&r2=311843&view=diff == --- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp (original) +++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp Sun Aug 27 03:58:03 2017 @@ -119,6 +119,14 @@ namespace { return Builder->GetAddrOfGlobal(global, ForDefinition_t(isForDefinition)); } +llvm::Module *StartModule(llvm::StringRef ModuleName, + llvm::LLVMContext &C) { + assert(!M && "Replacing existing Module?"); + M.reset(new llvm::Module(ModuleName, C)); + Initialize(*Ctx); + return M.get(); +} + void Initialize(ASTContext &Context) override { Ctx = &Context; @@ -317,6 +325,11 @@ llvm::Constant *CodeGenerator::GetAddrOf ->GetAddrOfGlobal(global, isForDefinition); } +llvm::Module *CodeGenerator::StartModule(llvm::StringRef ModuleName, + llvm::LLVMContext &C) { + return static_cast(this)->StartModule(ModuleName, C); +} + CodeGenerator *clang::CreateLLVMCodeGen( DiagnosticsEngine &Diags, llvm::StringRef ModuleName, const HeaderSearchOptions &HeaderSearchOpts, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34444: Teach codegen to work in incremental processing mode.
v.g.vassilev updated this revision to Diff 112813. v.g.vassilev added a comment. Type& name -> Type &name. https://reviews.llvm.org/D3 Files: include/clang/CodeGen/ModuleBuilder.h lib/CodeGen/ModuleBuilder.cpp Index: lib/CodeGen/ModuleBuilder.cpp === --- lib/CodeGen/ModuleBuilder.cpp +++ lib/CodeGen/ModuleBuilder.cpp @@ -119,6 +119,14 @@ return Builder->GetAddrOfGlobal(global, ForDefinition_t(isForDefinition)); } +llvm::Module *StartModule(llvm::StringRef ModuleName, llvm::LLVMContext &C, + const CodeGenOptions &CGO) { + assert(!M && "Replacing existing Module?"); + M.reset(new llvm::Module(ModuleName, C)); + Initialize(*Ctx); + return M.get(); +} + void Initialize(ASTContext &Context) override { Ctx = &Context; @@ -317,6 +325,11 @@ ->GetAddrOfGlobal(global, isForDefinition); } +llvm::Module *CodeGenerator::StartModule(llvm::StringRef ModuleName, + llvm::LLVMContext &C) { + return static_cast(this)->StartModule(ModuleName, C); +} + CodeGenerator *clang::CreateLLVMCodeGen( DiagnosticsEngine &Diags, llvm::StringRef ModuleName, const HeaderSearchOptions &HeaderSearchOpts, Index: include/clang/CodeGen/ModuleBuilder.h === --- include/clang/CodeGen/ModuleBuilder.h +++ include/clang/CodeGen/ModuleBuilder.h @@ -84,6 +84,11 @@ /// code generator will schedule the entity for emission if a /// definition has been registered with this code generator. llvm::Constant *GetAddrOfGlobal(GlobalDecl decl, bool isForDefinition); + + /// Create a new \c llvm::Module after calling HandleTranslationUnit. This + /// enable codegen in interactive processing environments. + llvm::Module* StartModule(llvm::StringRef ModuleName, llvm::LLVMContext &C, +const CodeGenOptions &CGO); }; /// CreateLLVMCodeGen - Create a CodeGenerator instance. Index: lib/CodeGen/ModuleBuilder.cpp === --- lib/CodeGen/ModuleBuilder.cpp +++ lib/CodeGen/ModuleBuilder.cpp @@ -119,6 +119,14 @@ return Builder->GetAddrOfGlobal(global, ForDefinition_t(isForDefinition)); } +llvm::Module *StartModule(llvm::StringRef ModuleName, llvm::LLVMContext &C, + const CodeGenOptions &CGO) { + assert(!M && "Replacing existing Module?"); + M.reset(new llvm::Module(ModuleName, C)); + Initialize(*Ctx); + return M.get(); +} + void Initialize(ASTContext &Context) override { Ctx = &Context; @@ -317,6 +325,11 @@ ->GetAddrOfGlobal(global, isForDefinition); } +llvm::Module *CodeGenerator::StartModule(llvm::StringRef ModuleName, + llvm::LLVMContext &C) { + return static_cast(this)->StartModule(ModuleName, C); +} + CodeGenerator *clang::CreateLLVMCodeGen( DiagnosticsEngine &Diags, llvm::StringRef ModuleName, const HeaderSearchOptions &HeaderSearchOpts, Index: include/clang/CodeGen/ModuleBuilder.h === --- include/clang/CodeGen/ModuleBuilder.h +++ include/clang/CodeGen/ModuleBuilder.h @@ -84,6 +84,11 @@ /// code generator will schedule the entity for emission if a /// definition has been registered with this code generator. llvm::Constant *GetAddrOfGlobal(GlobalDecl decl, bool isForDefinition); + + /// Create a new \c llvm::Module after calling HandleTranslationUnit. This + /// enable codegen in interactive processing environments. + llvm::Module* StartModule(llvm::StringRef ModuleName, llvm::LLVMContext &C, +const CodeGenOptions &CGO); }; /// CreateLLVMCodeGen - Create a CodeGenerator instance. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37188: [clang-tools-extra] [cmake] Support running extra clang tool tests without static analyzer
mgorny added inline comments. Comment at: test/include-fixer/yamldb_plugin.cpp:7 -// CHECK: yamldb_plugin.cpp:3:1: error: unknown type name 'foo'; did you mean 'foo'? -// CHECK: Number FIX-ITs = 1 Differential is showing this a bit weird, all that's changed here and below are adjusted line numbers. Repository: rL LLVM https://reviews.llvm.org/D37188 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37188: [clang-tools-extra] [cmake] Support running extra clang tool tests without static analyzer
mgorny created this revision. Support running the extra clang tool tests when the static analyzer is disabled. Disable the relevant clang-tidy tests and one include-fixer test that require it to work. Previously, the tests were disabled entirely with CLANG_ENABLE_STATIC_ANALYZER being false. Now, the tests are being enabled and the relevant tests are excluded and marked unsupported appropriately. In order to disable clang-tidy tests, the whole test directory is added to the exclude lists, to avoid having to explicitly add 'REQUIRES' line to every single test. If the other solution is preferable, I can update the patch. The yamldb_plugin include-fixer test is also updated to be disabled without static analyzer. It fails in that case because clang is not outputting a replacement suggestion -- but I don't know the exact reason why it does not do that. Repository: rL LLVM https://reviews.llvm.org/D37188 Files: CMakeLists.txt test/CMakeLists.txt test/include-fixer/yamldb_plugin.cpp test/lit.cfg test/lit.site.cfg.in unittests/CMakeLists.txt Index: unittests/CMakeLists.txt === --- unittests/CMakeLists.txt +++ unittests/CMakeLists.txt @@ -9,6 +9,8 @@ add_subdirectory(clang-apply-replacements) add_subdirectory(clang-move) add_subdirectory(clang-query) -add_subdirectory(clang-tidy) +if(CLANG_ENABLE_STATIC_ANALYZER) + add_subdirectory(clang-tidy) +endif() add_subdirectory(clangd) add_subdirectory(include-fixer) Index: test/lit.site.cfg.in === --- test/lit.site.cfg.in +++ test/lit.site.cfg.in @@ -10,6 +10,7 @@ config.clang_libs_dir = "@SHLIBDIR@" config.python_executable = "@PYTHON_EXECUTABLE@" config.target_triple = "@TARGET_TRIPLE@" +config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@ # Support substitution of the tools and libs dirs with user parameters. This is # used when we can't determine the tool dir at configuration time. Index: test/lit.cfg === --- test/lit.cfg +++ test/lit.cfg @@ -192,13 +192,18 @@ if platform.system() not in ['Windows']: config.available_features.add('ansi-escape-sequences') -check_clang_tidy = os.path.join( -config.test_source_root, "clang-tidy", "check_clang_tidy.py") -config.substitutions.append( -('%check_clang_tidy', - '%s %s' % (config.python_executable, check_clang_tidy)) ) -clang_tidy_diff = os.path.join( -config.test_source_root, "..", "clang-tidy", "tool", "clang-tidy-diff.py") -config.substitutions.append( -('%clang_tidy_diff', - '%s %s' % (config.python_executable, clang_tidy_diff)) ) +if config.clang_staticanalyzer: +config.available_features.add('static-analyzer') +check_clang_tidy = os.path.join( +config.test_source_root, "clang-tidy", "check_clang_tidy.py") +config.substitutions.append( +('%check_clang_tidy', + '%s %s' % (config.python_executable, check_clang_tidy)) ) +clang_tidy_diff = os.path.join( +config.test_source_root, "..", "clang-tidy", "tool", "clang-tidy-diff.py") +config.substitutions.append( +('%clang_tidy_diff', + '%s %s' % (config.python_executable, clang_tidy_diff)) ) +else: +# exclude the clang-tidy test directory +config.excludes.append('clang-tidy') Index: test/include-fixer/yamldb_plugin.cpp === --- test/include-fixer/yamldb_plugin.cpp +++ test/include-fixer/yamldb_plugin.cpp @@ -1,23 +1,24 @@ +// REQUIRES: static-analyzer // RUN: c-index-test -test-load-source-reparse 2 all %s -Xclang -add-plugin -Xclang clang-include-fixer -fspell-checking -Xclang -plugin-arg-clang-include-fixer -Xclang -input=%p/Inputs/fake_yaml_db.yaml 2>&1 | FileCheck %s foo f; foo g; unknown u; -// CHECK: yamldb_plugin.cpp:3:1: error: unknown type name 'foo'; did you mean 'foo'? -// CHECK: Number FIX-ITs = 1 -// CHECK: FIX-IT: Replace [3:1 - 3:4] with "foo" -// CHECK: yamldb_plugin.cpp:3:1: note: Add '#include "foo.h"' to provide the missing declaration [clang-include-fixer] -// CHECK: Number FIX-ITs = 1 -// CHECK: FIX-IT: Insert "#include "foo.h" // CHECK: yamldb_plugin.cpp:4:1: error: unknown type name 'foo'; did you mean 'foo'? // CHECK: Number FIX-ITs = 1 // CHECK: FIX-IT: Replace [4:1 - 4:4] with "foo" // CHECK: yamldb_plugin.cpp:4:1: note: Add '#include "foo.h"' to provide the missing declaration [clang-include-fixer] // CHECK: Number FIX-ITs = 1 // CHECK: FIX-IT: Insert "#include "foo.h" -// CHECK: " at 3:1 -// CHECK: yamldb_plugin.cpp:5:1: +// CHECK: yamldb_plugin.cpp:5:1: error: unknown type name 'foo'; did you mean 'foo'? +// CHECK: Number FIX-ITs = 1 +// CHECK: FIX-IT: Replace [5:1 - 5:4] with "foo" +// CHECK: yamldb_plugin.cpp:5:1: note: Add '#include "foo.h"' to provide the missing declaration [clang-include-fixer] +// CHECK: Number FIX-ITs = 1 +// CHECK
[PATCH] D34444: Teach codegen to work in incremental processing mode.
v.g.vassilev updated this revision to Diff 112812. v.g.vassilev marked an inline comment as done. v.g.vassilev added a comment. std::string& -> llvm::StringRef. https://reviews.llvm.org/D3 Files: include/clang/CodeGen/ModuleBuilder.h lib/CodeGen/ModuleBuilder.cpp Index: lib/CodeGen/ModuleBuilder.cpp === --- lib/CodeGen/ModuleBuilder.cpp +++ lib/CodeGen/ModuleBuilder.cpp @@ -119,6 +119,14 @@ return Builder->GetAddrOfGlobal(global, ForDefinition_t(isForDefinition)); } +llvm::Module *StartModule(llvm::StringRef ModuleName, llvm::LLVMContext& C, + const CodeGenOptions& CGO) { + assert(!M && "Replacing existing Module?"); + M.reset(new llvm::Module(ModuleName, C)); + Initialize(*Ctx); + return M.get(); +} + void Initialize(ASTContext &Context) override { Ctx = &Context; @@ -317,6 +325,11 @@ ->GetAddrOfGlobal(global, isForDefinition); } +llvm::Module *CodeGenerator::StartModule(llvm::StringRef ModuleName, + llvm::LLVMContext& C) { + return static_cast(this)->StartModule(ModuleName, C); +} + CodeGenerator *clang::CreateLLVMCodeGen( DiagnosticsEngine &Diags, llvm::StringRef ModuleName, const HeaderSearchOptions &HeaderSearchOpts, Index: include/clang/CodeGen/ModuleBuilder.h === --- include/clang/CodeGen/ModuleBuilder.h +++ include/clang/CodeGen/ModuleBuilder.h @@ -84,6 +84,11 @@ /// code generator will schedule the entity for emission if a /// definition has been registered with this code generator. llvm::Constant *GetAddrOfGlobal(GlobalDecl decl, bool isForDefinition); + + /// Create a new \c llvm::Module after calling HandleTranslationUnit. This + /// enable codegen in interactive processing environments. + llvm::Module* StartModule(llvm::StringRef ModuleName, llvm::LLVMContext& C, +const CodeGenOptions& CGO); }; /// CreateLLVMCodeGen - Create a CodeGenerator instance. Index: lib/CodeGen/ModuleBuilder.cpp === --- lib/CodeGen/ModuleBuilder.cpp +++ lib/CodeGen/ModuleBuilder.cpp @@ -119,6 +119,14 @@ return Builder->GetAddrOfGlobal(global, ForDefinition_t(isForDefinition)); } +llvm::Module *StartModule(llvm::StringRef ModuleName, llvm::LLVMContext& C, + const CodeGenOptions& CGO) { + assert(!M && "Replacing existing Module?"); + M.reset(new llvm::Module(ModuleName, C)); + Initialize(*Ctx); + return M.get(); +} + void Initialize(ASTContext &Context) override { Ctx = &Context; @@ -317,6 +325,11 @@ ->GetAddrOfGlobal(global, isForDefinition); } +llvm::Module *CodeGenerator::StartModule(llvm::StringRef ModuleName, + llvm::LLVMContext& C) { + return static_cast(this)->StartModule(ModuleName, C); +} + CodeGenerator *clang::CreateLLVMCodeGen( DiagnosticsEngine &Diags, llvm::StringRef ModuleName, const HeaderSearchOptions &HeaderSearchOpts, Index: include/clang/CodeGen/ModuleBuilder.h === --- include/clang/CodeGen/ModuleBuilder.h +++ include/clang/CodeGen/ModuleBuilder.h @@ -84,6 +84,11 @@ /// code generator will schedule the entity for emission if a /// definition has been registered with this code generator. llvm::Constant *GetAddrOfGlobal(GlobalDecl decl, bool isForDefinition); + + /// Create a new \c llvm::Module after calling HandleTranslationUnit. This + /// enable codegen in interactive processing environments. + llvm::Module* StartModule(llvm::StringRef ModuleName, llvm::LLVMContext& C, +const CodeGenOptions& CGO); }; /// CreateLLVMCodeGen - Create a CodeGenerator instance. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36555: Move x86-specific sources to x86-specific source lists.
mgorny resigned from this revision. mgorny added a comment. This revision is now accepted and ready to land. I'm not going to block this but I agree with others that the PPC changes look like they belong in a separate commit. https://reviews.llvm.org/D36555 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)
mgorny added a comment. The problems: 1. http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/2140/steps/annotate/logs/stdio -- purely this change, 2. http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/2146/steps/run%20instrumented%20asan%20tests%20%5Bi686%2Ffugu-userdebug%2FN2G48C%5D/logs/stdio -- after https://reviews.llvm.org/D26764. Repository: rL LLVM https://reviews.llvm.org/D26796 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)
mgorny added a comment. @eugenis, it seems that this broke the Android buildbot. Could you suggest an appropriate course of action? I suppose we either have to fix Android-something to use i386, or keep using i686 for Android. The latter I know how to do but for the former, I have no clue where the issue might be. Repository: rL LLVM https://reviews.llvm.org/D26796 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D35450: [analyzer] Support generating and reasoning over more symbolic constraint types
zaks.anna added inline comments. Comment at: lib/StaticAnalyzer/Core/SValBuilder.cpp:364 if (symLHS && symRHS && - (symLHS->computeComplexity() + symRHS->computeComplexity()) < MaxComp) + (symLHS->computeComplexity() + symRHS->computeComplexity()) < MaxComp) return makeNonLoc(symLHS, Op, symRHS, ResultTy); ddcc wrote: > zaks.anna wrote: > > As a follow up to the previous version of this patch, I do not think we > > should set the default complexity limit to 1. > > > > What is the relation between this limit and the limit in > > VisitNonLocSymbolVal? If they are related, would it be worthwhile turning > > these into an analyzer option? > To clarify, the current version of this patch does not modify the `MaxComp` > parameter. > > My understanding is that `MaxComp` is the upper bound for building a new > `NonLoc` symbol from two children, based on the sum of the number of child > symbols (complexity) across both children. > > In contrast, the limit in `VisitNonLocSymbolVal` (@NoQ, correct me if I'm > wrong), is the upper bound for recursively evaluating and inlining a `NonLoc` > symbol, triggered from `simplifySVal` by `evalBinOpNN`. Note that these two > latter functions indirectly call each other recursively (through > `evalBinOp`), causing the previous runtime blowup. Furthermore, each call to > `computeComplexity`will re-iterate through all child symbols of the current > symbol, but only the first complexity check at the root symbol is actually > necessary, because by definition the complexity of a child symbol at each > recursive call is monotonically decreasing. > > I think it'd be useful to allow both to be configurable, but I don't see a > direct relationship between the two. > To clarify, the current version of this patch does not modify the MaxComp > parameter. I know. Also, currently, it is only used in the unsupported taint tracking mode and only for tainted symbols. I would like a different smaller default for all expressions. https://reviews.llvm.org/D35450 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37103: [StaticAnalyzer] LoopUnrolling fixes
zaks.anna added inline comments. Comment at: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp:190 + /* Default = */ false); + return shouldUnrollLoops() || explicitlyIncludeLoopExit; } I would rather keep this method as is and add the extra logic elsewhere (ex: the place where includeLoopExitInCFG is used). To me, AnalyzerOptions::includeLoopExitInCFG() returns the value of the corresponding parameter and I would not expect it to use anything else. Comment at: test/Analysis/loop-unrolling.cpp:276 + +int loopexit_while_empty_loopstack() { + if (getNum()) nit: "loop" "exit" and "loop" "stack" are separate words, so consider using "_" to separate them. https://reviews.llvm.org/D37103 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26764: [compiler-rt] [cmake] Remove i686 target that is duplicate to i386
This revision was automatically updated to reflect the committed changes. Closed by commit rL311842: [cmake] Remove i686 target that is duplicate to i386 (authored by mgorny). Changed prior to commit: https://reviews.llvm.org/D26764?vs=112807&id=112808#toc Repository: rL LLVM https://reviews.llvm.org/D26764 Files: compiler-rt/trunk/cmake/Modules/CompilerRTUtils.cmake compiler-rt/trunk/cmake/base-config-ix.cmake compiler-rt/trunk/cmake/builtin-config-ix.cmake compiler-rt/trunk/cmake/config-ix.cmake compiler-rt/trunk/lib/asan/CMakeLists.txt compiler-rt/trunk/lib/asan/scripts/asan_device_setup compiler-rt/trunk/lib/builtins/CMakeLists.txt compiler-rt/trunk/lib/ubsan/CMakeLists.txt compiler-rt/trunk/test/asan/CMakeLists.txt compiler-rt/trunk/test/asan/lit.cfg compiler-rt/trunk/test/lit.common.cfg compiler-rt/trunk/test/lsan/TestCases/Linux/use_tls_dynamic.cc compiler-rt/trunk/test/sanitizer_common/lit.common.cfg compiler-rt/trunk/test/scudo/random_shuffle.cpp Index: compiler-rt/trunk/lib/builtins/CMakeLists.txt === --- compiler-rt/trunk/lib/builtins/CMakeLists.txt +++ compiler-rt/trunk/lib/builtins/CMakeLists.txt @@ -271,9 +271,6 @@ i386/chkstk.S i386/chkstk2.S) endif() - - set(i686_SOURCES - ${i386_SOURCES}) else () # MSVC # Use C versions of functions when building on MSVC # MSVC's assembler takes Intel syntax, not AT&T syntax. @@ -285,7 +282,6 @@ ${GENERIC_SOURCES}) set(x86_64h_SOURCES ${x86_64_SOURCES}) set(i386_SOURCES ${GENERIC_SOURCES}) - set(i686_SOURCES ${i386_SOURCES}) endif () # if (NOT MSVC) set(arm_SOURCES @@ -493,9 +489,7 @@ # NOTE: some architectures (e.g. i386) have multiple names. Ensure that # we catch them all. set(_arch ${arch}) - if("${arch}" STREQUAL "i686") -set(_arch "i386|i686") - elseif("${arch}" STREQUAL "armv6m") + if("${arch}" STREQUAL "armv6m") set(_arch "arm|armv6m") elseif("${arch}" MATCHES "^(armhf|armv7|armv7s|armv7k|armv7m|armv7em)$") set(_arch "arm") Index: compiler-rt/trunk/lib/asan/scripts/asan_device_setup === --- compiler-rt/trunk/lib/asan/scripts/asan_device_setup +++ compiler-rt/trunk/lib/asan/scripts/asan_device_setup @@ -95,7 +95,7 @@ local _ARCH= local _ARCH64= if [[ $_ABI == x86* ]]; then -_ARCH=i686 +_ARCH=i386 elif [[ $_ABI == armeabi* ]]; then _ARCH=arm elif [[ $_ABI == arm64-v8a* ]]; then Index: compiler-rt/trunk/lib/asan/CMakeLists.txt === --- compiler-rt/trunk/lib/asan/CMakeLists.txt +++ compiler-rt/trunk/lib/asan/CMakeLists.txt @@ -169,7 +169,7 @@ PARENT_TARGET asan) foreach(arch ${ASAN_SUPPORTED_ARCH}) -if (UNIX AND NOT ${arch} MATCHES "i386|i686") +if (UNIX AND NOT ${arch} STREQUAL "i386") add_sanitizer_rt_version_list(clang_rt.asan-dynamic-${arch} LIBS clang_rt.asan-${arch} clang_rt.asan_cxx-${arch} EXTRA asan.syms.extra) @@ -218,7 +218,7 @@ DEFS ${ASAN_DYNAMIC_DEFINITIONS} PARENT_TARGET asan) -if (UNIX AND NOT ${arch} MATCHES "i386|i686") +if (UNIX AND NOT ${arch} STREQUAL "i386") add_sanitizer_rt_symbols(clang_rt.asan_cxx ARCHS ${arch}) add_dependencies(asan clang_rt.asan_cxx-${arch}-symbols) Index: compiler-rt/trunk/lib/ubsan/CMakeLists.txt === --- compiler-rt/trunk/lib/ubsan/CMakeLists.txt +++ compiler-rt/trunk/lib/ubsan/CMakeLists.txt @@ -178,7 +178,7 @@ if (UNIX) set(ARCHS_FOR_SYMBOLS ${UBSAN_SUPPORTED_ARCH}) - list(REMOVE_ITEM ARCHS_FOR_SYMBOLS i386 i686) + list(REMOVE_ITEM ARCHS_FOR_SYMBOLS i386) add_sanitizer_rt_symbols(clang_rt.ubsan_standalone ARCHS ${ARCHS_FOR_SYMBOLS} PARENT_TARGET ubsan Index: compiler-rt/trunk/cmake/config-ix.cmake === --- compiler-rt/trunk/cmake/config-ix.cmake +++ compiler-rt/trunk/cmake/config-ix.cmake @@ -174,7 +174,7 @@ set(ARM64 aarch64) set(ARM32 arm armhf) -set(X86 i386 i686) +set(X86 i386) set(X86_64 x86_64) set(MIPS32 mips mipsel) set(MIPS64 mips64 mips64el) Index: compiler-rt/trunk/cmake/base-config-ix.cmake === --- compiler-rt/trunk/cmake/base-config-ix.cmake +++ compiler-rt/trunk/cmake/base-config-ix.cmake @@ -139,10 +139,6 @@ elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "i[2-6]86|x86|amd64") if(NOT MSVC) test_target_arch(x86_64 "" "-m64") -# FIXME: We build runtimes for both i686 and i386, as "clang -m32" may -# target different variant than "$CMAKE_C_COMPILER -m32". This part should -
[PATCH] D26764: [compiler-rt] [cmake] Remove i686 target that is duplicate to i386
mgorny updated this revision to Diff 112807. mgorny added a comment. I'm going to commit this now to see if it helps with the Android buildbot. Updating to the rebased patch that's going to be committed. https://reviews.llvm.org/D26764 Files: cmake/Modules/CompilerRTUtils.cmake cmake/base-config-ix.cmake cmake/builtin-config-ix.cmake cmake/config-ix.cmake lib/asan/CMakeLists.txt lib/asan/scripts/asan_device_setup lib/builtins/CMakeLists.txt lib/ubsan/CMakeLists.txt test/asan/CMakeLists.txt test/asan/lit.cfg test/lit.common.cfg test/lsan/TestCases/Linux/use_tls_dynamic.cc test/sanitizer_common/lit.common.cfg test/scudo/random_shuffle.cpp Index: test/scudo/random_shuffle.cpp === --- test/scudo/random_shuffle.cpp +++ test/scudo/random_shuffle.cpp @@ -7,7 +7,7 @@ // RUN: %run %t 1 > %T/random_shuffle_tmp_dir/out2 // RUN: not diff %T/random_shuffle_tmp_dir/out? // RUN: rm -rf %T/random_shuffle_tmp_dir -// UNSUPPORTED: i386-linux,i686-linux,arm-linux,armhf-linux,aarch64-linux,mips-linux,mipsel-linux,mips64-linux,mips64el-linux +// UNSUPPORTED: i386-linux,arm-linux,armhf-linux,aarch64-linux,mips-linux,mipsel-linux,mips64-linux,mips64el-linux // Tests that the allocator shuffles the chunks before returning to the user. Index: test/sanitizer_common/lit.common.cfg === --- test/sanitizer_common/lit.common.cfg +++ test/sanitizer_common/lit.common.cfg @@ -26,7 +26,7 @@ if config.target_arch not in ['arm', 'armhf', 'aarch64']: config.available_features.add('stable-runtime') -if config.host_os == 'Linux' and config.tool_name == "lsan" and (config.target_arch == 'i386' or config.target_arch == 'i686'): +if config.host_os == 'Linux' and config.tool_name == "lsan" and config.target_arch == 'i386': config.available_features.add("lsan-x86") if config.host_os == 'Darwin': Index: test/lsan/TestCases/Linux/use_tls_dynamic.cc === --- test/lsan/TestCases/Linux/use_tls_dynamic.cc +++ test/lsan/TestCases/Linux/use_tls_dynamic.cc @@ -5,7 +5,7 @@ // RUN: %env_lsan_opts=$LSAN_BASE:"use_tls=0" not %run %t 2>&1 | FileCheck %s // RUN: %env_lsan_opts=$LSAN_BASE:"use_tls=1" %run %t 2>&1 // RUN: %env_lsan_opts="" %run %t 2>&1 -// UNSUPPORTED: i386-linux,i686-linux,arm +// UNSUPPORTED: i386-linux,arm #ifndef BUILD_DSO #include Index: test/lit.common.cfg === --- test/lit.common.cfg +++ test/lit.common.cfg @@ -135,7 +135,7 @@ target_arch = getattr(config, 'target_arch', None) if target_arch: config.available_features.add(target_arch + '-target-arch') - if target_arch in ['x86_64', 'i386', 'i686']: + if target_arch in ['x86_64', 'i386']: config.available_features.add('x86-target-arch') config.available_features.add(target_arch + '-' + config.host_os.lower()) Index: test/asan/lit.cfg === --- test/asan/lit.cfg +++ test/asan/lit.cfg @@ -121,16 +121,11 @@ def build_invocation(compile_flags): return " " + " ".join([config.compile_wrapper, config.clang] + compile_flags) + " " -# Clang driver link 'x86' (i686) architecture to 'i386'. -target_arch = config.target_arch -if (target_arch == "i686"): - target_arch = "i386" - config.substitutions.append( ("%clang ", build_invocation(target_cflags)) ) config.substitutions.append( ("%clangxx ", build_invocation(target_cxxflags)) ) config.substitutions.append( ("%clang_asan ", build_invocation(clang_asan_cflags)) ) config.substitutions.append( ("%clangxx_asan ", build_invocation(clang_asan_cxxflags)) ) -config.substitutions.append( ("%shared_libasan", "libclang_rt.asan-%s.so" % target_arch)) +config.substitutions.append( ("%shared_libasan", "libclang_rt.asan-%s.so" % config.target_arch)) if config.asan_dynamic: config.substitutions.append( ("%clang_asan_static ", build_invocation(clang_asan_static_cflags)) ) config.substitutions.append( ("%clangxx_asan_static ", build_invocation(clang_asan_static_cxxflags)) ) Index: test/asan/CMakeLists.txt === --- test/asan/CMakeLists.txt +++ test/asan/CMakeLists.txt @@ -18,7 +18,7 @@ endif() macro(get_bits_for_arch arch bits) - if (${arch} MATCHES "i386|i686|arm|mips|mipsel") + if (${arch} MATCHES "i386|arm|mips|mipsel") set(${bits} 32) elseif (${arch} MATCHES "x86_64|powerpc64|powerpc64le|aarch64|mips64|mips64el|s390x") set(${bits} 64) Index: lib/ubsan/CMakeLists.txt === --- lib/ubsan/CMakeLists.txt +++ lib/ubsan/CMakeLists.txt @@ -178,7 +178,7 @@ if (UNIX) set(ARCHS_FOR_SYMBOLS ${UBSAN_SUPPORTED_ARCH}) - list(REMOVE_ITEM ARCHS_FOR_SYMBOLS i386 i686) + list(REMOVE_ITEM ARCHS_FOR_SYMBOLS i386)
[PATCH] D36737: [analyzer] Store design discussions in docs/analyzer for future use.
zaks.anna added a comment. I think we should have these is .rst format as this is what the rest of the documentation predominantly uses. (Note, the formatting can be very basic, it's the format that I care about.) Otherwise, great to see this addition! https://reviews.llvm.org/D36737 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits