r275679 - Revert "Revert r275029 - Update Clang tests after adding inference for the returned argument attribute"
Author: hfinkel Date: Sat Jul 16 02:22:09 2016 New Revision: 275679 URL: http://llvm.org/viewvc/llvm-project?rev=275679&view=rev Log: Revert "Revert r275029 - Update Clang tests after adding inference for the returned argument attribute" This reverts commit r275043 after reapplying the underlying LLVM commit. Modified: cfe/trunk/test/CodeGen/ppc64-struct-onevect.c cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp cfe/trunk/test/CodeGenOpenCL/as_type.cl Modified: cfe/trunk/test/CodeGen/ppc64-struct-onevect.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ppc64-struct-onevect.c?rev=275679&r1=275678&r2=275679&view=diff == --- cfe/trunk/test/CodeGen/ppc64-struct-onevect.c (original) +++ cfe/trunk/test/CodeGen/ppc64-struct-onevect.c Sat Jul 16 02:22:09 2016 @@ -9,5 +9,5 @@ v4sf foo (struct s a) { return a.v; } -// CHECK-LABEL: define <4 x float> @foo(<4 x float> inreg %a.coerce) +// CHECK-LABEL: define <4 x float> @foo(<4 x float> inreg returned %a.coerce) // CHECK: ret <4 x float> %a.coerce Modified: cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp?rev=275679&r1=275678&r2=275679&view=diff == --- cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp (original) +++ cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp Sat Jul 16 02:22:09 2016 @@ -14,7 +14,7 @@ struct one_field { double d; }; test(one_field); -// CHECK: define double @_Z7forward9one_field(double %{{.*}}) +// CHECK: define double @_Z7forward9one_field(double returned %{{.*}}) // // CHECK: define void @_Z14test_one_fieldv() // CHECK: %[[call:.*]] = tail call double @_Z13def_one_fieldv() @@ -89,7 +89,7 @@ struct one_bitfield { int d:3; }; test(one_bitfield); -// CHECK: define i32 @_Z7forward12one_bitfield(i32 %{{.*}}) +// CHECK: define i32 @_Z7forward12one_bitfield(i32 returned %{{.*}}) // // CHECK: define void @_Z17test_one_bitfieldv() // CHECK: %[[call:.*]] = tail call i32 @_Z16def_one_bitfieldv() Modified: cfe/trunk/test/CodeGenOpenCL/as_type.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/as_type.cl?rev=275679&r1=275678&r2=275679&view=diff == --- cfe/trunk/test/CodeGenOpenCL/as_type.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/as_type.cl Sat Jul 16 02:22:09 2016 @@ -51,7 +51,7 @@ int f6(char4 x) { return __builtin_astype(x, int); } -//CHECK: define spir_func <3 x i8> @f7(<3 x i8> %[[x:.*]]) +//CHECK: define spir_func <3 x i8> @f7(<3 x i8> returned %[[x:.*]]) //CHECK-NOT: bitcast //CHECK-NOT: shufflevector //CHECK: ret <3 x i8> %[[x]] ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands
omtcyfz added a subscriber: omtcyfz. omtcyfz added a comment. - Can you please update diff? I changed most of the tests recently. - I think you should update `doc/clang-rename` in this patch (making it a subsequent patch isn't worthy IMO) - Updating `clang-rename/tool/clang-rename.py` (simply add `-rename-at` into the argument list there) seems reasonable. - Also, I'd be happy to see at least few good tests for `-rename-all` with multiple `-old-name` and `-new-name` arguments. - Why does `-rename-at` not have `-export-fixes` option anymore? - Is there really a need to dispatch `main` to `renameAtMain` and `renameAllMain`? Most of the code is exactly the same (apart from YAML dump absence in `renameAtMain`, which I do not understand). https://reviews.llvm.org/D21814 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20100: [NFC] Header cleanup
kevgs added a comment. Good. I have no commit rights. https://reviews.llvm.org/D20100 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r275681 - [clang-rename] remove obsolete tests and apply fixes to existing
Author: omtcyfz Date: Sat Jul 16 03:55:01 2016 New Revision: 275681 URL: http://llvm.org/viewvc/llvm-project?rev=275681&view=rev Log: [clang-rename] remove obsolete tests and apply fixes to existing Few tests introduced by previous patch had obsolete counterparts. Applied fixes to {Dynamic|Static}CastExpr.cpp Added: clang-tools-extra/trunk/test/clang-rename/ComplicatedClassType.cpp Removed: clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp clang-tools-extra/trunk/test/clang-rename/ClassTestByName.cpp clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp clang-tools-extra/trunk/test/clang-rename/ComplicatedClassTest.cpp clang-tools-extra/trunk/test/clang-rename/CtorDefTest.cpp clang-tools-extra/trunk/test/clang-rename/CtorInitializerTest.cpp clang-tools-extra/trunk/test/clang-rename/DtorDefTest.cpp clang-tools-extra/trunk/test/clang-rename/FieldTest.cpp clang-tools-extra/trunk/test/clang-rename/VarTest.cpp Modified: clang-tools-extra/trunk/test/clang-rename/DynamicCastExpr.cpp clang-tools-extra/trunk/test/clang-rename/StaticCastExpr.cpp Removed: clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp?rev=275680&view=auto == --- clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp (original) +++ clang-tools-extra/trunk/test/clang-rename/ClassTest.cpp (removed) @@ -1,15 +0,0 @@ -// RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=138 -new-name=Hector %t.cpp -i -- -// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s -class Cla // CHECK: class Hector -{ -}; - -int main() -{ -Cla *Pointer = 0; // CHECK: Hector *Pointer = 0; -return 0; -} - -// Use grep -FUbo 'Cla' to get the correct offset of Cla when changing -// this file. Removed: clang-tools-extra/trunk/test/clang-rename/ClassTestByName.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ClassTestByName.cpp?rev=275680&view=auto == --- clang-tools-extra/trunk/test/clang-rename/ClassTestByName.cpp (original) +++ clang-tools-extra/trunk/test/clang-rename/ClassTestByName.cpp (removed) @@ -1,10 +0,0 @@ -// RUN: cat %s > %t.cpp -// RUN: clang-rename -old-name=Cla -new-name=Hector %t.cpp -i -- -// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s -class Cla { // CHECK: class Hector -}; - -int main() { - Cla *Pointer = 0; // CHECK: Hector *Pointer = 0; - return 0; -} Removed: clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp?rev=275680&view=auto == --- clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp (original) +++ clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp (removed) @@ -1,12 +0,0 @@ -// RUN: rm -rf %t -// RUN: mkdir -p %t/fixes -// RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=256 -new-name=Hector -export-fixes=%t/fixes/clang-rename.yaml %t.cpp -- -// RUN: clang-apply-replacements %t -// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s -class Cla // CHECK: class Hector -{ -}; - -// Use grep -FUbo 'Cla' to get the correct offset of Cla when changing -// this file. Removed: clang-tools-extra/trunk/test/clang-rename/ComplicatedClassTest.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ComplicatedClassTest.cpp?rev=275680&view=auto == --- clang-tools-extra/trunk/test/clang-rename/ComplicatedClassTest.cpp (original) +++ clang-tools-extra/trunk/test/clang-rename/ComplicatedClassTest.cpp (removed) @@ -1,30 +0,0 @@ -// Unsupported test. -// RUN: cat %s > %t.cpp -// FIXME: This test contains very simple constructions likely to be seen in any -// project and therefore passing this test is a slight sign of success. -// Currently, the test fails badly. - -class Foo { // CHECK: class Bar { - public: - Foo(int value = 0) : x(value) {}// Bar(int value=0) : x(value) {} - - Foo& operator++(int) { // Bar& operator++(int) { -x++; -return *this; - } - - bool operator<(Foo const& rhs) {// bool operator<(Bar const &rhs) { -return this->x < rhs.x; - } - - private: - int x; -}; - -int main() { - Foo* Pointer = 0; // CHECK: Bar *Pointer = 0; - Foo Variable = Foo(10); // CHECK: Bar Variable = Bar(10); - for (Foo it; it < Variable; it++) { // for (Bar it; it < Variable; it++) {} - } - return 0; -} Added: clang-tools-extra/trunk/test/clang-rename/ComplicatedClassType.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ComplicatedClassType.cpp
Re: [PATCH] D22237: clang-rename: fix renaming member functions
vmiklos abandoned this revision. vmiklos added a comment. I see your point, then let me abandon this. https://reviews.llvm.org/D22237 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22408: [clang-rename] add support for overridden functions
Prazek added a subscriber: Prazek. Prazek added a comment. haven't found anything else Comment at: clang-rename/USRFindingAction.cpp:62 @@ +61,3 @@ + bool Found = false; + for (auto &OverriddenMethod : D->overridden_methods()) { +if (std::find(USRs->begin(), USRs->end(), const auto &OverridenMethod https://reviews.llvm.org/D22408 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22220: [clang-tidy] Add check 'misc-move-forwarding-reference'
Prazek added inline comments. Comment at: docs/clang-tidy/checks/misc-move-forwarding-reference.rst:30 @@ +29,3 @@ +Background +-- + Nothing from me. It's just general comment https://reviews.llvm.org/D0 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22408: [clang-rename] add support for overridden functions
omtcyfz updated this revision to Diff 64228. omtcyfz marked an inline comment as done. https://reviews.llvm.org/D22408 Files: clang-rename/USRFindingAction.cpp test/clang-rename/VirtualFunctionFindInBaseClass.cpp test/clang-rename/VirtualFunctionFindInDerivedClass.cpp Index: test/clang-rename/VirtualFunctionFindInDerivedClass.cpp === --- /dev/null +++ test/clang-rename/VirtualFunctionFindInDerivedClass.cpp @@ -0,0 +1,33 @@ +// RUN: cat %s > %t.cpp +// RUN: clang-rename -offset=165 -new-name=bar %t.cpp -i -- +// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s + +class Foo { +public: + virtual void foo() {} // CHECK: virtual void bar() {} +}; + +class Bar : public Foo { +public: + void foo() override {} // CHECK: void bar() override {} +}; + +class Baz : public Bar { + public: + void foo() override {} // CHECK: void bar() override {} +}; + +int main() { + Foo f; + f.foo();// CHECK: f.bar(); + + Bar b; + b.foo();// CHECK: b.bar(); + + Baz obj; + obj.foo(); // CHECK: obj.bar(); + + return 0; +} + +// Use grep -FUbo 'foo' to get the correct offset of foo when changing Index: test/clang-rename/VirtualFunctionFindInBaseClass.cpp === --- /dev/null +++ test/clang-rename/VirtualFunctionFindInBaseClass.cpp @@ -0,0 +1,33 @@ +// RUN: cat %s > %t.cpp +// RUN: clang-rename -offset=165 -new-name=bar %t.cpp -i -- +// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s + +class Foo { +public: + virtual void foo() {} // CHECK: virtual void bar() {} +}; + +class Bar : public Foo { +public: + void foo() override {} // CHECK: void bar() override {} +}; + +class Baz : public Bar { + public: + void foo() override {} // CHECK: void bar() override {} +}; + +int main() { + Foo f; + f.foo();// CHECK: f.bar(); + + Bar b; + b.foo();// CHECK: b.bar(); + + Baz obj; + obj.foo(); // CHECK: obj.bar(); + + return 0; +} + +// Use grep -FUbo 'foo' to get the correct offset of foo when changing Index: clang-rename/USRFindingAction.cpp === --- clang-rename/USRFindingAction.cpp +++ clang-rename/USRFindingAction.cpp @@ -8,64 +8,111 @@ //===--===// /// /// \file -/// \brief Provides an action to rename every symbol at a point. +/// \brief Provides an action to find USR for the symbol at and all +/// relevant USRs aswell. /// //===--===// #include "USRFindingAction.h" #include "USRFinder.h" #include "clang/AST/AST.h" #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/Decl.h" +#include "clang/AST/RecursiveASTVisitor.h" #include "clang/Basic/FileManager.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendAction.h" #include "clang/Lex/Lexer.h" #include "clang/Lex/Preprocessor.h" #include "clang/Tooling/CommonOptionsParser.h" #include "clang/Tooling/Refactoring.h" #include "clang/Tooling/Tooling.h" +#include #include #include using namespace llvm; namespace clang { namespace rename { -// Get the USRs for the constructors of the class. -static std::vector getAllConstructorUSRs( -const CXXRecordDecl *Decl) { - std::vector USRs; +namespace { +// \brief NamedDeclFindingConsumer should delegate finding USRs relevant to +// given Decl to RelevantUSRFinder. +// +// FIXME: It's better to match ctors/dtors via typeLoc's instead of adding +// their USRs to the storage, because we can also match CXXConversionDecl's by +// typeLoc and we won't have to "manually" handle them here. +class RelevantUSRFinder : public clang::RecursiveASTVisitor { +public: + explicit RelevantUSRFinder(const Decl *FoundDecl, TranslationUnitDecl *TUDecl, + std::vector *USRs) + : FoundDecl(FoundDecl), USRs(USRs) { +USRs->push_back(getUSRForDecl(FoundDecl)); +addRelevantUSRs(); +TraverseDecl(TUDecl); + } - // We need to get the definition of the record (as opposed to any forward - // declarations) in order to find the constructor and destructor. - const auto *RecordDecl = Decl->getDefinition(); + // CXXMethodDecl which overrides one of the methods stored for renaming + // should be added to the storage, too. + bool VisitCXXMethodDecl(CXXMethodDecl *D) { +if (D->isVirtual()) { + bool Found = false; + for (const auto &OverriddenMethod : D->overridden_methods()) { +if (std::find(USRs->begin(), USRs->end(), + getUSRForDecl(OverriddenMethod)) != USRs->end()) { + Found = true; +} + } + if (Found) { +USRs->push_back(getUSRForDecl(D)); + } +} +return true; + } - // Iterate over all the constructors and add their U
Re: [PATCH] D22408: [clang-rename] add support for overridden functions
omtcyfz added inline comments. Comment at: clang-rename/USRFindingAction.cpp:62 @@ +61,3 @@ + bool Found = false; + for (auto &OverriddenMethod : D->overridden_methods()) { +if (std::find(USRs->begin(), USRs->end(), Prazek wrote: > const auto &OverridenMethod Fixed; thanks! https://reviews.llvm.org/D22408 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20100: [NFC] Header cleanup
mehdi_amini added a comment. Can you rebase? I can't apply it right now. https://reviews.llvm.org/D20100 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D22439: Add missing includes.
v.g.vassilev created this revision. v.g.vassilev added a reviewer: rsmith. v.g.vassilev added a subscriber: cfe-commits. I am not sure if we should #include but the instantiation of `operator*` of `ManagedStatic` needs `std::memory_order_aquire`. Modules builds error out with: `In module 'LLVM_Utils' imported from /home/vvassilev/workspace/llvm-git/src/lib/Support/CommandLine.cpp:19: /home/vvassilev/workspace/llvm-git/src/include/llvm/Support/ManagedStatic.h:66:26: error: definition of 'memory_order' must be imported from module 'LLVM_Utils.ADT.IntrusiveRefCntPtr' before it is required void *Tmp = Ptr.load(std::memory_order_acquire); ^ /home/vvassilev/workspace/llvm-git/src/include/llvm/Support/ManagedStatic.h:73:29: note: in instantiation of member function 'llvm::ManagedStatic<(anonymous namespace)::CommandLineParser>::operator*' requested here C *operator->() { return &**this; } ^ /home/vvassilev/workspace/llvm-git/src/lib/Support/CommandLine.cpp:339:15: note: in instantiation of member function 'llvm::ManagedStatic<(anonymous namespace)::CommandLineParser>::operator->' requested here GlobalParser->addLiteralOption(O, Name); ^ /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/atomic_base.h:56:16: note: previous definition is here typedef enum memory_order ^ 1 error generated. ` https://reviews.llvm.org/D22439 Files: lib/Support/APInt.cpp lib/Support/CachePruning.cpp lib/Support/CommandLine.cpp lib/Support/CrashRecoveryContext.cpp lib/Support/Debug.cpp lib/Support/DeltaAlgorithm.cpp lib/Support/Error.cpp lib/Support/ErrorHandling.cpp lib/Support/LockFileManager.cpp lib/Support/ManagedStatic.cpp Index: lib/Support/ManagedStatic.cpp === --- lib/Support/ManagedStatic.cpp +++ lib/Support/ManagedStatic.cpp @@ -16,6 +16,7 @@ #include "llvm/Support/Mutex.h" #include "llvm/Support/MutexGuard.h" #include "llvm/Support/Threading.h" +#include #include using namespace llvm; Index: lib/Support/LockFileManager.cpp === --- lib/Support/LockFileManager.cpp +++ lib/Support/LockFileManager.cpp @@ -13,6 +13,8 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/Signals.h" +#include +#include #include #include #if LLVM_ON_WIN32 Index: lib/Support/ErrorHandling.cpp === --- lib/Support/ErrorHandling.cpp +++ lib/Support/ErrorHandling.cpp @@ -27,6 +27,7 @@ #include "llvm/Support/Threading.h" #include "llvm/Support/WindowsError.h" #include "llvm/Support/raw_ostream.h" +#include #include #include Index: lib/Support/Error.cpp === --- lib/Support/Error.cpp +++ lib/Support/Error.cpp @@ -11,7 +11,8 @@ #include "llvm/ADT/Twine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ManagedStatic.h" - +#include +#include using namespace llvm; Index: lib/Support/DeltaAlgorithm.cpp === --- lib/Support/DeltaAlgorithm.cpp +++ lib/Support/DeltaAlgorithm.cpp @@ -9,6 +9,7 @@ #include "llvm/ADT/DeltaAlgorithm.h" #include #include +#include using namespace llvm; DeltaAlgorithm::~DeltaAlgorithm() { Index: lib/Support/Debug.cpp === --- lib/Support/Debug.cpp +++ lib/Support/Debug.cpp @@ -29,6 +29,7 @@ #include "llvm/Support/Signals.h" #include "llvm/Support/circular_raw_ostream.h" #include "llvm/Support/raw_ostream.h" +#include #undef isCurrentDebugType #undef setCurrentDebugType Index: lib/Support/CrashRecoveryContext.cpp === --- lib/Support/CrashRecoveryContext.cpp +++ lib/Support/CrashRecoveryContext.cpp @@ -13,6 +13,7 @@ #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Mutex.h" #include "llvm/Support/ThreadLocal.h" +#include #include using namespace llvm; Index: lib/Support/CommandLine.cpp === --- lib/Support/CommandLine.cpp +++ lib/Support/CommandLine.cpp @@ -35,6 +35,7 @@ #include "llvm/Support/Path.h" #include "llvm/Support/StringSaver.h" #include "llvm/Support/raw_ostream.h" +#include #include #include using namespace llvm; Index: lib/Support/CachePruning.cpp === --- lib/Support/CachePruning.cpp +++ lib/Support/CachePruning.cpp @@ -22,6 +22,7 @@ #define DEBUG_TYPE "cache-pruning" #include +#include using namespace llvm; Index: lib/Support/APInt.cpp === --- lib/Support/API
Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands
vmiklos updated this revision to Diff 64231. https://reviews.llvm.org/D21814 Files: clang-rename/tool/ClangRename.cpp clang-rename/tool/clang-rename.py docs/clang-rename.rst test/clang-rename/ClassFindByName.cpp test/clang-rename/ClassReplacements.cpp test/clang-rename/ClassSimpleRenaming.cpp test/clang-rename/ConstCastExpr.cpp test/clang-rename/ConstructExpr.cpp test/clang-rename/CtorFindByDeclaration.cpp test/clang-rename/CtorFindByDefinition.cpp test/clang-rename/CtorInitializer.cpp test/clang-rename/DeclRefExpr.cpp test/clang-rename/DtorDeclaration.cpp test/clang-rename/DtorDefinition.cpp test/clang-rename/DynamicCastExpr.cpp test/clang-rename/Field.cpp test/clang-rename/FunctionMacro.cpp test/clang-rename/MemberExprMacro.cpp test/clang-rename/Namespace.cpp test/clang-rename/NoNewName.cpp test/clang-rename/ReinterpretCastExpr.cpp test/clang-rename/StaticCastExpr.cpp test/clang-rename/Variable.cpp test/clang-rename/VariableMacro.cpp Index: test/clang-rename/VariableMacro.cpp === --- test/clang-rename/VariableMacro.cpp +++ test/clang-rename/VariableMacro.cpp @@ -1,5 +1,5 @@ // RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=208 -new-name=Z %t.cpp -i -- +// RUN: clang-rename rename-at -offset=218 -new-name=Z %t.cpp -i -- // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s #define Y X // CHECK: #define Y Z Index: test/clang-rename/Variable.cpp === --- test/clang-rename/Variable.cpp +++ test/clang-rename/Variable.cpp @@ -1,5 +1,5 @@ // RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=148 -new-name=Bar %t.cpp -i -- +// RUN: clang-rename rename-at -offset=158 -new-name=Bar %t.cpp -i -- // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s namespace A { Index: test/clang-rename/StaticCastExpr.cpp === --- test/clang-rename/StaticCastExpr.cpp +++ test/clang-rename/StaticCastExpr.cpp @@ -1,5 +1,5 @@ // RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=152 -new-name=Bar %t.cpp -i -- +// RUN: clang-rename rename-at -offset=162 -new-name=Bar %t.cpp -i -- // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s class Baz { Index: test/clang-rename/ReinterpretCastExpr.cpp === --- test/clang-rename/ReinterpretCastExpr.cpp +++ test/clang-rename/ReinterpretCastExpr.cpp @@ -1,5 +1,5 @@ // RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=133 -new-name=X %t.cpp -i -- +// RUN: clang-rename rename-at -offset=143 -new-name=X %t.cpp -i -- // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s class Cla { public: Index: test/clang-rename/NoNewName.cpp === --- test/clang-rename/NoNewName.cpp +++ test/clang-rename/NoNewName.cpp @@ -1,4 +1,4 @@ // Check for an error while -new-name argument has not been passed to // clang-rename. -// RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s +// RUN: not clang-rename rename-at -offset=133 %s 2>&1 | FileCheck %s // CHECK: clang-rename: no new name provided. Index: test/clang-rename/Namespace.cpp === --- test/clang-rename/Namespace.cpp +++ test/clang-rename/Namespace.cpp @@ -1,5 +1,5 @@ // RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=143 -new-name=llvm %t.cpp -i -- +// RUN: clang-rename rename-at -offset=153 -new-name=llvm %t.cpp -i -- // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s namespace foo { // CHECK: namespace llvm { Index: test/clang-rename/MemberExprMacro.cpp === --- test/clang-rename/MemberExprMacro.cpp +++ test/clang-rename/MemberExprMacro.cpp @@ -1,5 +1,5 @@ // RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=156 -new-name=Bar %t.cpp -i -- +// RUN: clang-rename rename-at -offset=166 -new-name=Bar %t.cpp -i -- // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s class Baz { Index: test/clang-rename/FunctionMacro.cpp === --- test/clang-rename/FunctionMacro.cpp +++ test/clang-rename/FunctionMacro.cpp @@ -1,5 +1,5 @@ // RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=199 -new-name=macro_function %t.cpp -i -- +// RUN: clang-rename rename-at -offset=209 -new-name=macro_function %t.cpp -i -- // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s #define moo foo // CHECK: #define moo macro_function Index: test/clang-rename/Field.cpp === --- test/clang-rename/Field.cpp +++ test/clang-rename/Field.cpp @@ -1,5 +1,5 @@ // RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=148 -new-name=Bar %t.cpp -i -- +// RUN: clang-rename rename-at -offset=158 -new-name=Bar %t.cpp -i -- // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s class Baz { Index: test/clang-rename/DynamicCastExpr
Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands
vmiklos added a comment. In https://reviews.llvm.org/D21814#486204, @omtcyfz wrote: > - Can you please update diff? I changed most of the tests recently. Sure, I actually wanted to ask if those test additions were meant to be test renames. :-) > - I think you should update `doc/clang-rename` in this patch (making it a > subsequent patch isn't worthy IMO) Done. > - Updating `clang-rename/tool/clang-rename.py` (simply add `-rename-at` into > the argument list there) seems reasonable. Done. > - Also, I'd be happy to see at least few good tests for `-rename-all` with > multiple `-old-name` and `-new-name` arguments. Multiple -old-name / -new-name is not supported yet. I implemented that in the first diff of this review, but then I was asked to split the two use cases into separate subcommands first, and only support the multi-rename feature in rename-all only. So I plan to add that in a subsequent patch. Or should squash even that into this review? > - Why does `-rename-at` not have `-export-fixes` option anymore? The use-case for -export-fixes was that multiple translation units will want to do the same replacements in common headers, so -i is not a good choice there. Instead using -export-fixes, and then letting clang-apply-replacements do the deduplication is the way to go. From this point of view, -export-fixes is not useful for the rename-at / single TU use-case. But no problem, I've added it back. > - Is there really a need to dispatch `main` to `renameAtMain` and > `renameAllMain`? Most of the code is exactly the same (apart from YAML dump > absence in `renameAtMain`, which I do not understand). The first idea was to use two separate binaries for rename-at/rename-all. Then a compromise was to still have the same binary, but separate subcommands. So I thought it's considered good to have a separate implementation of the separate subcommands. But I'm happy if sharing code between rename-at and rename-all is still OK, I've changed that. https://reviews.llvm.org/D21814 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands
omtcyfz added a comment. In https://reviews.llvm.org/D21814#486269, @vmiklos wrote: > In https://reviews.llvm.org/D21814#486204, @omtcyfz wrote: > > > - Can you please update diff? I changed most of the tests recently. > > > Sure, I actually wanted to ask if those test additions were meant to be test > renames. :-) Yeah, sorry for that... > > > > - I think you should update `doc/clang-rename` in this patch (making it a > > subsequent patch isn't worthy IMO) > > > Done. > > > - Updating `clang-rename/tool/clang-rename.py` (simply add `-rename-at` > > into the argument list there) seems reasonable. > > > Done. > > > - Also, I'd be happy to see at least few good tests for `-rename-all` with > > multiple `-old-name` and `-new-name` arguments. > > > Multiple -old-name / -new-name is not supported yet. I implemented that in the > first diff of this review, but then I was asked to split the two use cases > into > separate subcommands first, and only support the multi-rename feature in > rename-all only. So I plan to add that in a subsequent patch. Or should > squash > even that into this review? Well, it might be fine for this one. Let's see what the others have to say. > > > > - Why does `-rename-at` not have `-export-fixes` option anymore? > > > The use-case for -export-fixes was that multiple translation units will want > to > do the same replacements in common headers, so -i is not a good choice there. > Instead using -export-fixes, and then letting clang-apply-replacements do the > deduplication is the way to go. From this point of view, -export-fixes is not > useful for the rename-at / single TU use-case. But no problem, I've added it > back. Ah, I can see your point. Well, there's still a long long way to the multi-TU stuff anyway... But I hope we'll get there at some point. I think both interfaces might be useful for multi-TU swell. > > > > - Is there really a need to dispatch `main` to `renameAtMain` and > > `renameAllMain`? Most of the code is exactly the same (apart from YAML dump > > absence in `renameAtMain`, which I do not understand). > > > The first idea was to use two separate binaries for rename-at/rename-all. Then > a compromise was to still have the same binary, but separate subcommands. So > I > thought it's considered good to have a separate implementation of the > separate > subcommands. But I'm happy if sharing code between rename-at and rename-all > is > still OK, I've changed that. Hm, I didn't think about it. Well, honestly I'm not a fan of getting too many binaries and at the moment I think both interfaces are almost identical, so ATM I don't think we should get second binary, it will just make things even more complicated. https://reviews.llvm.org/D21814 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22222: [ASTMatchers] isSignedInteger() and isUnsignedInteger()
Prazek added a subscriber: Prazek. Prazek closed this revision. Prazek added a comment. Already in master https://reviews.llvm.org/D2 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r275697 - CodeGen: use StringRefs more in ObjC class generation, NFC
Author: compnerd Date: Sat Jul 16 17:42:06 2016 New Revision: 275697 URL: http://llvm.org/viewvc/llvm-project?rev=275697&view=rev Log: CodeGen: use StringRefs more in ObjC class generation, NFC Rather than building up a number of SmallString-s in order to construct a std::string, use more StringRefs and construct the string once before use. This avoids unnecessary string constructions. NFC. Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=275697&r1=275696&r2=275697&view=diff == --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original) +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sat Jul 16 17:42:06 2016 @@ -5978,7 +5978,6 @@ void CGObjCNonFragileABIMac::GetClassSiz } void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) { - std::string ClassName = ID->getObjCRuntimeNameAsString(); if (!ObjCEmptyCacheVar) { ObjCEmptyCacheVar = new llvm::GlobalVariable( CGM.getModule(), ObjCTypes.CacheTy, false, @@ -5997,12 +5996,10 @@ void CGObjCNonFragileABIMac::GenerateCla CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ClassnfABITy); uint32_t InstanceSize = InstanceStart; uint32_t flags = NonFragileABI_Class_Meta; - llvm::SmallString<64> ObjCMetaClassName(getMetaclassSymbolPrefix()); - llvm::SmallString<64> ObjCClassName(getClassSymbolPrefix()); - llvm::SmallString<64> TClassName; llvm::GlobalVariable *SuperClassGV, *IsAGV; + StringRef ClassName = ID->getObjCRuntimeNameAsString(); const auto *CI = ID->getClassInterface(); assert(CI && "CGObjCNonFragileABIMac::GenerateClass - class is 0"); @@ -6023,13 +6020,11 @@ void CGObjCNonFragileABIMac::GenerateCla // class is root flags |= NonFragileABI_Class_Root; -TClassName = ObjCClassName; -TClassName += ClassName; -SuperClassGV = GetClassGlobal(TClassName.str(), CI->isWeakImported()); - -TClassName = ObjCMetaClassName; -TClassName += ClassName; -IsAGV = GetClassGlobal(TClassName.str(), CI->isWeakImported()); +SuperClassGV = GetClassGlobal((getClassSymbolPrefix() + ClassName).str(), + CI->isWeakImported()); + +IsAGV = GetClassGlobal((getMetaclassSymbolPrefix() + ClassName).str(), + CI->isWeakImported()); } else { // Has a root. Current class is not a root. const ObjCInterfaceDecl *Root = ID->getClassInterface(); @@ -6037,25 +6032,25 @@ void CGObjCNonFragileABIMac::GenerateCla Root = Super; const auto *Super = CI->getSuperClass(); +StringRef RootClassName = Root->getObjCRuntimeNameAsString(); +StringRef SuperClassName = Super->getObjCRuntimeNameAsString(); -TClassName = ObjCMetaClassName ; -TClassName += Root->getObjCRuntimeNameAsString(); -IsAGV = GetClassGlobal(TClassName.str(), Root->isWeakImported()); +IsAGV = GetClassGlobal((getMetaclassSymbolPrefix() + RootClassName).str(), + Root->isWeakImported()); // work on super class metadata symbol. -TClassName = ObjCMetaClassName; -TClassName += Super->getObjCRuntimeNameAsString(); -SuperClassGV = GetClassGlobal(TClassName.str(), Super->isWeakImported()); +SuperClassGV = +GetClassGlobal((getMetaclassSymbolPrefix() + SuperClassName).str(), + Super->isWeakImported()); } llvm::GlobalVariable *CLASS_RO_GV = BuildClassRoTInitializer(flags, InstanceStart, InstanceSize, ID); - TClassName = ObjCMetaClassName; - TClassName += ClassName; llvm::GlobalVariable *MetaTClass = - BuildClassMetaData(TClassName.str(), IsAGV, SuperClassGV, CLASS_RO_GV, - classIsHidden, CI->isWeakImported()); + BuildClassMetaData((getMetaclassSymbolPrefix() + ClassName).str(), IsAGV, + SuperClassGV, CLASS_RO_GV, classIsHidden, + CI->isWeakImported()); DefinedMetaClasses.push_back(MetaTClass); // Metadata for the class @@ -6085,21 +6080,21 @@ void CGObjCNonFragileABIMac::GenerateCla } else { // Has a root. Current class is not a root. const auto *Super = CI->getSuperClass(); +StringRef SuperClassName = Super->getObjCRuntimeNameAsString(); -TClassName = ObjCClassName; -TClassName += Super->getObjCRuntimeNameAsString(); -SuperClassGV = GetClassGlobal(TClassName.str(), Super->isWeakImported()); +SuperClassGV = +GetClassGlobal((getClassSymbolPrefix() + SuperClassName).str(), + Super->isWeakImported()); } GetClassSizeInfo(ID, InstanceStart, InstanceSize); CLASS_RO_GV = BuildClassRoTInitializer(flags, InstanceStart, InstanceSize, ID); - TClassName = ObjCClassName; - TClassName += ClassName; llvm::GlobalVariable *ClassMD = -BuildClassMetaData(TClassName.str(), MetaTClass, Supe
r275696 - CodeGen: simplify using a local variable, NFC
Author: compnerd Date: Sat Jul 16 17:42:04 2016 New Revision: 275696 URL: http://llvm.org/viewvc/llvm-project?rev=275696&view=rev Log: CodeGen: simplify using a local variable, NFC Add a couple of local variables for the class interface and the super class interface. This allows for the repeated access of the information to be cached and makes the code simpler to understand. NFC. Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=275696&r1=275695&r2=275696&view=diff == --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original) +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sat Jul 16 17:42:04 2016 @@ -5991,8 +5991,7 @@ void CGObjCNonFragileABIMac::GenerateCla CGM.getModule(), ObjCTypes.ImpnfABITy, false, llvm::GlobalValue::ExternalLinkage, nullptr, "_objc_empty_vtable"); } - assert(ID->getClassInterface() && - "CGObjCNonFragileABIMac::GenerateClass - class is 0"); + // FIXME: Is this correct (that meta class size is never computed)? uint32_t InstanceStart = CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ClassnfABITy); @@ -6004,9 +6003,11 @@ void CGObjCNonFragileABIMac::GenerateCla llvm::GlobalVariable *SuperClassGV, *IsAGV; + const auto *CI = ID->getClassInterface(); + assert(CI && "CGObjCNonFragileABIMac::GenerateClass - class is 0"); + // Build the flags for the metaclass. - bool classIsHidden = -ID->getClassInterface()->getVisibility() == HiddenVisibility; + bool classIsHidden = CI->getVisibility() == HiddenVisibility; if (classIsHidden) flags |= NonFragileABI_Class_Hidden; @@ -6018,42 +6019,43 @@ void CGObjCNonFragileABIMac::GenerateCla flags |= NonFragileABI_Class_HasCXXDestructorOnly; } - if (!ID->getClassInterface()->getSuperClass()) { + if (!CI->getSuperClass()) { // class is root flags |= NonFragileABI_Class_Root; + TClassName = ObjCClassName; TClassName += ClassName; -SuperClassGV = GetClassGlobal(TClassName.str(), - ID->getClassInterface()->isWeakImported()); +SuperClassGV = GetClassGlobal(TClassName.str(), CI->isWeakImported()); + TClassName = ObjCMetaClassName; TClassName += ClassName; -IsAGV = GetClassGlobal(TClassName.str(), - ID->getClassInterface()->isWeakImported()); +IsAGV = GetClassGlobal(TClassName.str(), CI->isWeakImported()); } else { // Has a root. Current class is not a root. const ObjCInterfaceDecl *Root = ID->getClassInterface(); while (const ObjCInterfaceDecl *Super = Root->getSuperClass()) Root = Super; + +const auto *Super = CI->getSuperClass(); + TClassName = ObjCMetaClassName ; TClassName += Root->getObjCRuntimeNameAsString(); -IsAGV = GetClassGlobal(TClassName.str(), - Root->isWeakImported()); +IsAGV = GetClassGlobal(TClassName.str(), Root->isWeakImported()); // work on super class metadata symbol. TClassName = ObjCMetaClassName; -TClassName += ID->getClassInterface()->getSuperClass()->getObjCRuntimeNameAsString(); -SuperClassGV = GetClassGlobal( - TClassName.str(), - ID->getClassInterface()->getSuperClass()->isWeakImported()); +TClassName += Super->getObjCRuntimeNameAsString(); +SuperClassGV = GetClassGlobal(TClassName.str(), Super->isWeakImported()); } - llvm::GlobalVariable *CLASS_RO_GV = BuildClassRoTInitializer(flags, - InstanceStart, - InstanceSize,ID); + + llvm::GlobalVariable *CLASS_RO_GV = + BuildClassRoTInitializer(flags, InstanceStart, InstanceSize, ID); + TClassName = ObjCMetaClassName; TClassName += ClassName; - llvm::GlobalVariable *MetaTClass = BuildClassMetaData( - TClassName.str(), IsAGV, SuperClassGV, CLASS_RO_GV, classIsHidden, - ID->getClassInterface()->isWeakImported()); + llvm::GlobalVariable *MetaTClass = + BuildClassMetaData(TClassName.str(), IsAGV, SuperClassGV, CLASS_RO_GV, + classIsHidden, CI->isWeakImported()); DefinedMetaClasses.push_back(MetaTClass); // Metadata for the class @@ -6074,34 +6076,32 @@ void CGObjCNonFragileABIMac::GenerateCla flags |= NonFragileABI_Class_HasCXXDestructorOnly; } - if (hasObjCExceptionAttribute(CGM.getContext(), ID->getClassInterface())) + if (hasObjCExceptionAttribute(CGM.getContext(), CI)) flags |= NonFragileABI_Class_Exception; - if (!ID->getClassInterface()->getSuperClass()) { + if (!CI->getSuperClass()) { flags |= NonFragileABI_Class_Root; SuperClassGV = nullptr; } else { // Has a root. Current class is not a root. +const auto *Super
Re: [PATCH] D22208: clang-tidy] Fixes to modernize-use-emplace
Prazek removed rL LLVM as the repository for this revision. Prazek updated this revision to Diff 64238. Prazek marked 6 inline comments as done. https://reviews.llvm.org/D22208 Files: clang-tidy/modernize/UseEmplaceCheck.cpp clang-tidy/modernize/UseEmplaceCheck.h clang-tidy/utils/Matchers.h docs/clang-tidy/checks/modernize-use-emplace.rst test/clang-tidy/modernize-use-emplace.cpp Index: test/clang-tidy/modernize-use-emplace.cpp === --- test/clang-tidy/modernize-use-emplace.cpp +++ test/clang-tidy/modernize-use-emplace.cpp @@ -1,4 +1,7 @@ -// RUN: %check_clang_tidy %s modernize-use-emplace %t +// RUN: %check_clang_tidy %s modernize-use-emplace %t -- \ +// RUN: -config="{CheckOptions: \ +// RUN: [{key: modernize-use-emplace.ContainersWithPushBack, \ +// RUN: value: '::std::vector; ::std::list; ::std::deque; llvm::LikeASmallVector'}]}" -- -std=c++11 namespace std { template @@ -9,6 +12,7 @@ template void emplace_back(Args &&... args){}; + ~vector(); }; template class list { @@ -18,6 +22,7 @@ template void emplace_back(Args &&... args){}; + ~list(); }; template @@ -28,6 +33,7 @@ template void emplace_back(Args &&... args){}; + ~deque(); }; template @@ -54,10 +60,24 @@ template class unique_ptr { public: - unique_ptr(T *) {} + explicit unique_ptr(T *) {} + ~unique_ptr(); }; } // namespace std +namespace llvm { +template +class LikeASmallVector { +public: + void push_back(const T &) {} + void push_back(T &&) {} + + template + void emplace_back(Args &&... args){}; +}; + +} // llvm + void testInts() { std::vector v; v.push_back(42); @@ -117,6 +137,23 @@ v.push_back(s); } +template +void dependOnElem() { + std::vector v; + v.push_back(ElemType(42)); +} + +template +void dependOnContainer() { + ContainerType v; + v.push_back(Something(42)); +} + +void callDependent() { + dependOnElem(); + dependOnContainer>(); +} + void test2() { std::vector v; v.push_back(Zoz(Something(21, 37))); @@ -130,12 +167,20 @@ v.push_back(getZoz(Something(1, 2))); } +struct GetPair { + std::pair getPair(); +}; void testPair() { std::vector> v; v.push_back(std::pair(1, 2)); // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back // CHECK-FIXES: v.emplace_back(1, 2); + GetPair g; + v.push_back(g.getPair()); + // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back + // CHECK-FIXES: v.emplace_back(g.getPair()); + std::vector> v2; v2.push_back(std::pair(Something(42, 42), Zoz(Something(21, 37; // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use emplace_back @@ -206,14 +251,14 @@ v.push_back(new int(5)); std::vector> v2; - v2.push_back(new int(42)); + v2.push_back(std::unique_ptr(new int(42))); // This call can't be replaced with emplace_back. // If emplacement will fail (not enough memory to add to vector) // we will have leak of int because unique_ptr won't be constructed // (and destructed) as in push_back case. auto *ptr = new int; - v2.push_back(ptr); + v2.push_back(std::unique_ptr(ptr)); // Same here } @@ -240,6 +285,11 @@ d.push_back(Something(42)); // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back // CHECK-FIXES: d.emplace_back(42); + + llvm::LikeASmallVector ls; + ls.push_back(Something(42)); + // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use emplace_back + // CHECK-FIXES: ls.emplace_back(42); } class IntWrapper { @@ -336,3 +386,16 @@ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back // CHECK-FIXES: v.emplace_back(42, var); } + +struct WithDtor { + WithDtor(int) {} + ~WithDtor(); +}; + +void testWithDtor() { + std::vector v; + + v.push_back(WithDtor(42)); + // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back + // CHECK-FIXES: v.emplace_back(42); +} Index: docs/clang-tidy/checks/modernize-use-emplace.rst === --- docs/clang-tidy/checks/modernize-use-emplace.rst +++ docs/clang-tidy/checks/modernize-use-emplace.rst @@ -4,28 +4,36 @@ = This check looks for cases when inserting new element into an STL -container (``std::vector``, ``std::deque``, ``std::list``) or ``llvm::SmallVector`` -but the element is constructed temporarily. +container, but the element is constructed temporarily. + +By default only ``std::vector``, ``std::deque``, ``std::list`` are considered. +This list can be modified by passing a `;` separated list of class names using the `ContainersWithPushBack` +option. + Before: .. code:: c++ std::vector v; v.push_back(MyClass(21, 37)); - std::vector > w; - w.push_back(std::make_pair(21, 37)); + std::vector> w; + + w.push_back(std::pair(21, 37)); + w.push_back(std::make_pair(21L, 37L)); After: .. code:: c++ std::vector v; v.emplace_back(21, 37); - std::vector > w; - v.emplace_back(21,
r275699 - [CodeGen] Some assorted cleanups
Author: majnemer Date: Sat Jul 16 19:39:12 2016 New Revision: 275699 URL: http://llvm.org/viewvc/llvm-project?rev=275699&view=rev Log: [CodeGen] Some assorted cleanups No functional change, just some cleanups: - Use auto when it is appropriate. - There were some strange static_casts which were superfluous. - Use range-based for loops when appropriate. - The dyn_cast_or_null construct was used when null was impossible. Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=275699&r1=275698&r2=275699&view=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Sat Jul 16 19:39:12 2016 @@ -169,10 +169,10 @@ llvm::DIScope *CGDebugInfo::getContextDe } // Check namespace. - if (const NamespaceDecl *NSDecl = dyn_cast(Context)) + if (const auto *NSDecl = dyn_cast(Context)) return getOrCreateNameSpace(NSDecl); - if (const RecordDecl *RDecl = dyn_cast(Context)) + if (const auto *RDecl = dyn_cast(Context)) if (!RDecl->isDependentType()) return getOrCreateType(CGM.getContext().getTypeDeclType(RDecl), getOrCreateMainFile()); @@ -222,21 +222,18 @@ StringRef CGDebugInfo::getObjCMethodName llvm::raw_svector_ostream OS(MethodName); OS << (OMD->isInstanceMethod() ? '-' : '+') << '['; const DeclContext *DC = OMD->getDeclContext(); - if (const ObjCImplementationDecl *OID = - dyn_cast(DC)) { + if (const auto *OID = dyn_cast(DC)) { OS << OID->getName(); - } else if (const ObjCInterfaceDecl *OID = - dyn_cast(DC)) { + } else if (const auto *OID = dyn_cast(DC)) { OS << OID->getName(); - } else if (const ObjCCategoryDecl *OC = dyn_cast(DC)) { + } else if (const auto *OC = dyn_cast(DC)) { if (OC->IsClassExtension()) { OS << OC->getClassInterface()->getName(); } else { - OS << ((const NamedDecl *)OC)->getIdentifier()->getNameStart() << '(' + OS << OC->getIdentifier()->getNameStart() << '(' << OC->getIdentifier()->getNameStart() << ')'; } - } else if (const ObjCCategoryImplDecl *OCD = - dyn_cast(DC)) { + } else if (const auto *OCD = dyn_cast(DC)) { OS << ((const NamedDecl *)OCD)->getIdentifier()->getNameStart() << '(' << OCD->getIdentifier()->getNameStart() << ')'; } else if (isa(DC)) { @@ -846,7 +843,7 @@ llvm::DIType *CGDebugInfo::CreateType(co OS, Ty->template_arguments(), CGM.getContext().getPrintingPolicy()); - TypeAliasDecl *AliasDecl = cast( + auto *AliasDecl = cast( Ty->getTemplateName().getAsTemplateDecl())->getTemplatedDecl(); SourceLocation Loc = AliasDecl->getLocation(); @@ -912,9 +909,9 @@ llvm::DIType *CGDebugInfo::CreateType(co // otherwise emit it as a variadic function. if (isa(Ty)) EltTys.push_back(DBuilder.createUnspecifiedParameter()); - else if (const FunctionProtoType *FPT = dyn_cast(Ty)) { -for (unsigned i = 0, e = FPT->getNumParams(); i != e; ++i) - EltTys.push_back(getOrCreateType(FPT->getParamType(i), Unit)); + else if (const auto *FPT = dyn_cast(Ty)) { +for (const QualType &ParamType : FPT->param_types()) + EltTys.push_back(getOrCreateType(ParamType, Unit)); if (FPT->isVariadic()) EltTys.push_back(DBuilder.createUnspecifiedParameter()); } @@ -1097,7 +1094,7 @@ void CGDebugInfo::CollectRecordFields( const RecordDecl *record, llvm::DIFile *tunit, SmallVectorImpl &elements, llvm::DICompositeType *RecordTy) { - const CXXRecordDecl *CXXDecl = dyn_cast(record); + const auto *CXXDecl = dyn_cast(record); if (CXXDecl && CXXDecl->isLambda()) CollectRecordLambdaFields(CXXDecl, elements, RecordTy); @@ -1201,7 +1198,7 @@ llvm::DISubroutineType *CGDebugInfo::get /// isFunctionLocalClass - Return true if CXXRecordDecl is defined /// inside a function. static bool isFunctionLocalClass(const CXXRecordDecl *RD) { - if (const CXXRecordDecl *NRD = dyn_cast(RD->getDeclContext())) + if (const auto *NRD = dyn_cast(RD->getDeclContext())) return isFunctionLocalClass(NRD); if (isa(RD->getDeclContext())) return true; @@ -1283,11 +1280,10 @@ llvm::DISubprogram *CGDebugInfo::CreateC if (Method->isImplicit()) Flags |= llvm::DINode::FlagArtificial; Flags |= getAccessFlag(Method->getAccess(), Method->getParent()); - if (const CXXConstructorDecl *CXXC = dyn_cast(Method)) { + if (const auto *CXXC = dyn_cast(Method)) { if (CXXC->isExplicit()) Flags |= llvm::DINode::FlagExplicit; - } else if (const CXXConversionDecl *CXXC = - dyn_cast(Method)) { + } else if (const auto *CXXC = dyn_cast(Method)) { if (CXXC->isExplicit()) Flags |= llvm::DINode::FlagExplicit; } @@ -1356,7 +1352,7 @@ void CGDebugInfo::CollectCXXBases(const unsigned