[cfe-users] How to use clang-apply-replacements with clang-tidy fixit file

2019-04-26 Thread Robert Ankeney via cfe-users
I used clang-tidy to generate some replacements for a code base into a yaml
file using the -export-fixits=file option. After editing the file to remove
some unwanted changes, I would like to apply those fixes. The documentation
says to use clang-apply-replacements, but I don't see how do use it to do
that. It looks more like it's designed to work with clang-format.
Any suggestions?

Many thanks,
Robert
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] How to use clang-apply-replacements with clang-tidy fixit file

2019-04-29 Thread Robert Ankeney via cfe-users
I used the run-clang-tidy script to operate across a large compilation
database using:

run-clang-tidy.py -header-filter=.*
-checks=-*,-cppcoreguidelines-pro-type-member-init -export-fixes=ctinit.yaml

This generated a large YAML fixit file. I've since edited the file to
remove and/or change some of the fixits. I'm now writing a program to split
the results into a set of file by file fixits with duplicates removed so I
can apply the results in stages.

Robert

On Fri, Apr 26, 2019 at 2:11 PM Christian Gagneraud 
wrote:

> On Sat, 27 Apr 2019 at 09:01, Robert Ankeney  wrote:
> >
> > Hi Chris,
> >
> > Thanks for the fast response! As it turns out, I was doing that, but
> found that there must be some edit in my .yaml file it doesn't like, as it
> simply returned without doing anything. Making a short subset of the file
> worked fine, so I'm looking at breaking it into pieces to see if I can
> narrow it down. On the first cut, it at least did warn me about some
> duplicate replacements and exited.
> >
>
> Feel free to submit bug report and/or suggestion:
> https://llvm.org/docs/HowToSubmitABug.html
>
> What program do you use to generate the replacement files?
>
> Chris
>
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] clang-tidy bug?

2019-10-27 Thread Robert Ankeney via cfe-users
For the following code (wrong.cpp):

bool check(bool isValid)
{
bool retVal = false;

if (( isValid == true ))
{
retVal = true;
}

return retVal;
}

when I run:
clang-tidy -checks=modernize-use-default-member-init wrong.cpp

I get:
4 warnings and 1 error generated.
Error while processing /llvm/match/ctBad/wrong.cpp.
/llvm/match/ctBad/wrong.cpp:5:19: error: equality comparison with
extraneous parentheses [clang-diagnostic-parentheses-equality]
if (( isValid == true ))
~ ^~  ~
  =
/llvm/match/ctBad/wrong.cpp:5:19: note: remove extraneous parentheses
around the comparison to silence this warning
/llvm/match/ctBad/wrong.cpp:5:19: note: use '=' to turn this equality
comparison into an assignment

Note it turns the if into:
if ( isValid = true )

Seems like a very bad idea. Removing the redundant parentheses seems fine,
but changing the comparison to an assignment does not. Is this a bug?

Thanks,
Robert
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] DeclRefExpr question

2019-12-03 Thread Robert Ankeney via cfe-users
Let's assume I have a DeclRefExpr that is referenceing some variable that
is declared as "static const int var;". How can I determine the variable is
static? There is no isStaticLocal() or getStorageClass() call as there
would be for the VarDecl. Is there something within the QualType that gets
me that info?

Many thanks,
Robert
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] DeclRefExpr question

2019-12-03 Thread Robert Ankeney via cfe-users
Worked great! Many thanks!

Robert


On Tue, Dec 3, 2019 at 10:43 AM David Blaikie  wrote:

> I'd guess you'd call "getDecl" to get the decl the DeclRefExpr is
> referencing, then dyn_cast that (the decl is a ValueDecl*) to VarDecl to
> see if it's a variable that's being referenced (could be a function, etc,
> etc) then do whatever you want to do with that VarDecl.
>
> On Tue, Dec 3, 2019 at 1:33 PM Robert Ankeney via cfe-users <
> cfe-users@lists.llvm.org> wrote:
>
>> Let's assume I have a DeclRefExpr that is referenceing some variable that
>> is declared as "static const int var;". How can I determine the variable is
>> static? There is no isStaticLocal() or getStorageClass() call as there
>> would be for the VarDecl. Is there something within the QualType that gets
>> me that info?
>>
>> Many thanks,
>> Robert
>>
>> ___
>> cfe-users mailing list
>> cfe-users@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
>>
>
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] How to determine if variable is templated?

2020-02-16 Thread Robert Ankeney via cfe-users
Suppose I have some code like:

template
Type tVar;
function(tVar);

How can I determine that tVar is templated from the VarDecl or a
MemberExpr? I don't see any obvious function in QualType or Type.

Thanks,
Robert
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] cfe-users Digest, Vol 85, Issue 8

2020-02-20 Thread Robert Ankeney via cfe-users
David - thanks for your suggestions, but no luck here. I had hoped for
something like a isTemplateTypeParam() function in QualType, but no such
luck. In many cases, if I do a getCanonicalType().getAsString() I get a
"type-parameter-0-0" as a result. Though not always. I don't even always
see "Type" returned if I do a getUnqualifiedType().getAsString(). I had
hoped for a simple function call, as these template parameters seem like
generic types.

Robert

On Mon, Feb 17, 2020 at 11:58 AM via cfe-users 
wrote:

> Send cfe-users mailing list submissions to
> cfe-users@lists.llvm.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
> or, via email, send a message with subject or body 'help' to
> cfe-users-requ...@lists.llvm.org
>
> You can reach the person managing the list at
> cfe-users-ow...@lists.llvm.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of cfe-users digest..."
>
>
> Today's Topics:
>
>1. How to determine if variable is templated?
>   (Robert Ankeney via cfe-users)
>2. Re: How to determine if variable is templated?
>   (David Blaikie via cfe-users)
>
>
> ------------------
>
> Message: 1
> Date: Sun, 16 Feb 2020 17:43:19 -0800
> From: Robert Ankeney via cfe-users 
> To: via cfe-users 
> Subject: [cfe-users] How to determine if variable is templated?
> Message-ID:
> <
> cajl6gzpylbnx8iydxnzzsxobnf5_jaege+wvxdw233cvo-t...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Suppose I have some code like:
>
> template
> Type tVar;
> function(tVar);
>
> How can I determine that tVar is templated from the VarDecl or a
> MemberExpr? I don't see any obvious function in QualType or Type.
>
> Thanks,
> Robert
> -- next part --
> An HTML attachment was scrubbed...
> URL: <
> http://lists.llvm.org/pipermail/cfe-users/attachments/20200216/2a886f3a/attachment-0001.html
> >
>
> --
>
> Message: 2
> Date: Mon, 17 Feb 2020 09:28:51 -0800
> From: David Blaikie via cfe-users 
> To: Robert Ankeney 
> Cc: via cfe-users 
> Subject: Re: [cfe-users] How to determine if variable is templated?
> Message-ID:
> <
> caens6evh8eyvo+h4ezju8gkdkxoxj7uzkt8bjyty+2inhkd...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Guessing these sort of functions would be relevant:
>
> https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html#a617bcdd5baaab0ccba71a96cd9c2ed03
>
> On Sun, Feb 16, 2020 at 5:43 PM Robert Ankeney via cfe-users <
> cfe-users@lists.llvm.org> wrote:
>
> > Suppose I have some code like:
> >
> > template
> > Type tVar;
> > function(tVar);
> >
> > How can I determine that tVar is templated from the VarDecl or a
> > MemberExpr? I don't see any obvious function in QualType or Type.
> >
> > Thanks,
> > Robert
> >
> > ___
> > cfe-users mailing list
> > cfe-users@lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
> >
> -- next part --
> An HTML attachment was scrubbed...
> URL: <
> http://lists.llvm.org/pipermail/cfe-users/attachments/20200217/fda6a48f/attachment-0001.html
> >
>
> --
>
> Subject: Digest Footer
>
> ___
> cfe-users mailing list
> cfe-users@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
>
>
> --
>
> End of cfe-users Digest, Vol 85, Issue 8
> 
>
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] Template parameter matcher?

2020-06-23 Thread Robert Ankeney via cfe-users
I'm looking for a matcher for variables whose type is a template parameter.
For example:

template
T tVal;   // Match tVal
int func(T tParam);   // Match tParam
int i = func(tVal);   // Match tVal

Our coding standards require the variable to have a 't' at the start of the
variable name.
Looking at the matcher reference, I didn't see anything obvious. Can anyone
point me the right direction?

Many thanks,
Robert
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] Order of matchers

2020-07-20 Thread Robert Ankeney via cfe-users
I have a tool with multiple matchers. Each different matcher is added to
MatchFinder with a call to addMatcher(). It seems like the order of matches
that are called isn't dependent on the order I added them with addMatcher.
To give a specific example, I'm looking to match variables whose type is a
template parameter (matcher 1) using
fieldDecl(hasType(templateTypeParmType())), which works fine. If I want to
also have a matcher 2 just for fieldDecl(), that matcher is always called
before the more specific template parameter matcher 1.
I tried looking for template parameters inside the fieldDecl matcher with a
"if (isa(TY))", where TY is the FieldDecl type, but
with no success. Instead the type appears to have been already determined
(e.g. float). So is there a way to assure the order that matchers are
called?

Thanks,
Robert
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] clang-format feature request

2021-06-29 Thread Robert Ankeney via cfe-users
I'm not sure where best to post this, but I'd like to see a couple of
features added to clang-format, and from browsing around, have seen others
looking for these features, too.
1) Ability to break declaration parameters into groups when more than N
parameters are declared. For example, if I have more than 3 parameters
declared, I'd like to see the declaration changed to show one parameter per
line. I could imagine others would want a different grouping style, so
maybe something like BreakParametersOfDeclarationAfter: 3, and
BreakParametersOfDeclarationGroup: 1 to accomplish this.

2) Ability to force the use of braces after an if statement, much like the
clang-tidy readability-braces-around-statements option without needing to
have a compilation database in place.

Any hope this request can make it to the appropriate ears?
Thanks!

Robert
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] Matcher for templated variable

2021-08-08 Thread Robert Ankeney via cfe-users
I'm looking to create AST matchers for variables that are templated. For
example, in the code:

template  class Class  // template <(class or typename or
int/float/etc) T>
{
public:

void Func(T* Param)// 1) match Param
{
   Param = nullptr; // 2) match Param
}

T* Var = nullptr;// 3) match Var
};

int main()
{
   Class MyClass;
   float FloatVal;
   MyClass.Var = &FloatVal;  // 4) match Var
}

Ideally, I'd like one matcher to find each of the 4 matches, but I suspect
I need individual matchers for each of them.  For the first match above I
have varDecl(hasType(templateTypeParmType())), but I haven't had luck with
clang-query in finding the other 3. Any help would be much appreciated!

Thanks,
Robert
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] cfe-users Digest, Vol 105, Issue 6

2022-01-08 Thread Robert Ankeney via cfe-users
I have run into this problem before. Instead of adding more RAM to my
machine, I found that doing a "sudo make" will often succeed.

Robert


On Fri, Dec 24, 2021 at 8:09 AM via cfe-users 
wrote:

> Send cfe-users mailing list submissions to
> cfe-users@lists.llvm.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
> or, via email, send a message with subject or body 'help' to
> cfe-users-requ...@lists.llvm.org
>
> You can reach the person managing the list at
> cfe-users-ow...@lists.llvm.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of cfe-users digest..."
>
>
> Today's Topics:
>
>1. Issue with clang-13 (Sunil Kumar via cfe-users)
>2. Re: Issue with clang-13 (Csaba Raduly via cfe-users)
>3. Re: Issue with clang-13 (Matthew Fernandez via cfe-users)
>
>
> --
>
> Message: 1
> Date: Fri, 24 Dec 2021 19:20:58 +0530
> From: Sunil Kumar via cfe-users 
> To: cfe-users@lists.llvm.org
> Subject: [cfe-users] Issue with clang-13
> Message-ID:
> <
> cadmbxb6dufxcyc3egx8ae3atodr-6m0w6wenp+guzwv6d5r...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hi,
> I tried many times to install clang-13 in ubuntu-16.04. I followed the
> steps mentioned below.
>
>- git clone https://github.com/llvm/llvm-project.git
>- git checkout llvmorg-13.0.0
>- cd llvm-project
>- mkdir build
>- cd build
>- cmake -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" ../llvm
>- make
>
> After running make command, it failed to install clang eventually and
> showed some error mentioned below
> 
> make:342: recipe for target 'bin/clang-13' failed
> make[2]: *** [bin/clang-13] Error 1
> make[2]: *** Deleting file 'bin/clang-13' CMakeFiles/Makefile2:38992:
> recipe for target 'tools/clang/tools/driver/CMakeFiles/clang.dir/all'
> failed
> make[1]: *** [tools/clang/tools/driver/CMakeFiles/clang.dir/all] Error 2
> collect2: fatal error: ld terminated with signal 9 [Killed] compilation
> terminated.
> -
> Please help to resolve this bug.
> --
> Sunil Kumar
> PhD21001
> Ph.D. Scholar
> HiPeC Lab  @IIIT-Delhi
> Homepage: https://justasunil.github.io/
> -- next part --
> An HTML attachment was scrubbed...
> URL: <
> http://lists.llvm.org/pipermail/cfe-users/attachments/20211224/be232374/attachment-0001.html
> >
>
> --
>
> Message: 2
> Date: Fri, 24 Dec 2021 15:45:33 +0100
> From: Csaba Raduly via cfe-users 
> To: Sunil Kumar 
> Cc: "CFE-Users \(Clang\)" 
> Subject: Re: [cfe-users] Issue with clang-13
> Message-ID:
> <
> caehddbctgfetzds55s2fdwowxy2gtnrpvyeep-j1e_ds383...@mail.gmail.com>
> Content-Type: text/plain; charset="UTF-8"
>
> Hi Sunil,
>
> On Fri, 24 Dec 2021 at 14:51, Sunil Kumar via cfe-users
>  wrote:
> >
> > Hi,
> > I tried many times to install clang-13 in ubuntu-16.04. I followed the
> steps mentioned below.
> >
> > git clone https://github.com/llvm/llvm-project.git
> > git checkout llvmorg-13.0.0
> > cd llvm-project
> > mkdir build
> > cd build
> > cmake -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" ../llvm
> > make
> >
> > After running make command, it failed to install clang eventually and
> showed some error mentioned below
> > 
> > make:342: recipe for target 'bin/clang-13' failed
> > make[2]: *** [bin/clang-13] Error 1
> > make[2]: *** Deleting file 'bin/clang-13' CMakeFiles/Makefile2:38992:
> recipe for target 'tools/clang/tools/driver/CMakeFiles/clang.dir/all' failed
> > make[1]: *** [tools/clang/tools/driver/CMakeFiles/clang.dir/all] Error 2
> > collect2: fatal error: ld terminated with signal 9 [Killed] compilation
> terminated.
> > -
> > Please help to resolve this bug.
>
> It's not a bug in clang if you kill the linker program.
>
> If it wasn't you who killed the linker program, perhaps it was the
> out-of-memory killer. You can try to solve the out-of-memory issue:
>
> 1. Buy more memory for your computer, or
> 2. Delete the build directory, create it again, then add
> -DCMAKE_BUILD_TYPE=Release to the cmake command line, and build again.
> Debug builds require more memory, because of the large amount of debug
> info. Hopefully the release build will not run into out-of-memory.
>
> Are you using a 32-bit system by any chance?
>
> Csaba
> --
> You can get very substantial performance improvements
> by not doing the right thing. - Scott Meyers, An Effective C++11/14 Sampler
> So if you're looking for a completely portable, 100% standards-conformant
> way
> to get the wrong information: this is what you want. - S