LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 28334 - modernize-use-using problems: template types, namespaces
Summary: modernize-use-using problems: template types, namespaces
Status: RESOLVED FIXED
Alias: None
Product: clang-tools-extra
Classification: Unclassified
Component: clang-tidy (show other bugs)
Version: unspecified
Hardware: PC Linux
: P normal
Assignee: Krystyna Gajczyk
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-27 16:19 PDT by Eugene Zelenko
Modified: 2017-04-02 12:30 PDT (History)
6 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Zelenko 2016-06-27 16:19:42 PDT
Looks like modernize-use-using  suggest to replace type from template parameters with actual type passed to template.

To reproduce run check over LLVM code base with -header-filter=".*" and search include/llvm/ADT/SmallPtrSet.h:237:3.
Comment 1 Eugene Zelenko 2016-06-27 20:13:44 PDT
Other encountered problem: namespace is inserted when template is located in llvm namespace.

include/llvm/Support/CommandLine.h:478:3: warning: use 'using' instead of 'typedef' [modernize-use-using]
  typedef StringRef WrapperType;
  ^
  using WrapperType = llvm::StringRef
Comment 2 Eugene Zelenko 2016-06-27 20:41:17 PDT
Constants defined in enum is replaced with actual value in fix-it:

tools/clang/include/clang/Basic/AddressSpaces.h:45:1: warning: use 'using' instead of 'typedef' [modernize-use-using]
typedef unsigned Map[Count];
^
using Map = unsigned int [7]
Comment 3 Piotr Padlewski 2016-07-19 16:34:32 PDT
There is also other thing that Krystyna told me about:
It gives many warnings when you use some macro that uses typedefs inside like the ones in gtest. Perhaps there it should warn about ones in macros only when some special option is enabled.
Comment 4 Alexander Kornienko 2016-08-02 14:54:53 PDT
Piotr, do you know whether Krystyna is planning to work on this?
Comment 5 Piotr Padlewski 2016-08-02 15:07:15 PDT
We don't work together because she is moving to another city. I remember that she said that she is planning to fix it sometime, but I don't think it will be in next 2 months. I know she is not doing any work right now.
Comment 6 Krystyna Gajczyk 2016-08-03 18:38:18 PDT
I'm planning to fix this, but I do not have possibility to do it before second half of September because I do not have a good computer right now.
Comment 7 Alexander Kornienko 2016-08-04 05:51:34 PDT
Krystyna, thank you for the information! I'm assigning the issue to you then. Feel free to unassign, if you realize that you're not going to work on this.
Comment 8 Malcolm Parsons 2016-09-06 11:10:10 PDT
Another problem:

typedef.cpp:1:1: warning: use 'using' instead of 'typedef' [modernize-use-using]
typedef struct foo_s { int i; } * foo_t;
^
using foo_t = struct foo_s *

I'd expect the fixit to create this:

struct foo_s { int i; };
using foo_t = foo_s *;
Comment 9 Alexander Kornienko 2017-01-24 05:44:30 PST
(In reply to comment #8)
> Another problem:
> 
> typedef.cpp:1:1: warning: use 'using' instead of 'typedef'
> [modernize-use-using]
> typedef struct foo_s { int i; } * foo_t;
> ^
> using foo_t = struct foo_s *
> 
> I'd expect the fixit to create this:
> 
> struct foo_s { int i; };
> using foo_t = foo_s *;

I've added a workaround for this in r292918. Actually, it would be more convenient to have a separate bug for each of these issues with isolated and reduced test cases.
Comment 10 Alexander Kornienko 2017-01-24 05:46:18 PST
Please file a separate bug with a corresponding isolated test case for each of these issues.
Comment 11 Krystyna Gajczyk 2017-01-29 15:21:59 PST
(In reply to comment #0)
> Looks like modernize-use-using  suggest to replace type from template
> parameters with actual type passed to template.
> 
> To reproduce run check over LLVM code base with -header-filter=".*" and
> search include/llvm/ADT/SmallPtrSet.h:237:3.

I was not able to reproduce this problem. In the line 280 (which was previously 237 line) code:

template<typename PtrTy>
class SmallPtrSetIterator : public SmallPtrSetIteratorImpl {

public:
  typedef PtrTy                     reference;
} 

is changed to:

template<typename PtrTy>
class SmallPtrSetIterator : public SmallPtrSetIteratorImpl {

public:
  using reference = PtrTy;

} 

Can you try to reproduce this error once again and open a bug if you find it?
Comment 12 Eugene Zelenko 2017-01-29 20:10:40 PST
Alexander did some fixes in r292918. May be this problem was fixed there?
Comment 13 Krystyna Gajczyk 2017-01-30 07:44:25 PST
Solutions for some bugs in https://reviews.llvm.org/D29262

Remaining bug is now in: https://llvm.org/bugs/show_bug.cgi?id=31793