[clang-tools-extra] r319148 - run-clang-tidy: Use check_call instead of check_output

2017-11-27 Thread Kevin Funk via cfe-commits
Author: kfunk
Date: Mon Nov 27 23:17:01 2017
New Revision: 319148

URL: http://llvm.org/viewvc/llvm-project?rev=319148=rev
Log:
run-clang-tidy: Use check_call instead of check_output

Summary:
Streamlines the output under Python 3.x.

Before:
```
b'Enabled checks:\nclang-analyzer-apiModeling.google.GTest\n ...
```

After:
```
Enabled checks:
clang-analyzer-apiModeling.google.GTest
...
```

Reviewers: cfe-commits, alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere

Differential Revision: https://reviews.llvm.org/D37482

Change-Id: I6287104bc73926ae6d0f66c15c250c3cb44bee33

Modified:
clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py

Modified: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py?rev=319148=319147=319148=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py Mon Nov 27 
23:17:01 2017
@@ -222,7 +222,7 @@ def main():
 if args.checks:
   invocation.append('-checks=' + args.checks)
 invocation.append('-')
-print(subprocess.check_output(invocation))
+subprocess.check_call(invocation)
   except:
 print("Unable to run clang-tidy.", file=sys.stderr)
 sys.exit(1)


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r312532 - Make run-clang-tidy compatible with Python 3.x

2017-09-05 Thread Kevin Funk via cfe-commits
Author: kfunk
Date: Tue Sep  5 05:36:33 2017
New Revision: 312532

URL: http://llvm.org/viewvc/llvm-project?rev=312532=rev
Log:
Make run-clang-tidy compatible with Python 3.x

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits, JDevlieghere

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D37138

Change-Id: I89a95d1e082e566e7e64c2a5ca4123c543e6b1be

Modified:
clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py

Modified: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py?rev=312532=312531=312532=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py Tue Sep  5 
05:36:33 2017
@@ -35,12 +35,12 @@ http://clang.llvm.org/docs/HowToSetupToo
 """
 
 from __future__ import print_function
+
 import argparse
 import glob
 import json
 import multiprocessing
 import os
-import Queue
 import re
 import shutil
 import subprocess
@@ -50,6 +50,12 @@ import threading
 import traceback
 import yaml
 
+is_py2 = sys.version[0] == '2'
+
+if is_py2:
+import Queue as queue
+else:
+import queue as queue
 
 def find_compilation_database(path):
   """Adjusts the directory until a compilation database is found."""
@@ -233,20 +239,20 @@ def main():
 
   try:
 # Spin up a bunch of tidy-launching threads.
-queue = Queue.Queue(max_task)
+task_queue = queue.Queue(max_task)
 for _ in range(max_task):
   t = threading.Thread(target=run_tidy,
-   args=(args, tmpdir, build_path, queue))
+   args=(args, tmpdir, build_path, task_queue))
   t.daemon = True
   t.start()
 
 # Fill the queue with files.
 for name in files:
   if file_name_re.search(name):
-queue.put(name)
+task_queue.put(name)
 
 # Wait for all threads to be done.
-queue.join()
+task_queue.join()
 
   except KeyboardInterrupt:
 # This is a sad hack. Unfortunately subprocess goes


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r308975 - [clang-tidy] Fixup clang-apply-replacements/invalid-files test

2017-07-25 Thread Kevin Funk via cfe-commits
Author: kfunk
Date: Tue Jul 25 07:39:08 2017
New Revision: 308975

URL: http://llvm.org/viewvc/llvm-project?rev=308975=rev
Log:
[clang-tidy] Fixup clang-apply-replacements/invalid-files test

Modified:
clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp

Modified: 
clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp?rev=308975=308974=308975=diff
==
--- clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp Tue 
Jul 25 07:39:08 2017
@@ -1,5 +1,6 @@
 // RUN: mkdir -p %T/invalid-files
+// RUN: cp %S/Inputs/invalid-files/invalid-files.yaml 
%T/invalid-files/invalid-files.yaml
 // RUN: clang-apply-replacements %T/invalid-files
 //
 // Check that the yaml files are *not* deleted after running 
clang-apply-replacements without remove-change-desc-files.
-// RUN: ls %T/Inputs/invalid-files/invalid-files.yaml
+// RUN: ls %T/invalid-files/invalid-files.yaml


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r308974 - [clang-tidy] clang-apply-replacements: Don't insert null entry

2017-07-25 Thread Kevin Funk via cfe-commits
Author: kfunk
Date: Tue Jul 25 07:28:16 2017
New Revision: 308974

URL: http://llvm.org/viewvc/llvm-project?rev=308974=rev
Log:
[clang-tidy] clang-apply-replacements: Don't insert null entry

Summary:
[clang-tidy] clang-apply-replacements: Don't insert null entry

Fix crash when running clang-apply-replacements on YML files which
contain an invalid file path. Make sure we never add a nullptr into the
map. The previous code started adding nullptr to the map after the first
warnings via errs() has been emitted.

Backtrace:
```
Starting program:
/home/kfunk/devel/build/llvm/bin/clang-apply-replacements /tmp/tmpIqtp7m
[Thread debugging using libthread_db enabled]
Using host libthread_db library
"/lib/x86_64-linux-gnu/libthread_db.so.1".
Described file 
'.moc/../../../../../../src/qt5.8/qtremoteobjects/src/remoteobjects/qremoteobjectregistrysource_p.h'
 doesn't exist. Ignoring...
...

Program received signal SIGSEGV, Segmentation fault.
main (argc=, argv=) at 
/home/kfunk/devel/src/llvm/tools/clang/tools/extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp:262
(gdb) p FileAndReplacements.first
$1 = (const clang::FileEntry *) 0x0
(gdb)
```

Added tests.

Before patch:

```
 TEST 'Clang Tools :: 
clang-apply-replacements/invalid-files.cpp' FAILED 
Script:
--
mkdir -p 
/home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/invalid-files
clang-apply-replacements 
/home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/invalid-files
ls -1 
/home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/Inputs/invalid-files
 | FileCheck 
/home/kfunk/devel/src/llvm/tools/clang/tools/extra/test/clang-apply-replacements/invalid-files.cpp
 --check-prefix=YAML
--
Exit Code: 139

Command Output (stderr):
--
Described file 'idonotexist.h' doesn't exist. Ignoring...
/home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-replacements/Output/invalid-files.cpp.script:
 line 4:  9919 Segmentation fault  clang-apply-replacements 
/home/kfunk/devel/build/llvm/tools/clang/tools/extra/test/clang-apply-   
replacements/Output/Inputs/invalid-files

--
```

After Patch:

```
PASS: Clang Tools :: clang-apply-replacements/invalid-files.cpp (5 of 6)
```

Reviewers: alexfh, yawanng

Reviewed By: alexfh

Subscribers: cfe-commits, klimek, JDevlieghere, xazax.hun

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D35194

Added:
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/invalid-files/

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/invalid-files/invalid-files.yaml
clang-tools-extra/trunk/test/clang-apply-replacements/invalid-files.cpp
Modified:

clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

Modified: 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp?rev=308974=308973=308974=diff
==
--- 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
 Tue Jul 25 07:28:16 2017
@@ -288,13 +288,12 @@ bool mergeAndDeduplicate(const TUReplace
 for (const tooling::Replacement  : TU.Replacements) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-   << "' doesn't exist. Ignoring...\n";
-continue;
+  if (const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath())) {
+GroupedReplacements[Entry].push_back(R);
+  } else if (Warned.insert(R.getFilePath()).second) {
+  errs() << "Described file '" << R.getFilePath()
+ << "' doesn't exist. Ignoring...\n";
   }
-  GroupedReplacements[Entry].push_back(R);
 }
   }
 
@@ -314,13 +313,12 @@ bool mergeAndDeduplicate(const TUDiagnos
 for (const tooling::Replacement  : Fix.second) {
   // Use the file manager to deduplicate paths. FileEntries are
   // automatically canonicalized.
-  const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath());
-  if (!Entry && Warned.insert(R.getFilePath()).second) {
-errs() << "Described file '" << R.getFilePath()
-   << "' doesn't exist. Ignoring...\n";
-continue;
+  if (const FileEntry *Entry = 
SM.getFileManager().getFile(R.getFilePath())) {
+GroupedReplacements[Entry].push_back(R);
+  } 

r296098 - Add clazy to external Clang examples page

2017-02-24 Thread Kevin Funk via cfe-commits
Author: kfunk
Date: Fri Feb 24 02:29:46 2017
New Revision: 296098

URL: http://llvm.org/viewvc/llvm-project?rev=296098=rev
Log:
Add clazy to external Clang examples page

Reviewers: silvas, rizsotto.mailinglist, sergio.martins

Reviewed By: rizsotto.mailinglist

Differential Revision: https://reviews.llvm.org/D30252

Modified:
cfe/trunk/docs/ExternalClangExamples.rst

Modified: cfe/trunk/docs/ExternalClangExamples.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ExternalClangExamples.rst?rev=296098=296097=296098=diff
==
--- cfe/trunk/docs/ExternalClangExamples.rst (original)
+++ cfe/trunk/docs/ExternalClangExamples.rst Fri Feb 24 02:29:46 2017
@@ -85,3 +85,8 @@ List of projects and tools
 errors, fixit hints).  See also ``_ for
 step-by-step instructions."
 
+``_
+   "clazy is a compiler plugin which allows clang to understand Qt semantics.
+   You get more than 50 Qt related compiler warnings, ranging from unneeded
+   memory allocations to misusage of API, including fix-its for automatic
+   refactoring."


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290172 - Fix for clang_Cursor_getSpellingNameRange()

2016-12-20 Thread Kevin Funk via cfe-commits
Author: kfunk
Date: Tue Dec 20 03:56:56 2016
New Revision: 290172

URL: http://llvm.org/viewvc/llvm-project?rev=290172=rev
Log:
Fix for clang_Cursor_getSpellingNameRange()

Summary:
Fixes spelling name ranges for user-defined string literal operators.

Example:
  constexpr int operator""_toint(unsigned long long val)
  { return int(val); }

Before this patch the spelling name range on consisted of 'operator'.

After this patch: 'operator""_toint'.

Related to http://reviews.llvm.org/D5041, which fixes the function for
other cursor kinds.

Reviewers: akyrtzi, craigt, skalinichev, klimek, milianw, bkramer

Subscribers: cfe-commits

Tags: #clang-c

Differential Revision: https://reviews.llvm.org/D18462

Modified:
cfe/trunk/test/Index/get-cursor.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/test/Index/get-cursor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/get-cursor.cpp?rev=290172=290171=290172=diff
==
--- cfe/trunk/test/Index/get-cursor.cpp (original)
+++ cfe/trunk/test/Index/get-cursor.cpp Tue Dec 20 03:56:56 2016
@@ -143,6 +143,8 @@ void test(TestColl coll) {
   }
 }
 
+const int operator""_toint(unsigned long long val) { return int(val); }
+
 // RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck 
-check-prefix=CHECK-COMPLETION-1 %s
 // CHECK-COMPLETION-1: CXXConstructor=X:6:3
 // CHECK-COMPLETION-1-NEXT: Completion string: {TypedText X}{LeftParen 
(}{Placeholder int}{Comma , }{Placeholder int}{RightParen )}
@@ -207,7 +209,7 @@ void test(TestColl coll) {
 // RUN: c-index-test -cursor-at=%s:66:23 %s | FileCheck 
-check-prefix=CHECK-TEMPLSPEC %s
 // CHECK-TEMPLSPEC: 66:23 ClassDecl=TC:66:23 (Definition) [Specialization of 
TC:59:7] Extent=[66:1 - 66:31] Spelling=TC ([66:23 - 66:25])
 
-// RUN: c-index-test -cursor-at=%s:69:3 -cursor-at=%s:70:11 -cursor-at=%s:73:6 
-cursor-at=%s:74:6 -cursor-at=%s:77:8 -cursor-at=%s:78:8 -cursor-at=%s:79:8 
-cursor-at=%s:80:8 -cursor-at=%s:81:8 -cursor-at=%s:82:8 -cursor-at=%s:85:6 
-cursor-at=%s:86:6 -cursor-at=%s:87:6 -cursor-at=%s:88:6 -cursor-at=%s:91:5 
-cursor-at=%s:92:5 -cursor-at=%s:93:5 -cursor-at=%s:94:5 -cursor-at=%s:95:5 
-cursor-at=%s:96:5 -cursor-at=%s:97:5 -cursor-at=%s:98:5 -cursor-at=%s:100:5 
-cursor-at=%s:101:5 -cursor-at=%s:104:6 -cursor-at=%s:105:6 -cursor-at=%s:106:6 
-cursor-at=%s:107:6 -cursor-at=%s:108:6 -cursor-at=%s:109:6 -cursor-at=%s:110:6 
-cursor-at=%s:111:6 -cursor-at=%s:113:6 -cursor-at=%s:114:6 -cursor-at=%s:117:8 
-cursor-at=%s:118:8 -cursor-at=%s:120:8 -cursor-at=%s:121:8 -cursor-at=%s:122:8 
-cursor-at=%s:123:8 -cursor-at=%s:124:8 -cursor-at=%s:125:8 -cursor-at=%s:128:6 
-cursor-at=%s:129:6 -cursor-at=%s:130:6 -cursor-at=%s:132:3 -std=c++11 %s | 
FileCheck -check-prefix=CHECK-SPELLING %s
+// RUN: c-index-test -cursor-at=%s:69:3 -cursor-at=%s:70:11 -cursor-at=%s:73:6 
-cursor-at=%s:74:6 -cursor-at=%s:77:8 -cursor-at=%s:78:8 -cursor-at=%s:79:8 
-cursor-at=%s:80:8 -cursor-at=%s:81:8 -cursor-at=%s:82:8 -cursor-at=%s:85:6 
-cursor-at=%s:86:6 -cursor-at=%s:87:6 -cursor-at=%s:88:6 -cursor-at=%s:91:5 
-cursor-at=%s:92:5 -cursor-at=%s:93:5 -cursor-at=%s:94:5 -cursor-at=%s:95:5 
-cursor-at=%s:96:5 -cursor-at=%s:97:5 -cursor-at=%s:98:5 -cursor-at=%s:100:5 
-cursor-at=%s:101:5 -cursor-at=%s:104:6 -cursor-at=%s:105:6 -cursor-at=%s:106:6 
-cursor-at=%s:107:6 -cursor-at=%s:108:6 -cursor-at=%s:109:6 -cursor-at=%s:110:6 
-cursor-at=%s:111:6 -cursor-at=%s:113:6 -cursor-at=%s:114:6 -cursor-at=%s:117:8 
-cursor-at=%s:118:8 -cursor-at=%s:120:8 -cursor-at=%s:121:8 -cursor-at=%s:122:8 
-cursor-at=%s:123:8 -cursor-at=%s:124:8 -cursor-at=%s:125:8 -cursor-at=%s:128:6 
-cursor-at=%s:129:6 -cursor-at=%s:130:6 -cursor-at=%s:132:3 
-cursor-at=%s:146:15 -std=c++11 %s | FileCheck -check-prefix=CHECK-SPELLING %
 s
 // CHECK-SPELLING: 69:3 CXXConstructor=A:69:3 (default constructor) 
Extent=[69:3 - 69:6] Spelling=A ([69:3 - 69:4])
 // CHECK-SPELLING: 70:11 CXXDestructor=~A:70:11 (virtual) Extent=[70:3 - 
70:15] Spelling=~A ([70:11 - 70:13])
 // CHECK-SPELLING: 73:6 CXXMethod=operator=:73:6 Extent=[73:3 - 73:25] 
Spelling=operator= ([73:6 - 73:15])
@@ -254,6 +256,7 @@ void test(TestColl coll) {
 // CHECK-SPELLING: 129:6 CXXMethod=operator->:129:6 Extent=[129:3 - 129:18] 
Spelling=operator-> ([129:6 - 129:16])
 // CHECK-SPELLING: 130:6 CXXMethod=operator():130:6 (const) Extent=[130:3 - 
130:37] Spelling=operator() ([130:6 - 130:16])
 // CHECK-SPELLING: 132:12 CXXConversion=operator bool:132:12 (const) 
Extent=[132:3 - 132:33] Spelling=operator bool ([132:12 - 132:25])
+// CHECK-SPELLING: 146:11 FunctionDecl=operator""_toint:146:11 (Definition) 
Extent=[146:1 - 146:72] Spelling=operator""_toint ([146:11 - 146:27])
 
 // RUN: c-index-test -cursor-at=%s:141:13 -cursor-at=%s:141:18 
-cursor-at=%s:142:11 -std=c++11 %s | FileCheck -check-prefix=CHECK-FORRANGE %s
 // CHECK-FORRANGE: 141:13 VarDecl=lv:141:13 (Definition) Extent=[141:8 - 
141:17] Spelling=lv 

Re: [PATCH] D18462: Fix for clang_Cursor_getSpellingNameRange()

2016-09-15 Thread Kevin Funk via cfe-commits
kfunk added a comment.

@other LLVM devs: Please review so we can finally ship this?



Comment at: tools/libclang/CIndex.cpp:4311
@@ -4311,1 +4310,3 @@
+  C.kind == CXCursor_ConversionFunction ||
+  C.kind == CXCursor_FunctionDecl) {
 if (pieceIndex > 0)

skalinichev wrote:
> What about function templates?
> 
> E.g.: template  double operator "" _x();
Still broken for function template. The fix isn't as easy as adding another 
check for `C.kind == CXCursor=FunctionTemplate`, though.

We should fix this in another patch.


https://reviews.llvm.org/D18462



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21279: Fix some issues in clang-format's AlignConsecutive modes

2016-06-13 Thread Kevin Funk via cfe-commits
kfunk added a subscriber: kfunk.
kfunk added a comment.

In http://reviews.llvm.org/D21279#455923, @klimek wrote:

> Generally, please subscribe cfe-commits when sending patches via phab.
>  See http://llvm.org/docs/Phabricator.html


You should set up a Herald rule then: 
https://secure.phabricator.com/book/phabricator/article/herald/ -- you can 
automatically subscribe users based on rules.


Repository:
  rL LLVM

http://reviews.llvm.org/D21279



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15729: Load compiler plugins in ASTUnit, too

2016-03-15 Thread Kevin Funk via cfe-commits
kfunk updated this revision to Diff 50720.
kfunk added a comment.

Remove unrelated hunk


http://reviews.llvm.org/D15729

Files:
  include/clang/Frontend/CompilerInstance.h
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/FrontendActionTest.cpp
  unittests/Frontend/PrintFunctionNamesTestPlugin/CMakeLists.txt
  
unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp

Index: unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp
===
--- /dev/null
+++ unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp
@@ -0,0 +1,123 @@
+//===- PrintFunctionNames.cpp -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Example clang plugin which simply prints the names of all the top-level decls
+// in the input file.
+//
+//===--===//
+
+#include "clang/Frontend/FrontendPluginRegistry.h"
+#include "clang/AST/AST.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Sema/Sema.h"
+#include "llvm/Support/raw_ostream.h"
+using namespace clang;
+
+namespace {
+
+class PrintFunctionsConsumer : public ASTConsumer {
+  CompilerInstance 
+  std::set ParsedTemplates;
+
+public:
+  PrintFunctionsConsumer(CompilerInstance ,
+ std::set ParsedTemplates)
+  : Instance(Instance), ParsedTemplates(ParsedTemplates) {}
+
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+for (DeclGroupRef::iterator i = DG.begin(), e = DG.end(); i != e; ++i) {
+  const Decl *D = *i;
+  if (const NamedDecl *ND = dyn_cast(D))
+llvm::errs() << "top-level-decl: \"" << ND->getNameAsString() << "\"\n";
+}
+
+return true;
+  }
+
+  void HandleTranslationUnit(ASTContext& context) override {
+if (!Instance.getLangOpts().DelayedTemplateParsing)
+  return;
+
+// This demonstrates how to force instantiation of some templates in
+// -fdelayed-template-parsing mode. (Note: Doing this unconditionally for
+// all templates is similar to not using -fdelayed-template-parsig in the
+// first place.)
+// The advantage of doing this in HandleTranslationUnit() is that all
+// codegen (when using -add-plugin) is completely finished and this can't
+// affect the compiler output.
+struct Visitor : public RecursiveASTVisitor {
+  const std::set 
+  Visitor(const std::set )
+  : ParsedTemplates(ParsedTemplates) {}
+  bool VisitFunctionDecl(FunctionDecl *FD) {
+if (FD->isLateTemplateParsed() &&
+ParsedTemplates.count(FD->getNameAsString()))
+  LateParsedDecls.insert(FD);
+return true;
+  }
+
+  std::set LateParsedDecls;
+} v(ParsedTemplates);
+v.TraverseDecl(context.getTranslationUnitDecl());
+clang::Sema  = Instance.getSema();
+for (const FunctionDecl *FD : v.LateParsedDecls) {
+  clang::LateParsedTemplate* LPT = sema.LateParsedTemplateMap.lookup(FD);
+  sema.LateTemplateParser(sema.OpaqueParser, *LPT);
+  llvm::errs() << "late-parsed-decl: \"" << FD->getNameAsString() << "\"\n";
+}
+  }
+};
+
+class PrintFunctionNamesAction : public PluginASTAction {
+  std::set ParsedTemplates;
+protected:
+  std::unique_ptr CreateASTConsumer(CompilerInstance ,
+ llvm::StringRef) override {
+return llvm::make_unique(CI, ParsedTemplates);
+  }
+
+  bool ParseArgs(const CompilerInstance ,
+ const std::vector ) override {
+for (unsigned i = 0, e = args.size(); i != e; ++i) {
+  llvm::errs() << "PrintFunctionNames arg = " << args[i] << "\n";
+
+  // Example error handling.
+  DiagnosticsEngine  = CI.getDiagnostics();
+  if (args[i] == "-an-error") {
+unsigned DiagID = D.getCustomDiagID(DiagnosticsEngine::Error,
+"invalid argument '%0'");
+D.Report(DiagID) << args[i];
+return false;
+  } else if (args[i] == "-parse-template") {
+if (i + 1 >= e) {
+  D.Report(D.getCustomDiagID(DiagnosticsEngine::Error,
+ "missing -parse-template argument"));
+  return false;
+}
+++i;
+ParsedTemplates.insert(args[i]);
+  }
+}
+if (!args.empty() && args[0] == "help")
+  PrintHelp(llvm::errs());
+
+return true;
+  }
+  void PrintHelp(llvm::raw_ostream& ros) {
+ros << 

Re: [PATCH] D11797: [LIbClang] Report the named type for ElaboratedType

2016-03-10 Thread Kevin Funk via cfe-commits
kfunk added inline comments.


Comment at: tools/libclang/CXType.cpp:990
@@ -987,1 +989,3 @@
 
+CXType clang_getNamedTypeUnderlyingElaboratedType(CXType CT){
+  QualType T = GetQualType(CT);

I'm not happy with this name either. If you look through the libclang API, 
functions are named like `clang_get${CPPCLASSNAME}${CPPMETHOD}`. E.g. 
`clang_getEnumConstantDeclValue`, `clang_getFieldDeclBitWidth`, 
`clang_getFunctionTypeCallingConv`.

Sergey's initial version was closer to that. Maybe 
`clang_getElaboratedTypeNamedType` will just do...?


http://reviews.llvm.org/D11797



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15729: Load compiler plugins in ASTUnit, too

2016-03-10 Thread Kevin Funk via cfe-commits
kfunk added a comment.

@bkramer: Thoughts about my patch? I wonder if this makes your "work-around" in 
http://reviews.llvm.org/D17808 redundant.


http://reviews.llvm.org/D15729



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262922 - Bump libclang API version after r262318

2016-03-08 Thread Kevin Funk via cfe-commits
Author: kfunk
Date: Tue Mar  8 04:34:23 2016
New Revision: 262922

URL: http://llvm.org/viewvc/llvm-project?rev=262922=rev
Log:
Bump libclang API version after r262318

Modified:
cfe/trunk/include/clang-c/Index.h

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=262922=262921=262922=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Mar  8 04:34:23 2016
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 33
+#define CINDEX_VERSION_MINOR 34
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15729: Load compiler plugins in ASTUnit, too

2016-03-07 Thread Kevin Funk via cfe-commits
kfunk added a comment.

Okay, just gave this another look. Unit test seems fine as-is. Let's call 
`loadPlugins` there explicitly.

@LLVM/Clang devs: Please review!

I'm especially interested in whether you think there's a better location for 
calling `CompilerInstance::loadPlugins` than in `ASTUnit::Parse`.


http://reviews.llvm.org/D15729



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15729: Load compiler plugins in ASTUnit, too

2016-03-07 Thread Kevin Funk via cfe-commits
kfunk updated this revision to Diff 4.
kfunk added a comment.
This revision is now accepted and ready to land.

Remove TODO statement


http://reviews.llvm.org/D15729

Files:
  include/clang/Frontend/CompilerInstance.h
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  test/CXX/drs/dr3xx.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/FrontendActionTest.cpp
  unittests/Frontend/PrintFunctionNamesTestPlugin/CMakeLists.txt
  
unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp

Index: unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp
===
--- /dev/null
+++ unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp
@@ -0,0 +1,123 @@
+//===- PrintFunctionNames.cpp -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Example clang plugin which simply prints the names of all the top-level decls
+// in the input file.
+//
+//===--===//
+
+#include "clang/Frontend/FrontendPluginRegistry.h"
+#include "clang/AST/AST.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Sema/Sema.h"
+#include "llvm/Support/raw_ostream.h"
+using namespace clang;
+
+namespace {
+
+class PrintFunctionsConsumer : public ASTConsumer {
+  CompilerInstance 
+  std::set ParsedTemplates;
+
+public:
+  PrintFunctionsConsumer(CompilerInstance ,
+ std::set ParsedTemplates)
+  : Instance(Instance), ParsedTemplates(ParsedTemplates) {}
+
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+for (DeclGroupRef::iterator i = DG.begin(), e = DG.end(); i != e; ++i) {
+  const Decl *D = *i;
+  if (const NamedDecl *ND = dyn_cast(D))
+llvm::errs() << "top-level-decl: \"" << ND->getNameAsString() << "\"\n";
+}
+
+return true;
+  }
+
+  void HandleTranslationUnit(ASTContext& context) override {
+if (!Instance.getLangOpts().DelayedTemplateParsing)
+  return;
+
+// This demonstrates how to force instantiation of some templates in
+// -fdelayed-template-parsing mode. (Note: Doing this unconditionally for
+// all templates is similar to not using -fdelayed-template-parsig in the
+// first place.)
+// The advantage of doing this in HandleTranslationUnit() is that all
+// codegen (when using -add-plugin) is completely finished and this can't
+// affect the compiler output.
+struct Visitor : public RecursiveASTVisitor {
+  const std::set 
+  Visitor(const std::set )
+  : ParsedTemplates(ParsedTemplates) {}
+  bool VisitFunctionDecl(FunctionDecl *FD) {
+if (FD->isLateTemplateParsed() &&
+ParsedTemplates.count(FD->getNameAsString()))
+  LateParsedDecls.insert(FD);
+return true;
+  }
+
+  std::set LateParsedDecls;
+} v(ParsedTemplates);
+v.TraverseDecl(context.getTranslationUnitDecl());
+clang::Sema  = Instance.getSema();
+for (const FunctionDecl *FD : v.LateParsedDecls) {
+  clang::LateParsedTemplate* LPT = sema.LateParsedTemplateMap.lookup(FD);
+  sema.LateTemplateParser(sema.OpaqueParser, *LPT);
+  llvm::errs() << "late-parsed-decl: \"" << FD->getNameAsString() << "\"\n";
+}
+  }
+};
+
+class PrintFunctionNamesAction : public PluginASTAction {
+  std::set ParsedTemplates;
+protected:
+  std::unique_ptr CreateASTConsumer(CompilerInstance ,
+ llvm::StringRef) override {
+return llvm::make_unique(CI, ParsedTemplates);
+  }
+
+  bool ParseArgs(const CompilerInstance ,
+ const std::vector ) override {
+for (unsigned i = 0, e = args.size(); i != e; ++i) {
+  llvm::errs() << "PrintFunctionNames arg = " << args[i] << "\n";
+
+  // Example error handling.
+  DiagnosticsEngine  = CI.getDiagnostics();
+  if (args[i] == "-an-error") {
+unsigned DiagID = D.getCustomDiagID(DiagnosticsEngine::Error,
+"invalid argument '%0'");
+D.Report(DiagID) << args[i];
+return false;
+  } else if (args[i] == "-parse-template") {
+if (i + 1 >= e) {
+  D.Report(D.getCustomDiagID(DiagnosticsEngine::Error,
+ "missing -parse-template argument"));
+  return false;
+}
+++i;
+ParsedTemplates.insert(args[i]);
+  }
+}
+if (!args.empty() && args[0] == "help")
+  PrintHelp(llvm::errs());
+
+

Re: [PATCH] D15729: Load compiler plugins in ASTUnit, too

2016-01-12 Thread Kevin Funk via cfe-commits
kfunk added a comment.

@realincubus: Sorry, I didn't know you had put this up for review already.

So back to this patch. Yes, it works fine for me *without* amending 
libclang.exports. I'm injecting the arguments to `clang_parseTranslationUnit2`.

See this patch here for reference: 
https://quickgit.kde.org/?p=kdevelop.git=commit=b299e550f6753667d415c6aea8c0b0806e954e36
(when you view the whole blob of *parsesession.cpp*, you can also see the call 
to `clang_parseTranslationUnit2`)


http://reviews.llvm.org/D15729



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15729: Load compiler plugins in ASTUnit, too

2016-01-11 Thread Kevin Funk via cfe-commits
kfunk updated this revision to Diff 9.
kfunk added a comment.

Update, add (non-working) test

Just uploading my WIP patch, now that the branching comes close. I added a 
test, unfortunately it doesn't do what I expect.
Please see the FIXME.

Didn't have the time to investigate yet, so any hints welcome!


http://reviews.llvm.org/D15729

Files:
  include/clang/Frontend/CompilerInstance.h
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  unittests/Frontend/CMakeLists.txt
  unittests/Frontend/FrontendActionTest.cpp
  unittests/Frontend/PrintFunctionNamesTestPlugin/CMakeLists.txt
  
unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp

Index: unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp
===
--- /dev/null
+++ unittests/Frontend/PrintFunctionNamesTestPlugin/PrintFunctionNamesTestPlugin.cpp
@@ -0,0 +1,123 @@
+//===- PrintFunctionNames.cpp -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Example clang plugin which simply prints the names of all the top-level decls
+// in the input file.
+//
+//===--===//
+
+#include "clang/Frontend/FrontendPluginRegistry.h"
+#include "clang/AST/AST.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Sema/Sema.h"
+#include "llvm/Support/raw_ostream.h"
+using namespace clang;
+
+namespace {
+
+class PrintFunctionsConsumer : public ASTConsumer {
+  CompilerInstance 
+  std::set ParsedTemplates;
+
+public:
+  PrintFunctionsConsumer(CompilerInstance ,
+ std::set ParsedTemplates)
+  : Instance(Instance), ParsedTemplates(ParsedTemplates) {}
+
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+for (DeclGroupRef::iterator i = DG.begin(), e = DG.end(); i != e; ++i) {
+  const Decl *D = *i;
+  if (const NamedDecl *ND = dyn_cast(D))
+llvm::errs() << "top-level-decl: \"" << ND->getNameAsString() << "\"\n";
+}
+
+return true;
+  }
+
+  void HandleTranslationUnit(ASTContext& context) override {
+if (!Instance.getLangOpts().DelayedTemplateParsing)
+  return;
+
+// This demonstrates how to force instantiation of some templates in
+// -fdelayed-template-parsing mode. (Note: Doing this unconditionally for
+// all templates is similar to not using -fdelayed-template-parsig in the
+// first place.)
+// The advantage of doing this in HandleTranslationUnit() is that all
+// codegen (when using -add-plugin) is completely finished and this can't
+// affect the compiler output.
+struct Visitor : public RecursiveASTVisitor {
+  const std::set 
+  Visitor(const std::set )
+  : ParsedTemplates(ParsedTemplates) {}
+  bool VisitFunctionDecl(FunctionDecl *FD) {
+if (FD->isLateTemplateParsed() &&
+ParsedTemplates.count(FD->getNameAsString()))
+  LateParsedDecls.insert(FD);
+return true;
+  }
+
+  std::set LateParsedDecls;
+} v(ParsedTemplates);
+v.TraverseDecl(context.getTranslationUnitDecl());
+clang::Sema  = Instance.getSema();
+for (const FunctionDecl *FD : v.LateParsedDecls) {
+  clang::LateParsedTemplate* LPT = sema.LateParsedTemplateMap.lookup(FD);
+  sema.LateTemplateParser(sema.OpaqueParser, *LPT);
+  llvm::errs() << "late-parsed-decl: \"" << FD->getNameAsString() << "\"\n";
+}
+  }
+};
+
+class PrintFunctionNamesAction : public PluginASTAction {
+  std::set ParsedTemplates;
+protected:
+  std::unique_ptr CreateASTConsumer(CompilerInstance ,
+ llvm::StringRef) override {
+return llvm::make_unique(CI, ParsedTemplates);
+  }
+
+  bool ParseArgs(const CompilerInstance ,
+ const std::vector ) override {
+for (unsigned i = 0, e = args.size(); i != e; ++i) {
+  llvm::errs() << "PrintFunctionNames arg = " << args[i] << "\n";
+
+  // Example error handling.
+  DiagnosticsEngine  = CI.getDiagnostics();
+  if (args[i] == "-an-error") {
+unsigned DiagID = D.getCustomDiagID(DiagnosticsEngine::Error,
+"invalid argument '%0'");
+D.Report(DiagID) << args[i];
+return false;
+  } else if (args[i] == "-parse-template") {
+if (i + 1 >= e) {
+  D.Report(D.getCustomDiagID(DiagnosticsEngine::Error,
+ "missing -parse-template argument"));
+  return false;
+}
+++i;

Re: [PATCH] D15729: Load compiler plugins in ASTUnit, too

2015-12-22 Thread Kevin Funk via cfe-commits
kfunk added a comment.

By the way; prove that it really works:

  http://wstaw.org/m/2015/12/23/kdevelop-clazy.png (loving it!) :)


http://reviews.llvm.org/D15729



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15729: Load compiler plugins in ASTUnit, too

2015-12-22 Thread Kevin Funk via cfe-commits
kfunk added a comment.

Doing as requested by 
http://lists.llvm.org/pipermail/cfe-dev/2014-October/039381.html, let's put 
this up for review in its initial form, so we can discuss a better approach.


http://reviews.llvm.org/D15729



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10833: Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface

2015-11-24 Thread Kevin Funk via cfe-commits
kfunk accepted this revision.
kfunk added a comment.

Looks good to me now. I'd also appreciate another +1 from somone else, though.


http://reviews.llvm.org/D10833



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10833: Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface

2015-11-04 Thread Kevin Funk via cfe-commits
kfunk added inline comments.


Comment at: bindings/python/clang/cindex.py:1589
@@ +1588,3 @@
+def is_assignment(self):
+return BinaryOperator.Assign.value <= self.value < 
BinaryOperator.Comma.value
+

TIL chaining comparisons in Python is OK... :)

I first though this expression gives the wrong result and you need `min <= val 
and val < max`. But indeed your expression does exactly this...


Comment at: bindings/python/tests/cindex/test_cursor.py:333
@@ +332,3 @@
+# not exposed yet
+# ".*" : BinaryOperator.PtrMemD,
+"->*" : BinaryOperator.PtrMemI,

What about this? How is it not exposed? 

This works in the C++ test apparently(?)


Comment at: tools/libclang/CIndex.cpp:6749
@@ -6743,1 +6748,3 @@
 
+enum CX_BinaryOperatorKind clang_Cursor_getBinaryOpCode(CXCursor C) {
+   if (C.kind != CXCursor_BinaryOperator &&

I'd rename to `getBinaryOpcode` (note the casing, more consistent).

Same below, rename to `getBinaryOpcodeString` (casing + full words)


Comment at: tools/libclang/CIndex.cpp:6763
@@ +6762,3 @@
+
+CXString clang_Cursor_getBinaryOpCodeStr(CXCursor C) {
+   if (C.kind != CXCursor_BinaryOperator &&

I think this should have a `enum CX_BinaryOperatorKind` as parameter instead.

There's `BinaryOperator::getOpcode(Opcode)` you can use.


http://reviews.llvm.org/D10833



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits