r359172 - [NFC] test commit removing excess line

2019-04-25 Thread Nikolai Kosjar via cfe-commits
Author: nik
Date: Thu Apr 25 01:14:39 2019
New Revision: 359172

URL: http://llvm.org/viewvc/llvm-project?rev=359172&view=rev
Log:
[NFC] test commit removing excess line

Modified:
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=359172&r1=359171&r2=359172&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Thu Apr 25 01:14:39 2019
@@ -171,7 +171,6 @@ CXSourceRange cxloc::translateSourceRang
 static SourceRange getRawCursorExtent(CXCursor C);
 static SourceRange getFullCursorExtent(CXCursor C, SourceManager &SrcMgr);
 
-
 RangeComparisonResult CursorVisitor::CompareRegionOfInterest(SourceRange R) {
   return RangeCompare(AU->getSourceManager(), R, RegionOfInterest);
 }


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


r360249 - [libclang] PR41649: Remove pointless duplicate flag. NFC.

2019-05-08 Thread Nikolai Kosjar via cfe-commits
Author: nik
Date: Wed May  8 06:19:29 2019
New Revision: 360249

URL: http://llvm.org/viewvc/llvm-project?rev=360249&view=rev
Log:
[libclang] PR41649: Remove pointless duplicate flag. NFC.

Modified:
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=360249&r1=360248&r2=360249&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed May  8 06:19:29 2019
@@ -7249,15 +7249,14 @@ void AnnotateTokensWorker::HandlePostPon
 
 void AnnotateTokensWorker::HandlePostPonedChildCursor(
 CXCursor Cursor, unsigned StartTokenIndex) {
-  const auto flags = CXNameRange_WantQualifier | CXNameRange_WantQualifier;
   unsigned I = StartTokenIndex;
 
   // The bracket tokens of a Call or Subscript operator are mapped to
   // CallExpr/CXXOperatorCallExpr because we skipped visiting the corresponding
   // DeclRefExpr. Remap these tokens to the DeclRefExpr cursors.
   for (unsigned RefNameRangeNr = 0; I < NumTokens; RefNameRangeNr++) {
-const CXSourceRange CXRefNameRange =
-clang_getCursorReferenceNameRange(Cursor, flags, RefNameRangeNr);
+const CXSourceRange CXRefNameRange = clang_getCursorReferenceNameRange(
+Cursor, CXNameRange_WantQualifier, RefNameRangeNr);
 if (clang_Range_isNull(CXRefNameRange))
   break; // All ranges handled.
 


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


[clang-tools-extra] r362702 - [clang-tidy] Make the plugin honor NOLINT

2019-06-06 Thread Nikolai Kosjar via cfe-commits
Author: nik
Date: Thu Jun  6 06:13:27 2019
New Revision: 362702

URL: http://llvm.org/viewvc/llvm-project?rev=362702&view=rev
Log:
[clang-tidy] Make the plugin honor NOLINT

Instantiate a ClangTidyDiagnosticConsumer also for the plugin case and
let it forward the diagnostics to the external diagnostic engine that is
already in place.

One minor difference to the clang-tidy executable case is that the
compiler checks/diagnostics are referred to with their original name.
For example, for -Wunused-variable the plugin will refer to the check as
"-Wunused-variable" while the clang-tidy executable will refer to that
as "clang-diagnostic- unused-variable". This is because the compiler
diagnostics never reach ClangTidyDiagnosticConsumer.

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

Added:
clang-tools-extra/trunk/test/clang-tidy/nolint-plugin.cpp
clang-tools-extra/trunk/test/clang-tidy/nolintnextline-plugin.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp
clang-tools-extra/trunk/test/clang-tidy/basic.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=362702&r1=362701&r2=362702&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Thu Jun  
6 06:13:27 2019
@@ -275,8 +275,10 @@ std::string ClangTidyContext::getCheckNa
 }
 
 ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(
-ClangTidyContext &Ctx, bool RemoveIncompatibleErrors)
-: Context(Ctx), RemoveIncompatibleErrors(RemoveIncompatibleErrors),
+ClangTidyContext &Ctx, DiagnosticsEngine *ExternalDiagEngine,
+bool RemoveIncompatibleErrors)
+: Context(Ctx), ExternalDiagEngine(ExternalDiagEngine),
+  RemoveIncompatibleErrors(RemoveIncompatibleErrors),
   LastErrorRelatesToUserCode(false), LastErrorPassesLineFilter(false),
   LastErrorWasIgnored(false) {}
 
@@ -461,16 +463,22 @@ void ClangTidyDiagnosticConsumer::Handle
 IsWarningAsError);
   }
 
-  ClangTidyDiagnosticRenderer Converter(
-  Context.getLangOpts(), &Context.DiagEngine->getDiagnosticOptions(),
-  Errors.back());
-  SmallString<100> Message;
-  Info.FormatDiagnostic(Message);
-  FullSourceLoc Loc;
-  if (Info.getLocation().isValid() && Info.hasSourceManager())
-Loc = FullSourceLoc(Info.getLocation(), Info.getSourceManager());
-  Converter.emitDiagnostic(Loc, DiagLevel, Message, Info.getRanges(),
-   Info.getFixItHints());
+  if (ExternalDiagEngine) {
+// If there is an external diagnostics engine, like in the
+// ClangTidyPluginAction case, forward the diagnostics to it.
+forwardDiagnostic(Info);
+  } else {
+ClangTidyDiagnosticRenderer Converter(
+Context.getLangOpts(), &Context.DiagEngine->getDiagnosticOptions(),
+Errors.back());
+SmallString<100> Message;
+Info.FormatDiagnostic(Message);
+FullSourceLoc Loc;
+if (Info.getLocation().isValid() && Info.hasSourceManager())
+  Loc = FullSourceLoc(Info.getLocation(), Info.getSourceManager());
+Converter.emitDiagnostic(Loc, DiagLevel, Message, Info.getRanges(),
+ Info.getFixItHints());
+  }
 
   if (Info.hasSourceManager())
 checkFilters(Info.getLocation(), Info.getSourceManager());
@@ -494,6 +502,68 @@ bool ClangTidyDiagnosticConsumer::passes
   return false;
 }
 
+void ClangTidyDiagnosticConsumer::forwardDiagnostic(const Diagnostic &Info) {
+  // Acquire a diagnostic ID also in the external diagnostics engine.
+  auto DiagLevelAndFormatString =
+  Context.getDiagLevelAndFormatString(Info.getID(), Info.getLocation());
+  unsigned ExternalID = 
ExternalDiagEngine->getDiagnosticIDs()->getCustomDiagID(
+  DiagLevelAndFormatString.first, DiagLevelAndFormatString.second);
+
+  // Forward the details.
+  auto builder = ExternalDiagEngine->Report(Info.getLocation(), ExternalID);
+  for (auto Hint : Info.getFixItHints())
+builder << Hint;
+  for (auto Range : Info.getRanges())
+builder << Range;
+  for (unsigned Index = 0; Index < Info.getNumArgs(); ++Index) {
+DiagnosticsEngine::ArgumentKind kind = Info.getArgKind(Index);
+switch (kind) {
+case clang::DiagnosticsEngine::ak_std_string:
+  builder << Info.getArgStdStr(Index);
+  break;
+case clang::DiagnosticsEngine::ak_c_string:
+  builder << Info.getArgCStr(Index);
+  break;
+case clang::DiagnosticsEngine::ak_sint:
+  builder << Info.getArgSInt(Index);
+  break;
+case clang::DiagnosticsEngine::ak_uint:
+  builder << Info.getArgUInt(Index);
+  break

r363067 - [libclang] Allow skipping warnings from all included files

2019-06-11 Thread Nikolai Kosjar via cfe-commits
Author: nik
Date: Tue Jun 11 07:14:24 2019
New Revision: 363067

URL: http://llvm.org/viewvc/llvm-project?rev=363067&view=rev
Log:
[libclang] Allow skipping warnings from all included files

Depending on the included files and the used warning flags, e.g. -
Weverything, a huge number of warnings can be reported for included
files. As processing that many diagnostics comes with a performance
impact and not all clients are interested in those diagnostics, add a
flag to skip them.

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


Added:
cfe/trunk/test/Index/ignore-warnings-from-headers.cpp
cfe/trunk/test/Index/ignore-warnings-from-headers.h
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/c-index-test/core_main.cpp
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/Indexing.cpp
cfe/trunk/unittests/Frontend/ASTUnitTest.cpp
cfe/trunk/unittests/Frontend/PCHPreambleTest.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=363067&r1=363066&r2=363067&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Jun 11 07:14:24 2019
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 58
+#define CINDEX_VERSION_MINOR 59
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -1346,7 +1346,17 @@ enum CXTranslationUnit_Flags {
   /**
* Used to indicate that implicit attributes should be visited.
*/
-  CXTranslationUnit_VisitImplicitAttributes = 0x2000
+  CXTranslationUnit_VisitImplicitAttributes = 0x2000,
+
+  /**
+   * Used to indicate that non-errors from included files should be ignored.
+   *
+   * If set, clang_getDiagnosticSetFromTU() will not report e.g. warnings from
+   * included files anymore. This speeds up clang_getDiagnosticSetFromTU() for
+   * the case where these warnings are not of interest, as for an IDE for
+   * example, which typically shows only the diagnostics in the main file.
+   */
+  CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000
 };
 
 /**

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=363067&r1=363066&r2=363067&view=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Tue Jun 11 07:14:24 2019
@@ -82,6 +82,9 @@ class TargetInfo;
 /// \brief Enumerates the available scopes for skipping function bodies.
 enum class SkipFunctionBodiesScope { None, Preamble, PreambleAndMainFile };
 
+/// \brief Enumerates the available kinds for capturing diagnostics.
+enum class CaptureDiagsKind { None, All, AllWithoutNonErrorsFromIncludes };
+
 /// Utility class for loading a ASTContext from an AST file.
 class ASTUnit {
 public:
@@ -144,7 +147,7 @@ private:
   bool OnlyLocalDecls = false;
 
   /// Whether to capture any diagnostics produced.
-  bool CaptureDiagnostics = false;
+  CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None;
 
   /// Track whether the main file was loaded from an AST or not.
   bool MainFileIsAST;
@@ -250,7 +253,7 @@ private:
   bool UserFilesAreVolatile : 1;
 
   static void ConfigureDiags(IntrusiveRefCntPtr Diags,
- ASTUnit &AST, bool CaptureDiagnostics);
+ ASTUnit &AST, CaptureDiagsKind 
CaptureDiagnostics);
 
   void TranslateStoredDiagnostics(FileManager &FileMgr,
   SourceManager &SrcMan,
@@ -661,8 +664,8 @@ public:
   /// Create a ASTUnit. Gets ownership of the passed CompilerInvocation.
   static std::unique_ptr
   create(std::shared_ptr CI,
- IntrusiveRefCntPtr Diags, bool CaptureDiagnostics,
- bool UserFilesAreVolatile);
+ IntrusiveRefCntPtr Diags,
+ CaptureDiagsKind CaptureDiagnostics, bool UserFilesAreVolatile);
 
   enum WhatToLoad {
 /// Load options and the preprocessor state.
@@ -690,7 +693,8 @@ public:
   WhatToLoad ToLoad, IntrusiveRefCntPtr Diags,
   const FileSystemOptions &FileSystemOpts, bool UseDebugInfo = false,
   bool OnlyLocalDecls = false, ArrayRef RemappedFiles = None,
-  bool CaptureDiagnostics = false, bool AllowPCHWithCompilerErrors = false,
+  CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
+  bool AllowPCHWithCompilerErrors = false,
   bool UserFilesAreVolatile = false);
 
 private:
@@ -748,7 +752,8 @@ public:
   IntrusiveRefCntPtr Diags,
   FrontendAction *Action = nullptr, ASTUnit *Unit = nu

[clang-tools-extra] r363068 - [clang-tidy] Fix invalid read on destruction

2019-06-11 Thread Nikolai Kosjar via cfe-commits
Author: nik
Date: Tue Jun 11 07:19:09 2019
New Revision: 363068

URL: http://llvm.org/viewvc/llvm-project?rev=363068&view=rev
Log:
[clang-tidy] Fix invalid read on destruction

...in case the clang tidy plugin is linked into the clang binary.

Valgrind's memcheck reports:

8949== Invalid read ==8866== Invalid read of size 4
8866== at 0x164D248B: fetch_sub (atomic_base.h:524)
8866== by 0x164D248B: 
llvm::ThreadSafeRefCountedBase::Release()
 const (IntrusiveRefCntPtr.h:98)
8866== by 0x164CE16C: 
llvm::IntrusiveRefCntPtrInfo::release(clang::ast_matchers::internal::DynMatcherInterface*)
 (IntrusiveRefCntPtr.h:127)
8866== by 0x164C8D5C: 
llvm::IntrusiveRefCntPtr::release()
 (IntrusiveRefCntPtr.h:190)
8866== by 0x164C3B87: 
llvm::IntrusiveRefCntPtr::~IntrusiveRefCntPtr()
 (IntrusiveRefCntPtr.h:157)
8866== by 0x164BB4F1: 
clang::ast_matchers::internal::DynTypedMatcher::~DynTypedMatcher() 
(ASTMatchersInternal.h:341)
8866== by 0x164BB529: 
clang::ast_matchers::internal::Matcher::~Matcher() 
(ASTMatchersInternal.h:496)
8866== by 0xD7AE614: __cxa_finalize (cxa_finalize.c:83)
8866== by 0x164B3082: ??? (in 
/d2/llvm/8/qtc/builds/DebugShared/lib/libclangTidyModernizeModule.so.8)
8866== by 0x4010B72: _dl_fini (dl-fini.c:138)
8866== by 0xD7AE040: __run_exit_handlers (exit.c:108)
8866== by 0xD7AE139: exit (exit.c:139)
8866== by 0xD78CB9D: (below main) (libc-start.c:344)
8866== Address 0x19dd9bc8 is 8 bytes inside a block of size 16 free'd
8866== at 0x4C3123B: operator delete(void*) (in 
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
8866== by 0x1469BB99: clang::ast_matchers::internal::(anonymous 
namespace)::TrueMatcherImpl::~TrueMatcherImpl() (ASTMatchersInternal.cpp:126)
8866== by 0x1469BBC5: 
llvm::object_deleter::call(void*) (ManagedStatic.h:30)
8866== by 0x9ABFF26: llvm::ManagedStaticBase::destroy() const 
(ManagedStatic.cpp:72)
8866== by 0x9ABFF94: llvm::llvm_shutdown() (ManagedStatic.cpp:84)
8866== by 0x9A65232: llvm::InitLLVM::~InitLLVM() (InitLLVM.cpp:52)
8866== by 0x14B0C8: main (driver.cpp:323)
8866== Block was alloc'd at
8866== at 0x4C3017F: operator new(unsigned long) (in 
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
8866== by 0x1469BB36: 
llvm::object_creator::call() (ManagedStatic.h:24)
8866== by 0x9ABFD99: llvm::ManagedStaticBase::RegisterManagedStatic(void* 
(*)(), void (*)(void*)) const (ManagedStatic.cpp:42)
8866== by 0x1469B5DF: 
llvm::ManagedStatic, 
llvm::object_deleter >::operator*() (ManagedStatic.h:67)
8866== by 0x14698F9D: 
clang::ast_matchers::internal::DynTypedMatcher::trueMatcher(clang::ast_type_traits::ASTNodeKind)
 (ASTMatchersInternal.cpp:195)
8866== by 0x164C9D3B: 
_ZNK5clang12ast_matchers8internal11TrueMatchercvNS1_7MatcherIT_EEINS_8QualTypeEEEv
 (ASTMatchersInternal.h:1247)
8866== by 0x16501458: __static_initialization_and_destruction_0(int, int) 
(LoopConvertCheck.cpp:48)
8866== by 0x16501976: _GLOBAL__sub_I_LoopConvertCheck.cpp 
(LoopConvertCheck.cpp:920)
8866== by 0x4010732: call_init (dl-init.c:72)
8866== by 0x4010732: _dl_init (dl-init.c:119)
8866== by 0x40010C9: ??? (in /lib/x86_64-linux-gnu/ld-2.27.so)

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=363068&r1=363067&r2=363068&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Tue Jun 
11 07:19:09 2019
@@ -44,18 +44,22 @@ static const char DerefByValueResultName
 static const char DerefByRefResultName[] = "derefByRefResult";
 
 // shared matchers
-static const TypeMatcher AnyType = anything();
+static const TypeMatcher AnyType() { return anything(); }
 
-static const StatementMatcher IntegerComparisonMatcher =
-expr(ignoringParenImpCasts(
-
declRefExpr(to(varDecl(hasType(isInteger())).bind(ConditionVarName);
-
-static const DeclarationMatcher InitToZeroMatcher =
-varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral(equals(0)
-.bind(InitVarName);
+static const StatementMatcher IntegerComparisonMatcher() {
+  return expr(ignoringParenImpCasts(
+  declRefExpr(to(varDecl(hasType(isInteger())).bind(ConditionVarName);
+}
+
+static const DeclarationMatcher InitToZeroMatcher() {
+  return varDecl(
+ hasInitializer(ignoringParenImpCasts(integerLiteral(equals(0)
+  .bind(InitVarName);
+}
 
-static const StatementMatcher IncrementVarMatcher =
-declRefExpr(to(varDecl(hasType(isInteger())).bind(IncrementVarName)));
+static const StatementMatcher IncrementVarMatcher() {
+  return declRefExpr(to(varDecl(hasType(isInteger())).bind(IncrementVarName)));
+}
 
 /// \brief The matcher for loops over arrays.
 //

r363127 - [NFC] Test commit

2019-06-12 Thread Nikolai Kosjar via cfe-commits
Author: nik
Date: Wed Jun 12 00:50:48 2019
New Revision: 363127

URL: http://llvm.org/viewvc/llvm-project?rev=363127&view=rev
Log:
[NFC] Test commit

Modified:
cfe/trunk/README.txt

Modified: cfe/trunk/README.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/README.txt?rev=363127&r1=363126&r2=363127&view=diff
==
--- cfe/trunk/README.txt (original)
+++ cfe/trunk/README.txt Wed Jun 12 00:50:48 2019
@@ -24,4 +24,3 @@ on the Clang development mailing list:
 
 If you find a bug in Clang, please file it in the LLVM bug tracker:
   http://llvm.org/bugs/
-


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


[clang-tools-extra] r363139 - [clangd] Fix typo in GUARDED_BY()

2019-06-12 Thread Nikolai Kosjar via cfe-commits
Author: nik
Date: Wed Jun 12 04:01:19 2019
New Revision: 363139

URL: http://llvm.org/viewvc/llvm-project?rev=363139&view=rev
Log:
[clangd] Fix typo in GUARDED_BY()

Reviewers: ilya-biryukov, kadircet, sammccall

Subscribers: javed.absar, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/TUScheduler.cpp

Modified: clang-tools-extra/trunk/clangd/TUScheduler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/TUScheduler.cpp?rev=363139&r1=363138&r2=363139&view=diff
==
--- clang-tools-extra/trunk/clangd/TUScheduler.cpp (original)
+++ clang-tools-extra/trunk/clangd/TUScheduler.cpp Wed Jun 12 04:01:19 2019
@@ -273,7 +273,7 @@ private:
   // The lifetime of the old/new ASTWorkers will overlap, but their handles
   // don't. When the old handle is destroyed, the old worker will stop 
reporting
   // diagnostics.
-  bool ReportDiagnostics = true; /* GUARDED_BY(DiagMu) */
+  bool ReportDiagnostics = true; /* GUARDED_BY(DiagsMu) */
 };
 
 /// A smart-pointer-like class that points to an active ASTWorker.


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


[clang-tools-extra] r364315 - [clang-tidy] Update documentation for Qt Creator integration.

2019-06-25 Thread Nikolai Kosjar via cfe-commits
Author: nik
Date: Tue Jun 25 06:50:09 2019
New Revision: 364315

URL: http://llvm.org/viewvc/llvm-project?rev=364315&view=rev
Log:
[clang-tidy] Update documentation for Qt Creator integration.

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/docs/clang-tidy/Integrations.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/Integrations.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/Integrations.rst?rev=364315&r1=364314&r2=364315&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/Integrations.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/Integrations.rst Tue Jun 25 
06:50:09 2019
@@ -32,7 +32,7 @@ well-known :program:`clang-tidy` integra
 
+--++-+--+-+--+
 |KDevelop IDE  | \-\|  
 \+\   |   \+\| \+\ 
|   \+\|
 
+--++-+--+-+--+
-|Qt Creator IDE| \+\|  
 \+\   |   \-\| \-\ 
|   \+\|
+|Qt Creator IDE| \+\|  
 \+\   |   \-\| \+\ 
|   \+\|
 
+--++-+--+-+--+
 |ReSharper C++ for Visual Studio   | \+\|  
 \+\   |   \-\| \+\ 
|   \+\|
 
+--++-+--+-+--+
@@ -65,11 +65,13 @@ output to provide a list of issues.
 
 .. _QtCreator: https://www.qt.io/
 .. _Clang Code Model: https://doc.qt.io/qtcreator/creator-clang-codemodel.html
+.. _Clang Tools: https://doc.qt.io/qtcreator/creator-clang-tools.html
 
 QtCreator_ 4.6 integrates :program:`clang-tidy` warnings into the editor
 diagnostics under the `Clang Code Model`_. To employ :program:`clang-tidy`
 inspection in QtCreator, you need to create a copy of one of the presets and
-choose the checks to be performed in the Clang Code Model Warnings menu.
+choose the checks to be performed. Since QtCreator 4.7 project-wide analysis is
+possible with the `Clang Tools`_ analyzer.
 
 .. _MS Visual Studio: https://visualstudio.microsoft.com/
 .. _ReSharper C++: 
https://www.jetbrains.com/help/resharper/Clang_Tidy_Integration.html


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


r360418 - [Preamble] Stop circular inclusion of main file when building preamble

2019-05-10 Thread Nikolai Kosjar via cfe-commits
Author: nik
Date: Fri May 10 03:25:35 2019
New Revision: 360418

URL: http://llvm.org/viewvc/llvm-project?rev=360418&view=rev
Log:
[Preamble] Stop circular inclusion of main file when building preamble

If a header file was processed for the second time, we could end up with a
wrong conditional stack and skipped ranges:

In the particular example, if the header guard is evaluated the second time and
it is decided to skip the conditional block, the corresponding "#endif" is
never seen since the preamble does not include it and we end up in the
Tok.is(tok::eof) case with a wrong conditional stack.

Detect the circular inclusion, emit a diagnostic and stop processing the
inclusion.


Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Basic/SourceManager.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=360418&r1=360417&r2=360418&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri May 10 03:25:35 2019
@@ -426,6 +426,8 @@ def note_pp_framework_without_header : N
   "did not find header '%0' in framework '%1' (loaded from '%2')">;
 def err_pp_error_opening_file : Error<
   "error opening file '%0': %1">, DefaultFatal;
+def err_pp_including_mainfile_in_preamble : Error<
+  "main file cannot be included recursively when building a preamble">;
 def err_pp_empty_filename : Error<"empty filename">;
 def err_pp_include_too_deep : Error<"#include nested too deeply">;
 def err_pp_expects_filename : Error<"expected \"FILENAME\" or ">;

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=360418&r1=360417&r2=360418&view=diff
==
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Fri May 10 03:25:35 2019
@@ -1582,7 +1582,7 @@ FileID SourceManager::translateFile(cons
 if (MainSLoc.isFile()) {
   const ContentCache *MainContentCache
 = MainSLoc.getFile().getContentCache();
-  if (!MainContentCache) {
+  if (!MainContentCache || !MainContentCache->OrigEntry) {
 // Can't do anything
   } else if (MainContentCache->OrigEntry == SourceFile) {
 FirstFID = MainFileID;

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=360418&r1=360417&r2=360418&view=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Fri May 10 03:25:35 2019
@@ -1871,6 +1871,18 @@ Preprocessor::ImportAction Preprocessor:
 return {ImportAction::None};
   }
 
+  // Check for circular inclusion of the main file.
+  // We can't generate a consistent preamble with regard to the conditional
+  // stack if the main file is included again as due to the preamble bounds
+  // some directives (e.g. #endif of a header guard) will never be seen.
+  // Since this will lead to confusing errors, avoid the inclusion.
+  if (File && PreambleConditionalStack.isRecording() &&
+  SourceMgr.translateFile(File) == SourceMgr.getMainFileID()) {
+Diag(FilenameTok.getLocation(),
+ diag::err_pp_including_mainfile_in_preamble);
+return {ImportAction::None};
+  }
+
   // Should we enter the source file? Set to Skip if either the source file is
   // known to have no effect beyond its effect on module visibility -- that is,
   // if it's got an include guard that is already defined, set to Import if it


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


r360428 - [libclang] Forward isInline for NamespaceDecl to libclang

2019-05-10 Thread Nikolai Kosjar via cfe-commits
Author: nik
Date: Fri May 10 06:58:34 2019
New Revision: 360428

URL: http://llvm.org/viewvc/llvm-project?rev=360428&view=rev
Log:
[libclang] Forward isInline for NamespaceDecl to libclang

Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/print-type.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CXType.cpp
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=360428&r1=360427&r2=360428&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Fri May 10 06:58:34 2019
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 56
+#define CINDEX_VERSION_MINOR 57
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -3932,6 +3932,12 @@ CINDEX_LINKAGE unsigned clang_Cursor_isA
  */
 CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C);
 
+/**
+ * Determine whether the given cursor represents an inline namespace
+ * declaration.
+ */
+CINDEX_LINKAGE unsigned clang_Cursor_isInlineNamespace(CXCursor C);
+
 enum CXRefQualifierKind {
   /** No ref-qualifier was provided. */
   CXRefQualifier_None = 0,

Modified: cfe/trunk/test/Index/print-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type.cpp?rev=360428&r1=360427&r2=360428&view=diff
==
--- cfe/trunk/test/Index/print-type.cpp (original)
+++ cfe/trunk/test/Index/print-type.cpp Fri May 10 06:58:34 2019
@@ -90,6 +90,8 @@ class X {
 namespace {
   int a;
 }
+
+inline namespace InlineNS {}
 // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s
 // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
 // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
@@ -204,3 +206,4 @@ namespace {
 // CHECK: UnionDecl=:86:3 (Definition) [type=X::(anonymous union at 
{{.*}}print-type.cpp:86:3)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1]
 // CHECK: EnumDecl=:87:3 (Definition) [type=X::(anonymous enum at 
{{.*}}print-type.cpp:87:3)] [typekind=Enum] [isPOD=1] [isAnon=1]
 // CHECK: Namespace=:90:11 (Definition) [type=] [typekind=Invalid] [isPOD=0] 
[isAnon=1]
+// CHECK: Namespace=InlineNS:94:18 (Definition) [type=] [typekind=Invalid] 
[isPOD=0] [isAnonRecDecl=0] [isInlineNamespace=1]

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=360428&r1=360427&r2=360428&view=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Fri May 10 06:58:34 2019
@@ -1671,6 +1671,13 @@ static enum CXChildVisitResult PrintType
   printf(" [isAnonRecDecl=%d]", isAnonRecDecl);
 }
 
+/* Print if it is an inline namespace decl */
+{
+  unsigned isInlineNamespace = clang_Cursor_isInlineNamespace(cursor);
+  if (isInlineNamespace != 0)
+printf(" [isInlineNamespace=%d]", isInlineNamespace);
+}
+
 printf("\n");
   }
   return CXChildVisit_Recurse;

Modified: cfe/trunk/tools/libclang/CXType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=360428&r1=360427&r2=360428&view=diff
==
--- cfe/trunk/tools/libclang/CXType.cpp (original)
+++ cfe/trunk/tools/libclang/CXType.cpp Fri May 10 06:58:34 2019
@@ -1271,6 +1271,14 @@ unsigned clang_Cursor_isAnonymousRecordD
   return 0;
 }
 
+unsigned clang_Cursor_isInlineNamespace(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))
+return 0;
+  const Decl *D = cxcursor::getCursorDecl(C);
+  const NamespaceDecl *ND = dyn_cast_or_null(D);
+  return ND ? ND->isInline() : 0;
+}
+
 CXType clang_Type_getNamedType(CXType CT){
   QualType T = GetQualType(CT);
   const Type *TP = T.getTypePtrOrNull();

Modified: cfe/trunk/tools/libclang/libclang.exports
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=360428&r1=360427&r2=360428&view=diff
==
--- cfe/trunk/tools/libclang/libclang.exports (original)
+++ cfe/trunk/tools/libclang/libclang.exports Fri May 10 06:58:34 2019
@@ -43,6 +43,7 @@ clang_Cursor_isAnonymousRecordDecl
 clang_Cursor_isBitField
 clang_Cursor_isDynamicCall
 clang_Cursor_isExternalSymbol
+clang_Cursor_isInlineNamespace
 clang_Cursor_isNull
 clang_Cursor_isObjCOptional
 clang_Cursor_isVariadic


___
cfe-commits mailin

r361226 - [Preamble] Reuse preamble even if an unsaved file does not exist

2019-05-21 Thread Nikolai Kosjar via cfe-commits
Author: nik
Date: Tue May 21 00:26:59 2019
New Revision: 361226

URL: http://llvm.org/viewvc/llvm-project?rev=361226&view=rev
Log:
[Preamble] Reuse preamble even if an unsaved file does not exist

When a preamble is created an unsaved file not existing on disk is
already part of PrecompiledPreamble::FilesInPreamble. However, when
checking whether the preamble can be re-used, a failed stat of such an
unsaved file invalidated the preamble, which led to pointless and time
consuming preamble regenerations on subsequent reparses.

Do not require anymore that unsaved files should exist on disk.

This avoids costly preamble invalidations depending on timing issues for
the cases where the file on disk might be removed just to be regenerated
a bit later.

It also allows an IDE to provide in-memory files that might not exist on
disk, e.g. because the build system hasn't generated those yet.

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

Modified:
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
cfe/trunk/unittests/Frontend/PCHPreambleTest.cpp

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=361226&r1=361225&r2=361226&view=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Tue May 21 00:26:59 2019
@@ -205,7 +205,10 @@ private:
   /// we'll attempt to rebuild the precompiled header. This way, if
   /// building the precompiled preamble fails, we won't try again for
   /// some number of calls.
-  unsigned PreambleRebuildCounter = 0;
+  unsigned PreambleRebuildCountdown = 0;
+
+  /// Counter indicating how often the preamble was build in total.
+  unsigned PreambleCounter = 0;
 
   /// Cache pairs "filename - source location"
   ///
@@ -574,6 +577,8 @@ public:
mapLocationToPreamble(R.getEnd()));
   }
 
+  unsigned getPreambleCounterForTests() const { return PreambleCounter; }
+
   // Retrieve the diagnostics associated with this AST
   using stored_diag_iterator = StoredDiagnostic *;
   using stored_diag_const_iterator = const StoredDiagnostic *;

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=361226&r1=361225&r2=361226&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Tue May 21 00:26:59 2019
@@ -1304,22 +1304,22 @@ ASTUnit::getMainBufferWithPrecompiledPre
 PreambleInvocationIn.getDiagnosticOpts());
   getDiagnostics().setNumWarnings(NumWarningsInPreamble);
 
-  PreambleRebuildCounter = 1;
+  PreambleRebuildCountdown = 1;
   return MainFileBuffer;
 } else {
   Preamble.reset();
   PreambleDiagnostics.clear();
   TopLevelDeclsInPreamble.clear();
   PreambleSrcLocCache.clear();
-  PreambleRebuildCounter = 1;
+  PreambleRebuildCountdown = 1;
 }
   }
 
   // If the preamble rebuild counter > 1, it's because we previously
   // failed to build a preamble and we're not yet ready to try
   // again. Decrement the counter and return a failure.
-  if (PreambleRebuildCounter > 1) {
---PreambleRebuildCounter;
+  if (PreambleRebuildCountdown > 1) {
+--PreambleRebuildCountdown;
 return nullptr;
   }
 
@@ -1329,6 +1329,8 @@ ASTUnit::getMainBufferWithPrecompiledPre
   if (!AllowRebuild)
 return nullptr;
 
+  ++PreambleCounter;
+
   SmallVector NewPreambleDiagsStandalone;
   SmallVector NewPreambleDiags;
   ASTUnitPreambleCallbacks Callbacks;
@@ -1356,18 +1358,18 @@ ASTUnit::getMainBufferWithPrecompiledPre
 
 if (NewPreamble) {
   Preamble = std::move(*NewPreamble);
-  PreambleRebuildCounter = 1;
+  PreambleRebuildCountdown = 1;
 } else {
   switch (static_cast(NewPreamble.getError().value())) 
{
   case BuildPreambleError::CouldntCreateTempFile:
 // Try again next time.
-PreambleRebuildCounter = 1;
+PreambleRebuildCountdown = 1;
 return nullptr;
   case BuildPreambleError::CouldntCreateTargetInfo:
   case BuildPreambleError::BeginSourceFileFailed:
   case BuildPreambleError::CouldntEmitPCH:
 // These erros are more likely to repeat, retry after some period.
-PreambleRebuildCounter = DefaultPreambleRebuildInterval;
+PreambleRebuildCountdown = DefaultPreambleRebuildInterval;
 return nullptr;
   }
   llvm_unreachable("unexpected BuildPreambleError");
@@ -1507,7 +1509,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvoca
   AST->OnlyLocalDecls = OnlyLocalDecls;
   AST->CaptureDiagnostics = CaptureDiagnostics;
   if (PrecompilePreambleAfterNParses > 0)
-AST->PreambleRebuildCounter = Prec

r361234 - [libclang] visit c++14 lambda capture init expressions

2019-05-21 Thread Nikolai Kosjar via cfe-commits
Author: nik
Date: Tue May 21 02:21:35 2019
New Revision: 361234

URL: http://llvm.org/viewvc/llvm-project?rev=361234&view=rev
Log:
[libclang] visit c++14 lambda capture init expressions

Patch by Milian Wolff.

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

Added:
cfe/trunk/test/Index/cxx14-lambdas.cpp
Modified:
cfe/trunk/tools/libclang/CIndex.cpp

Added: cfe/trunk/test/Index/cxx14-lambdas.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/cxx14-lambdas.cpp?rev=361234&view=auto
==
--- cfe/trunk/test/Index/cxx14-lambdas.cpp (added)
+++ cfe/trunk/test/Index/cxx14-lambdas.cpp Tue May 21 02:21:35 2019
@@ -0,0 +1,38 @@
+// Test is line- and column-sensitive; see below.
+
+typedef int Integer;
+struct X {
+  void f() {
+int localA, localB;
+auto lambda = [ptr = &localA, copy = localB] (Integer x) -> Integer {
+  return *ptr + copy + x;
+};
+  }
+};
+
+// RUN: c-index-test -test-load-source all -std=c++14 %s | FileCheck 
-check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: cxx14-lambdas.cpp:7:5: DeclStmt= Extent=[7:5 - 9:7]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:10: VarDecl=lambda:7:10 (Definition) 
Extent=[7:5 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:19: UnexposedExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:19: CallExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:19: UnexposedExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:19: LambdaExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:20: VariableRef=ptr:7:20 Extent=[7:20 - 
7:23]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:35: VariableRef=copy:7:35 Extent=[7:35 - 
7:39]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:27: DeclRefExpr=localA:6:9 Extent=[7:27 - 
7:33]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:42: DeclRefExpr=localB:6:17 Extent=[7:42 - 
7:48]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:59: ParmDecl=x:7:59 (Definition) 
Extent=[7:51 - 7:60]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:51: TypeRef=Integer:3:13 Extent=[7:51 - 
7:58]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:65: TypeRef=Integer:3:13 Extent=[7:65 - 
7:72]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:73: CompoundStmt= Extent=[7:73 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:8:7: ReturnStmt= Extent=[8:7 - 8:29]
+
+// RUN: env CINDEXTEST_INDEXLOCALSYMBOLS=1 c-index-test -index-file -std=c++14 
%s | FileCheck -check-prefix=CHECK-INDEX %s
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: ptr | USR: 
c:cxx14-lambdas.cpp@139@S@X@F@f#@Sa@F@operator()#I#1@ptr | lang: C | cursor: 
VariableRef=ptr:7:20 | loc: 7:20
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: copy | USR: 
c:cxx14-lambdas.cpp@154@S@X@F@f#@Sa@F@operator()#I#1@copy | lang: C | cursor: 
VariableRef=copy:7:35 | loc: 7:35
+// CHECK-INDEX: [indexDeclaration]: kind: variable | name: x | USR: 
c:cxx14-lambdas.cpp@170@S@X@F@f#@Sa@F@operator()#I#1@x | lang: C | cursor: 
ParmDecl=x:7:59 (Definition) | loc: 7:59
+// CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | USR: 
c:cxx14-lambdas.cpp@T@Integer | lang: C | cursor: TypeRef=Integer:3:13 | loc: 
7:51
+// CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | USR: 
c:cxx14-lambdas.cpp@T@Integer | lang: C | cursor: TypeRef=Integer:3:13 | loc: 
7:65
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: ptr | USR: 
c:cxx14-lambdas.cpp@139@S@X@F@f#@Sa@F@operator()#I#1@ptr | lang: C | cursor: 
DeclRefExpr=ptr:7:20 | loc: 8:15
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: copy | USR: 
c:cxx14-lambdas.cpp@154@S@X@F@f#@Sa@F@operator()#I#1@copy | lang: C | cursor: 
DeclRefExpr=copy:7:35 | loc: 8:21
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: x | USR: 
c:cxx14-lambdas.cpp@170@S@X@F@f#@Sa@F@operator()#I#1@x | lang: C | cursor: 
DeclRefExpr=x:7:59 | loc: 8:28

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=361234&r1=361233&r2=361234&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue May 21 02:21:35 2019
@@ -3134,12 +3134,11 @@ bool CursorVisitor::RunVisitorWorkList(V
   }
 
   case VisitorJob::LambdaExprPartsKind: {
-// Visit captures.
+// Visit non-init captures.
 const LambdaExpr *E = cast(&LI)->get();
 for (LambdaExpr::capture_iterator C = E->explicit_capture_begin(),
CEnd = E->explicit_capture_end();
  C != CEnd; ++C) {
-  // FIXME: Lambda init-captures.
   if (!C->capturesVariable())
 continue;
 
@@ -3148,6 +3147,11 @@ bool CursorVisitor::RunVisitorWorkList(V
   TU)))
 return true;
 }
+// Visit init captures
+for (auto InitExpr : E->capture_inits()) {
+  if (Visit(