r340521 - [libclang] Fix cursors for arguments of Subscript and Call operators
Author: yvvan Date: Thu Aug 23 02:48:11 2018 New Revision: 340521 URL: http://llvm.org/viewvc/llvm-project?rev=340521&view=rev Log: [libclang] Fix cursors for arguments of Subscript and Call operators The DeclRefExpr of CXXOperatorCallExpr refering to the custom operator is visited before the arguments to the operator call. For the Call and Subscript operator the range of this DeclRefExpr includes the whole call expression, so that all tokens in that range were mapped to the operator function, even the tokens of the arguments. Fix this by ensuring that this particular DeclRefExpr is visited last. Fixes PR25775. Fix by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D40481 Added: cfe/trunk/test/Index/annotate-operator-call-expr.cpp Modified: cfe/trunk/tools/libclang/CIndex.cpp Added: cfe/trunk/test/Index/annotate-operator-call-expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-operator-call-expr.cpp?rev=340521&view=auto == --- cfe/trunk/test/Index/annotate-operator-call-expr.cpp (added) +++ cfe/trunk/test/Index/annotate-operator-call-expr.cpp Thu Aug 23 02:48:11 2018 @@ -0,0 +1,84 @@ +struct Foo { + int operator[](int key); + int operator()(int key = 2); +}; + +void testFoo(Foo foo, int index) { + foo(); + foo(index); + + foo[index]; + foo[index + index]; + + foo[foo[index]]; + foo[foo() + foo[index]]; + foo[foo(index) + foo[index]]; +} + +// RUN: c-index-test -test-annotate-tokens=%s:7:1:7:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK1 +// CHECK1: Identifier: "foo" [7:3 - 7:6] DeclRefExpr=foo:6:18 +// CHECK1: Punctuation: "(" [7:6 - 7:7] DeclRefExpr=operator():3:7 RefName=[7:6 - 7:7] RefName=[7:7 - 7:8] +// CHECK1: Punctuation: ")" [7:7 - 7:8] DeclRefExpr=operator():3:7 RefName=[7:6 - 7:7] RefName=[7:7 - 7:8] +// CHECK1: Punctuation: ";" [7:8 - 7:9] CompoundStmt= + +// RUN: c-index-test -test-annotate-tokens=%s:8:1:8:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK2 +// CHECK2: Punctuation: "(" [8:6 - 8:7] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13] +// CHECK2: Identifier: "index" [8:7 - 8:12] DeclRefExpr=index:6:27 +// CHECK2: Punctuation: ")" [8:12 - 8:13] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13] +// CHECK2: Punctuation: ";" [8:13 - 8:14] CompoundStmt= + +// RUN: c-index-test -test-annotate-tokens=%s:10:1:10:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK3 +// CHECK3: Identifier: "foo" [10:3 - 10:6] DeclRefExpr=foo:6:18 +// CHECK3: Punctuation: "[" [10:6 - 10:7] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13] +// CHECK3: Identifier: "index" [10:7 - 10:12] DeclRefExpr=index:6:27 +// CHECK3: Punctuation: "]" [10:12 - 10:13] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13] +// CHECK3: Punctuation: ";" [10:13 - 10:14] CompoundStmt= + +// RUN: c-index-test -test-annotate-tokens=%s:11:1:11:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK4 +// CHECK4: Identifier: "foo" [11:3 - 11:6] DeclRefExpr=foo:6:18 +// CHECK4: Punctuation: "[" [11:6 - 11:7] DeclRefExpr=operator[]:2:7 RefName=[11:6 - 11:7] RefName=[11:20 - 11:21] +// CHECK4: Identifier: "index" [11:7 - 11:12] DeclRefExpr=index:6:27 +// CHECK4: Punctuation: "+" [11:13 - 11:14] BinaryOperator= +// CHECK4: Identifier: "index" [11:15 - 11:20] DeclRefExpr=index:6:27 +// CHECK4: Punctuation: "]" [11:20 - 11:21] DeclRefExpr=operator[]:2:7 RefName=[11:6 - 11:7] RefName=[11:20 - 11:21] +// CHECK4: Punctuation: ";" [11:21 - 11:22] CompoundStmt= + +// RUN: c-index-test -test-annotate-tokens=%s:13:1:13:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK5 +// CHECK5: Identifier: "foo" [13:3 - 13:6] DeclRefExpr=foo:6:18 +// CHECK5: Punctuation: "[" [13:6 - 13:7] DeclRefExpr=operator[]:2:7 RefName=[13:6 - 13:7] RefName=[13:17 - 13:18] +// CHECK5: Identifier: "foo" [13:7 - 13:10] DeclRefExpr=foo:6:18 +// CHECK5: Punctuation: "[" [13:10 - 13:11] DeclRefExpr=operator[]:2:7 RefName=[13:10 - 13:11] RefName=[13:16 - 13:17] +// CHECK5: Identifier: "index" [13:11 - 13:16] DeclRefExpr=index:6:27 +// CHECK5: Punctuation: "]" [13:16 - 13:17] DeclRefExpr=operator[]:2:7 RefName=[13:10 - 13:11] RefName=[13:16 - 13:17] +// CHECK5: Punctuation: "]" [13:17 - 13:18] DeclRefExpr=operator[]:2:7 RefName=[13:6 - 13:7] RefName=[13:17 - 13:18] +// CHECK5: Punctuation: ";" [13:18 - 13:19] CompoundStmt= + +// RUN: c-index-test -test-annotate-tokens=%s:14:1:14:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK6 +// CHECK6: Identifier: "foo" [14:3 - 14:6] DeclRefExpr=foo:6:18 +// CHECK6: Punctuation: "[" [14:6 - 14:7] DeclRefExpr=operator[]:2:7 RefName=[14:6 - 14:7] RefName=[14:25 - 14:26] +// CHECK6: Identifier: "foo" [14:7 - 14:10] DeclRefExpr=foo:6:18 +// CHECK6: Punctuation: "(" [14:10 - 14:11] DeclRefE
r332469 - [Frontend] Avoid running plugins during code completion parse
Author: yvvan Date: Wed May 16 06:50:05 2018 New Revision: 332469 URL: http://llvm.org/viewvc/llvm-project?rev=332469&view=rev Log: [Frontend] Avoid running plugins during code completion parse The parsing that is done for code completion is a special case that will discard any generated diagnostics, so avoid running plugins for this case in the first place to avoid performance penalties due to the plugins. A scenario for this is for example libclang with extra plugins like tidy. Patch by Nikolai Kosjar Differential Revision: https://reviews.llvm.org/D46050 Added: cfe/trunk/test/Index/complete-and-plugins.c Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=332469&r1=332468&r2=332469&view=diff == --- cfe/trunk/lib/Frontend/FrontendAction.cpp (original) +++ cfe/trunk/lib/Frontend/FrontendAction.cpp Wed May 16 06:50:05 2018 @@ -150,12 +150,16 @@ FrontendAction::CreateWrappedASTConsumer return nullptr; // If there are no registered plugins we don't need to wrap the consumer - if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end()) -return Consumer; - - // Collect the list of plugins that go before the main action (in Consumers) - // or after it (in AfterConsumers) - std::vector> Consumers; + if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end()) +return Consumer; + + // If this is a code completion run, avoid invoking the plugin consumers + if (CI.hasCodeCompletionConsumer()) +return Consumer; + + // Collect the list of plugins that go before the main action (in Consumers) + // or after it (in AfterConsumers) + std::vector> Consumers; std::vector> AfterConsumers; for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(), ie = FrontendPluginRegistry::end(); Added: cfe/trunk/test/Index/complete-and-plugins.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-and-plugins.c?rev=332469&view=auto == --- cfe/trunk/test/Index/complete-and-plugins.c (added) +++ cfe/trunk/test/Index/complete-and-plugins.c Wed May 16 06:50:05 2018 @@ -0,0 +1,6 @@ +// RUN: c-index-test -code-completion-at=%s:7:1 -load %llvmshlibdir/PrintFunctionNames%pluginext -add-plugin print-fns %s | FileCheck %s +// REQUIRES: plugins, examples +// CHECK: macro definition:{{.*}} +// CHECK-NOT: top-level-decl: "x" + +void x(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r332578 - [libclang] Allow skipping function bodies in preamble only
Author: yvvan Date: Thu May 17 00:31:29 2018 New Revision: 332578 URL: http://llvm.org/viewvc/llvm-project?rev=332578&view=rev Log: [libclang] Allow skipping function bodies in preamble only As an addition to CXTranslationUnit_SkipFunctionBodies, provide the new option CXTranslationUnit_LimitSkipFunctionBodiesToPreamble, which constraints the skipping of functions bodies to the preamble only. Function bodies in the main file are not affected if this option is set. Skipping function bodies only in the preamble is what clangd already does and the introduced flag implements it for libclang clients. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D45815 Added: cfe/trunk/test/Parser/skip-function-bodies.h Modified: cfe/trunk/include/clang-c/Index.h cfe/trunk/include/clang/Frontend/ASTUnit.h cfe/trunk/lib/Frontend/ASTUnit.cpp cfe/trunk/test/Parser/skip-function-bodies.mm cfe/trunk/tools/c-index-test/c-index-test.c cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang-c/Index.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=332578&r1=332577&r2=332578&view=diff == --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Thu May 17 00:31:29 2018 @@ -1321,13 +1321,21 @@ enum CXTranslationUnit_Flags { */ CXTranslationUnit_KeepGoing = 0x200, - /** - * Sets the preprocessor in a mode for parsing a single file only. - */ - CXTranslationUnit_SingleFileParse = 0x400 -}; - -/** + /** + * Sets the preprocessor in a mode for parsing a single file only. + */ + CXTranslationUnit_SingleFileParse = 0x400, + + /** + * \brief Used in combination with CXTranslationUnit_SkipFunctionBodies to + * constrain the skipping of function bodies to the preamble. + * + * The function bodies of the main file are not skipped. + */ + CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800, +}; + +/** * Returns the set of flags that is suitable for parsing a translation * unit that is being edited. * Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=332578&r1=332577&r2=332578&view=diff == --- cfe/trunk/include/clang/Frontend/ASTUnit.h (original) +++ cfe/trunk/include/clang/Frontend/ASTUnit.h Thu May 17 00:31:29 2018 @@ -78,12 +78,15 @@ class TargetInfo; namespace vfs { class FileSystem; - -} // namespace vfs - -/// Utility class for loading a ASTContext from an AST file. -class ASTUnit { -public: + +} // namespace vfs + +/// \brief Enumerates the available scopes for skipping function bodies. +enum class SkipFunctionBodiesScope { None, Preamble, PreambleAndMainFile }; + +/// Utility class for loading a ASTContext from an AST file. +class ASTUnit { +public: struct StandaloneFixIt { std::pair RemoveRange; std::pair InsertFromRange; @@ -345,12 +348,15 @@ private: unsigned CurrentTopLevelHashValue = 0; /// Bit used by CIndex to mark when a translation unit may be in an - /// inconsistent state, and is not safe to free. - unsigned UnsafeToFree : 1; - - /// Cache any "global" code-completion results, so that we can avoid - /// recomputing them with each completion. - void CacheCodeCompletionResults(); + /// inconsistent state, and is not safe to free. + unsigned UnsafeToFree : 1; + + /// \brief Enumerator specifying the scope for skipping function bodies. + SkipFunctionBodiesScope SkipFunctionBodies = SkipFunctionBodiesScope::None; + + /// Cache any "global" code-completion results, so that we can avoid + /// recomputing them with each completion. + void CacheCodeCompletionResults(); /// Clear out and deallocate void ClearCachedCompletionResults(); @@ -360,13 +366,13 @@ private: bool Parse(std::shared_ptr PCHContainerOps, std::unique_ptr OverrideMainBuffer, IntrusiveRefCntPtr VFS); - - std::unique_ptr getMainBufferWithPrecompiledPreamble( - std::shared_ptr PCHContainerOps, - const CompilerInvocation &PreambleInvocationIn, - IntrusiveRefCntPtr VFS, bool AllowRebuild = true, - unsigned MaxLines = 0); - void RealizeTopLevelDeclsFromPreamble(); + + std::unique_ptr getMainBufferWithPrecompiledPreamble( + std::shared_ptr PCHContainerOps, + CompilerInvocation &PreambleInvocationIn, + IntrusiveRefCntPtr VFS, bool AllowRebuild = true, + unsigned MaxLines = 0); + void RealizeTopLevelDeclsFromPreamble(); /// Transfers ownership of the objects (like SourceManager) from /// \param CI to this ASTUnit. @@ -798,15 +804,17 @@ public: ArrayRef RemappedFiles = None, bool RemappedFilesKeepOriginalName = true, unsigned PrecompilePreambleAfterNParses = 0, - TranslationUnitKind TUKind = TU_Complete,
r332585 - Revert https://reviews.llvm.org/D46050 and https://reviews.llvm.org/D45815
Author: yvvan Date: Thu May 17 02:15:22 2018 New Revision: 332585 URL: http://llvm.org/viewvc/llvm-project?rev=332585&view=rev Log: Revert https://reviews.llvm.org/D46050 and https://reviews.llvm.org/D45815 Windows line endings. Requires proper resubmission. Removed: cfe/trunk/test/Index/complete-and-plugins.c cfe/trunk/test/Parser/skip-function-bodies.h Modified: cfe/trunk/include/clang-c/Index.h cfe/trunk/include/clang/Frontend/ASTUnit.h cfe/trunk/lib/Frontend/ASTUnit.cpp cfe/trunk/lib/Frontend/FrontendAction.cpp cfe/trunk/test/Parser/skip-function-bodies.mm cfe/trunk/tools/c-index-test/c-index-test.c cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang-c/Index.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=332585&r1=332584&r2=332585&view=diff == --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Thu May 17 02:15:22 2018 @@ -1321,21 +1321,13 @@ enum CXTranslationUnit_Flags { */ CXTranslationUnit_KeepGoing = 0x200, - /** - * Sets the preprocessor in a mode for parsing a single file only. - */ - CXTranslationUnit_SingleFileParse = 0x400, - - /** - * \brief Used in combination with CXTranslationUnit_SkipFunctionBodies to - * constrain the skipping of function bodies to the preamble. - * - * The function bodies of the main file are not skipped. - */ - CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800, -}; - -/** + /** + * Sets the preprocessor in a mode for parsing a single file only. + */ + CXTranslationUnit_SingleFileParse = 0x400 +}; + +/** * Returns the set of flags that is suitable for parsing a translation * unit that is being edited. * Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=332585&r1=332584&r2=332585&view=diff == --- cfe/trunk/include/clang/Frontend/ASTUnit.h (original) +++ cfe/trunk/include/clang/Frontend/ASTUnit.h Thu May 17 02:15:22 2018 @@ -78,15 +78,12 @@ class TargetInfo; namespace vfs { class FileSystem; - -} // namespace vfs - -/// \brief Enumerates the available scopes for skipping function bodies. -enum class SkipFunctionBodiesScope { None, Preamble, PreambleAndMainFile }; - -/// Utility class for loading a ASTContext from an AST file. -class ASTUnit { -public: + +} // namespace vfs + +/// Utility class for loading a ASTContext from an AST file. +class ASTUnit { +public: struct StandaloneFixIt { std::pair RemoveRange; std::pair InsertFromRange; @@ -348,15 +345,12 @@ private: unsigned CurrentTopLevelHashValue = 0; /// Bit used by CIndex to mark when a translation unit may be in an - /// inconsistent state, and is not safe to free. - unsigned UnsafeToFree : 1; - - /// \brief Enumerator specifying the scope for skipping function bodies. - SkipFunctionBodiesScope SkipFunctionBodies = SkipFunctionBodiesScope::None; - - /// Cache any "global" code-completion results, so that we can avoid - /// recomputing them with each completion. - void CacheCodeCompletionResults(); + /// inconsistent state, and is not safe to free. + unsigned UnsafeToFree : 1; + + /// Cache any "global" code-completion results, so that we can avoid + /// recomputing them with each completion. + void CacheCodeCompletionResults(); /// Clear out and deallocate void ClearCachedCompletionResults(); @@ -366,13 +360,13 @@ private: bool Parse(std::shared_ptr PCHContainerOps, std::unique_ptr OverrideMainBuffer, IntrusiveRefCntPtr VFS); - - std::unique_ptr getMainBufferWithPrecompiledPreamble( - std::shared_ptr PCHContainerOps, - CompilerInvocation &PreambleInvocationIn, - IntrusiveRefCntPtr VFS, bool AllowRebuild = true, - unsigned MaxLines = 0); - void RealizeTopLevelDeclsFromPreamble(); + + std::unique_ptr getMainBufferWithPrecompiledPreamble( + std::shared_ptr PCHContainerOps, + const CompilerInvocation &PreambleInvocationIn, + IntrusiveRefCntPtr VFS, bool AllowRebuild = true, + unsigned MaxLines = 0); + void RealizeTopLevelDeclsFromPreamble(); /// Transfers ownership of the objects (like SourceManager) from /// \param CI to this ASTUnit. @@ -804,17 +798,15 @@ public: ArrayRef RemappedFiles = None, bool RemappedFilesKeepOriginalName = true, unsigned PrecompilePreambleAfterNParses = 0, - TranslationUnitKind TUKind = TU_Complete, - bool CacheCodeCompletionResults = false, - bool IncludeBriefCommentsInCodeCompletion = false, - bool AllowPCHWithCompilerErrors = false, - SkipFunctionBodiesScope SkipFunctionBodies = - SkipFunctionBodiesScope::None, - bool SingleFileParse = false, bool UserFilesAreVolatile = false, - bool
r332586 - [Frontend] Avoid running plugins during code completion parse
Author: yvvan Date: Thu May 17 02:21:07 2018 New Revision: 332586 URL: http://llvm.org/viewvc/llvm-project?rev=332586&view=rev Log: [Frontend] Avoid running plugins during code completion parse Second attempt. Proper line endings. The parsing that is done for code completion is a special case that will discard any generated diagnostics, so avoid running plugins for this case in the first place to avoid performance penalties due to the plugins. A scenario for this is for example libclang with extra plugins like tidy. Patch by Nikolai Kosjar Differential Revision: https://reviews.llvm.org/D46050 Added: cfe/trunk/test/Index/complete-and-plugins.c Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=332586&r1=332585&r2=332586&view=diff == --- cfe/trunk/lib/Frontend/FrontendAction.cpp (original) +++ cfe/trunk/lib/Frontend/FrontendAction.cpp Thu May 17 02:21:07 2018 @@ -153,6 +153,10 @@ FrontendAction::CreateWrappedASTConsumer if (FrontendPluginRegistry::begin() == FrontendPluginRegistry::end()) return Consumer; + // If this is a code completion run, avoid invoking the plugin consumers + if (CI.hasCodeCompletionConsumer()) +return Consumer; + // Collect the list of plugins that go before the main action (in Consumers) // or after it (in AfterConsumers) std::vector> Consumers; Added: cfe/trunk/test/Index/complete-and-plugins.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-and-plugins.c?rev=332586&view=auto == --- cfe/trunk/test/Index/complete-and-plugins.c (added) +++ cfe/trunk/test/Index/complete-and-plugins.c Thu May 17 02:21:07 2018 @@ -0,0 +1,6 @@ +// RUN: c-index-test -code-completion-at=%s:7:1 -load %llvmshlibdir/PrintFunctionNames%pluginext -add-plugin print-fns %s | FileCheck %s +// REQUIRES: plugins, examples +// CHECK: macro definition:{{.*}} +// CHECK-NOT: top-level-decl: "x" + +void x(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r332587 - [libclang] Allow skipping function bodies in preamble only
Author: yvvan Date: Thu May 17 02:24:37 2018 New Revision: 332587 URL: http://llvm.org/viewvc/llvm-project?rev=332587&view=rev Log: [libclang] Allow skipping function bodies in preamble only Second attempt. Fix line endings and warning. As an addition to CXTranslationUnit_SkipFunctionBodies, provide the new option CXTranslationUnit_LimitSkipFunctionBodiesToPreamble, which constraints the skipping of functions bodies to the preamble only. Function bodies in the main file are not affected if this option is set. Skipping function bodies only in the preamble is what clangd already does and the introduced flag implements it for libclang clients. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D45815 Added: cfe/trunk/test/Parser/skip-function-bodies.h Modified: cfe/trunk/include/clang-c/Index.h cfe/trunk/include/clang/Frontend/ASTUnit.h cfe/trunk/lib/Frontend/ASTUnit.cpp cfe/trunk/test/Parser/skip-function-bodies.mm cfe/trunk/tools/c-index-test/c-index-test.c cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang-c/Index.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=332587&r1=332586&r2=332587&view=diff == --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Thu May 17 02:24:37 2018 @@ -1324,7 +1324,15 @@ enum CXTranslationUnit_Flags { /** * Sets the preprocessor in a mode for parsing a single file only. */ - CXTranslationUnit_SingleFileParse = 0x400 + CXTranslationUnit_SingleFileParse = 0x400, + + /** + * \brief Used in combination with CXTranslationUnit_SkipFunctionBodies to + * constrain the skipping of function bodies to the preamble. + * + * The function bodies of the main file are not skipped. + */ + CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800 }; /** Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=332587&r1=332586&r2=332587&view=diff == --- cfe/trunk/include/clang/Frontend/ASTUnit.h (original) +++ cfe/trunk/include/clang/Frontend/ASTUnit.h Thu May 17 02:24:37 2018 @@ -81,6 +81,9 @@ class FileSystem; } // namespace vfs +/// \brief Enumerates the available scopes for skipping function bodies. +enum class SkipFunctionBodiesScope { None, Preamble, PreambleAndMainFile }; + /// Utility class for loading a ASTContext from an AST file. class ASTUnit { public: @@ -348,6 +351,9 @@ private: /// inconsistent state, and is not safe to free. unsigned UnsafeToFree : 1; + /// \brief Enumerator specifying the scope for skipping function bodies. + SkipFunctionBodiesScope SkipFunctionBodies = SkipFunctionBodiesScope::None; + /// Cache any "global" code-completion results, so that we can avoid /// recomputing them with each completion. void CacheCodeCompletionResults(); @@ -363,7 +369,7 @@ private: std::unique_ptr getMainBufferWithPrecompiledPreamble( std::shared_ptr PCHContainerOps, - const CompilerInvocation &PreambleInvocationIn, + CompilerInvocation &PreambleInvocationIn, IntrusiveRefCntPtr VFS, bool AllowRebuild = true, unsigned MaxLines = 0); void RealizeTopLevelDeclsFromPreamble(); @@ -801,9 +807,11 @@ public: TranslationUnitKind TUKind = TU_Complete, bool CacheCodeCompletionResults = false, bool IncludeBriefCommentsInCodeCompletion = false, - bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies = false, - bool SingleFileParse = false, - bool UserFilesAreVolatile = false, bool ForSerialization = false, + bool AllowPCHWithCompilerErrors = false, + SkipFunctionBodiesScope SkipFunctionBodies = + SkipFunctionBodiesScope::None, + bool SingleFileParse = false, bool UserFilesAreVolatile = false, + bool ForSerialization = false, llvm::Optional ModuleFormat = llvm::None, std::unique_ptr *ErrAST = nullptr, IntrusiveRefCntPtr VFS = nullptr); Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=332587&r1=332586&r2=332587&view=diff == --- cfe/trunk/lib/Frontend/ASTUnit.cpp (original) +++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu May 17 02:24:37 2018 @@ -1271,7 +1271,7 @@ makeStandaloneDiagnostic(const LangOptio std::unique_ptr ASTUnit::getMainBufferWithPrecompiledPreamble( std::shared_ptr PCHContainerOps, -const CompilerInvocation &PreambleInvocationIn, +CompilerInvocation &PreambleInvocationIn, IntrusiveRefCntPtr VFS, bool AllowRebuild, unsigned MaxLines) { auto MainFilePath = @@ -1338,9 +1338,18 @@ ASTUnit::getMainBufferWithPrecompiledPre SimpleTimer PreambleTimer
r333272 - Optionally add code completion results for arrow instead of dot
Author: yvvan Date: Fri May 25 05:56:26 2018 New Revision: 333272 URL: http://llvm.org/viewvc/llvm-project?rev=333272&view=rev Log: Optionally add code completion results for arrow instead of dot Currently getting such completions requires source correction, reparsing and calling completion again. And if it shows no results and rollback is required then it costs one more reparse. With this change it's possible to get all results which can be later filtered to split changes which require correction. Differential Revision: https://reviews.llvm.org/D41537 Modified: cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h cfe/trunk/include/clang/Sema/CodeCompleteOptions.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Frontend/ASTUnit.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Parse/ParseExpr.cpp cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp cfe/trunk/lib/Sema/SemaCodeComplete.cpp cfe/trunk/test/CodeCompletion/member-access.cpp Modified: cfe/trunk/include/clang/Driver/CC1Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=333272&r1=333271&r2=333272&view=diff == --- cfe/trunk/include/clang/Driver/CC1Options.td (original) +++ cfe/trunk/include/clang/Driver/CC1Options.td Fri May 25 05:56:26 2018 @@ -445,6 +445,8 @@ def no_code_completion_ns_level_decls : HelpText<"Do not include declarations inside namespaces (incl. global namespace) in the code-completion results.">; def code_completion_brief_comments : Flag<["-"], "code-completion-brief-comments">, HelpText<"Include brief documentation comments in code-completion results.">; +def code_completion_with_fixits : Flag<["-"], "code-completion-with-fixits">, + HelpText<"Include code completion results which require small fix-its.">; def disable_free : Flag<["-"], "disable-free">, HelpText<"Disable freeing of memory on exit">; def discard_value_names : Flag<["-"], "discard-value-names">, Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=333272&r1=333271&r2=333272&view=diff == --- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original) +++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Fri May 25 05:56:26 2018 @@ -783,6 +783,33 @@ public: /// The availability of this result. CXAvailabilityKind Availability = CXAvailability_Available; + /// FixIts that *must* be applied before inserting the text for the + /// corresponding completion item. + /// + /// Completion items with non-empty fixits will not be returned by default, + /// they should be explicitly requested by setting + /// CompletionOptions::IncludeFixIts. For the editors to be able to + /// compute position of the cursor for the completion item itself, the + /// following conditions are guaranteed to hold for RemoveRange of the stored + /// fixits: + /// - Ranges in the fixits are guaranteed to never contain the completion + /// point (or identifier under completion point, if any) inside them, except + /// at the start or at the end of the range. + /// - If a fixit range starts or ends with completion point (or starts or + /// ends after the identifier under completion point), it will contain at + /// least one character. It allows to unambiguously recompute completion + /// point after applying the fixit. + /// The intuition is that provided fixits change code around the identifier we + /// complete, but are not allowed to touch the identifier itself or the + /// completion point. One example of completion items with corrections are the + /// ones replacing '.' with '->' and vice versa: + /// std::unique_ptr> vec_ptr; + /// In 'vec_ptr.^', one of completion items is 'push_back', it requires + /// replacing '.' with '->'. + /// In 'vec_ptr->^', one of completion items is 'release', it requires + /// replacing '->' with '.'. + std::vector FixIts; + /// Whether this result is hidden by another name. bool Hidden : 1; @@ -807,15 +834,17 @@ public: NestedNameSpecifier *Qualifier = nullptr; /// Build a result that refers to a declaration. - CodeCompletionResult(const NamedDecl *Declaration, - unsigned Priority, + CodeCompletionResult(const NamedDecl *Declaration, unsigned Priority, NestedNameSpecifier *Qualifier = nullptr, bool QualifierIsInformative = false, - bool Accessible = true) + bool Accessible = true, + std::vector FixIts = std::vector()) : Declaration(Declaration), Priority(Priority), Kind(RK_Declaration), Hidden(false), QualifierIsInformative(QualifierIsInfo
r333276 - Fix members initialization order in constructor (fails with -Werror)
Author: yvvan Date: Fri May 25 06:46:07 2018 New Revision: 333276 URL: http://llvm.org/viewvc/llvm-project?rev=333276&view=rev Log: Fix members initialization order in constructor (fails with -Werror) Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=333276&r1=333275&r2=333276&view=diff == --- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original) +++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Fri May 25 06:46:07 2018 @@ -840,10 +840,10 @@ public: bool Accessible = true, std::vector FixIts = std::vector()) : Declaration(Declaration), Priority(Priority), Kind(RK_Declaration), -Hidden(false), QualifierIsInformative(QualifierIsInformative), +FixIts(std::move(FixIts)), Hidden(false), +QualifierIsInformative(QualifierIsInformative), StartsNestedNameSpecifier(false), AllParametersAreInformative(false), -DeclaringEntity(false), Qualifier(Qualifier), -FixIts(std::move(FixIts)) { +DeclaringEntity(false), Qualifier(Qualifier) { //FIXME: Add assert to check FixIts range requirements. computeCursorKindAndAvailability(Accessible); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r341656 - [libclang] Return the proper pointee type for 'auto' deduced to pointer
Author: yvvan Date: Fri Sep 7 06:23:51 2018 New Revision: 341656 URL: http://llvm.org/viewvc/llvm-project?rev=341656&view=rev Log: [libclang] Return the proper pointee type for 'auto' deduced to pointer Currently the resulting type is always invalid in such case. Differential Revision: https://reviews.llvm.org/D51281 Modified: cfe/trunk/test/Index/print-type.cpp cfe/trunk/tools/libclang/CXType.cpp Modified: cfe/trunk/test/Index/print-type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type.cpp?rev=341656&r1=341655&r2=341656&view=diff == --- cfe/trunk/test/Index/print-type.cpp (original) +++ cfe/trunk/test/Index/print-type.cpp Fri Sep 7 06:23:51 2018 @@ -75,6 +75,8 @@ template struct A {}; template using C = T; using baz = C>; +auto autoTemplPointer = &autoTemplRefParam; + // 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] @@ -182,3 +184,4 @@ using baz = C>; // CHECK: UnexposedExpr=templRefParam:71:40 [type=const Specialization &>] [typekind=Unexposed] const [templateargs/1= [type=Specialization &] [typekind=LValueReference]] [canonicaltype=const Specialization &>] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization &] [typekind=LValueReference]] [isPOD=1] // CHECK: DeclRefExpr=templRefParam:71:40 [type=Specialization &>] [typekind=Unexposed] [templateargs/1= [type=Specialization &] [typekind=LValueReference]] [canonicaltype=Specialization &>] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization &] [typekind=LValueReference]] [isPOD=1] // CHECK: TypeAliasDecl=baz:76:7 (Definition) [type=baz] [typekind=Typedef] [templateargs/1= [type=A] [typekind=Unexposed]] [canonicaltype=A] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=void] [typekind=Void]] [isPOD=0] +// CHECK: VarDecl=autoTemplPointer:78:6 (Definition) [type=Specialization &> *] [typekind=Auto] [canonicaltype=Specialization &> *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=Specialization &>] [pointeekind=Record] Modified: cfe/trunk/tools/libclang/CXType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=341656&r1=341655&r2=341656&view=diff == --- cfe/trunk/tools/libclang/CXType.cpp (original) +++ cfe/trunk/tools/libclang/CXType.cpp Fri Sep 7 06:23:51 2018 @@ -442,6 +442,7 @@ CXType clang_getPointeeType(CXType CT) { if (!TP) return MakeCXType(QualType(), GetTU(CT)); +try_again: switch (TP->getTypeClass()) { case Type::Pointer: T = cast(TP)->getPointeeType(); @@ -459,6 +460,12 @@ CXType clang_getPointeeType(CXType CT) { case Type::MemberPointer: T = cast(TP)->getPointeeType(); break; +case Type::Auto: +case Type::DeducedTemplateSpecialization: + TP = cast(TP)->getDeducedType().getTypePtrOrNull(); + if (TP) +goto try_again; + break; default: T = QualType(); break; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r321695 - [libclang] Add clang_getFileContents to libclang.exports
Author: yvvan Date: Wed Jan 3 01:17:08 2018 New Revision: 321695 URL: http://llvm.org/viewvc/llvm-project?rev=321695&view=rev Log: [libclang] Add clang_getFileContents to libclang.exports This is the follow up patch for rL319881 which introduced the function but did not put it into .exports file. Modified: cfe/trunk/tools/libclang/libclang.exports Modified: cfe/trunk/tools/libclang/libclang.exports URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=321695&r1=321694&r2=321695&view=diff == --- cfe/trunk/tools/libclang/libclang.exports (original) +++ cfe/trunk/tools/libclang/libclang.exports Wed Jan 3 01:17:08 2018 @@ -220,6 +220,7 @@ clang_getExceptionSpecificationType clang_getFieldDeclBitWidth clang_getExpansionLocation clang_getFile +clang_getFileContents clang_getFileLocation clang_getFileName clang_getFileTime ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r321697 - [libclang] Support querying whether a declaration is invalid
Author: yvvan Date: Wed Jan 3 01:49:31 2018 New Revision: 321697 URL: http://llvm.org/viewvc/llvm-project?rev=321697&view=rev Log: [libclang] Support querying whether a declaration is invalid This is useful for e.g. highlighting purposes in an IDE. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D40072 Modified: cfe/trunk/include/clang-c/Index.h cfe/trunk/test/Index/print-type-size.cpp cfe/trunk/tools/c-index-test/c-index-test.c cfe/trunk/tools/libclang/CIndex.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=321697&r1=321696&r2=321697&view=diff == --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Wed Jan 3 01:49:31 2018 @@ -29,13 +29,13 @@ * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes. * * The policy about the libclang API was always to keep it source and ABI - * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. - */ -#define CINDEX_VERSION_MAJOR 0 -#define CINDEX_VERSION_MINOR 45 - -#define CINDEX_VERSION_ENCODE(major, minor) ( \ - ((major) * 1) \ + * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. + */ +#define CINDEX_VERSION_MAJOR 0 +#define CINDEX_VERSION_MINOR 46 + +#define CINDEX_VERSION_ENCODE(major, minor) ( \ + ((major) * 1) \ + ((minor) * 1)) #define CINDEX_VERSION CINDEX_VERSION_ENCODE( \ @@ -2638,12 +2638,22 @@ CINDEX_LINKAGE enum CXCursorKind clang_g /** * \brief Determine whether the given cursor kind represents a declaration. - */ -CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); - -/** - * \brief Determine whether the given cursor kind represents a simple - * reference. + */ +CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); + +/** + * \brief Determine whether the given declaration is invalid. + * + * A declaration is invalid if it could not be parsed successfully. + * + * \returns non-zero if the cursor represents a declaration and it is + * invalid, otherwise NULL. + */ +CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor); + +/** + * \brief Determine whether the given cursor kind represents a simple + * reference. * * Note that other kinds of cursors (such as expressions) can also refer to * other cursors. Use clang_getCursorReferenced() to determine whether a Modified: cfe/trunk/test/Index/print-type-size.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type-size.cpp?rev=321697&r1=321696&r2=321697&view=diff == --- cfe/trunk/test/Index/print-type-size.cpp (original) +++ cfe/trunk/test/Index/print-type-size.cpp Wed Jan 3 01:49:31 2018 @@ -1,14 +1,14 @@ // from SemaCXX/class-layout.cpp // RUN: c-index-test -test-print-type-size %s -target x86_64-pc-linux-gnu | FileCheck -check-prefix=CHECK64 %s // RUN: c-index-test -test-print-type-size %s -target i386-apple-darwin9 | FileCheck -check-prefix=CHECK32 %s - -namespace basic { - -// CHECK64: VarDecl=v:[[@LINE+2]]:6 (Definition) [type=void] [typekind=Void] -// CHECK32: VarDecl=v:[[@LINE+1]]:6 (Definition) [type=void] [typekind=Void] -void v; - -// CHECK64: VarDecl=v1:[[@LINE+2]]:7 (Definition) [type=void *] [typekind=Pointer] [sizeof=8] [alignof=8] + +namespace basic { + +// CHECK64: VarDecl=v:[[@LINE+2]]:6 (Definition) (invalid) [type=void] [typekind=Void] +// CHECK32: VarDecl=v:[[@LINE+1]]:6 (Definition) (invalid) [type=void] [typekind=Void] +void v; + +// CHECK64: VarDecl=v1:[[@LINE+2]]:7 (Definition) [type=void *] [typekind=Pointer] [sizeof=8] [alignof=8] // CHECK32: VarDecl=v1:[[@LINE+1]]:7 (Definition) [type=void *] [typekind=Pointer] [sizeof=4] [alignof=4] void *v1; 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=321697&r1=321696&r2=321697&view=diff == --- cfe/trunk/tools/c-index-test/c-index-test.c (original) +++ cfe/trunk/tools/c-index-test/c-index-test.c Wed Jan 3 01:49:31 2018 @@ -809,12 +809,14 @@ static void PrintCursor(CXCursor Cursor, if (clang_EnumDecl_isScoped(Cursor)) printf(" (scoped)"); if (clang_Cursor_isVariadic(Cursor)) - printf(" (variadic)"); -if (clang_Cursor_isObjCOptional(Cursor)) - printf(" (@optional)"); - -switch (clang_getCursorExceptionSpecificationType(Cursor)) -{ + printf(" (variadic)"); +if (clang_Cursor_isObjCOptional(Cursor)) + printf(" (@optional)"); +if (clang_isInvalidDeclaration(Cursor)) + printf(" (invalid)"); + +switch (clang_getCursorExceptionSpecificationType(Cursor)) +{
r321698 - [libclang] Fix cursors for functions with trailing return type
Author: yvvan Date: Wed Jan 3 02:04:37 2018 New Revision: 321698 URL: http://llvm.org/viewvc/llvm-project?rev=321698&view=rev Log: [libclang] Fix cursors for functions with trailing return type For the function declaration auto foo5(Foo) -> Foo; the parameter tokens were mapped to cursors representing the FunctionDecl: Keyword: "auto" [1:1 - 1:5] FunctionDecl=test5:1:6 Identifier: "test5" [1:6 - 1:11] FunctionDecl=test5:1:6 Punctuation: "(" [1:11 - 1:12] FunctionDecl=test5:1:6 Identifier: "X" [1:12 - 1:13] FunctionDecl=test5:1:6 // Ops, not a TypeRef Punctuation: ")" [1:13 - 1:14] FunctionDecl=test5:1:6 Punctuation: "->" [1:15 - 1:17] FunctionDecl=test5:1:6 Identifier: "X" [1:18 - 1:19] TypeRef=struct X:7:8 Punctuation: ";" [1:19 - 1:20] Fix this by ensuring that the trailing return type is not visited as first. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D40561 Modified: cfe/trunk/test/Index/annotate-tokens.cpp cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/test/Index/annotate-tokens.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens.cpp?rev=321698&r1=321697&r2=321698&view=diff == --- cfe/trunk/test/Index/annotate-tokens.cpp (original) +++ cfe/trunk/test/Index/annotate-tokens.cpp Wed Jan 3 02:04:37 2018 @@ -34,13 +34,15 @@ void test4() { } class C { - ~C(); -}; - -// RUN: c-index-test -test-annotate-tokens=%s:1:1:38:1 %s -fno-delayed-template-parsing | FileCheck %s -// CHECK: Keyword: "struct" [1:1 - 1:7] StructDecl=bonk:1:8 (Definition) -// CHECK: Identifier: "bonk" [1:8 - 1:12] StructDecl=bonk:1:8 (Definition) -// CHECK: Punctuation: "{" [1:13 - 1:14] StructDecl=bonk:1:8 (Definition) + ~C(); +}; + +auto test5(X) -> X; + +// RUN: c-index-test -test-annotate-tokens=%s:1:1:41:1 %s -std=c++14 -fno-delayed-template-parsing | FileCheck %s +// CHECK: Keyword: "struct" [1:1 - 1:7] StructDecl=bonk:1:8 (Definition) +// CHECK: Identifier: "bonk" [1:8 - 1:12] StructDecl=bonk:1:8 (Definition) +// CHECK: Punctuation: "{" [1:13 - 1:14] StructDecl=bonk:1:8 (Definition) // CHECK: Punctuation: "}" [1:15 - 1:16] StructDecl=bonk:1:8 (Definition) // CHECK: Punctuation: ";" [1:16 - 1:17] // CHECK: Keyword: "void" [2:1 - 2:5] FunctionDecl=test:2:6 (Definition) @@ -181,12 +183,20 @@ class C { // CHECK: Punctuation: "(" [29:18 - 29:19] CXXMethod=foo:29:15 (Definition) // CHECK: Punctuation: ")" [29:19 - 29:20] CXXMethod=foo:29:15 (Definition) // CHECK: Punctuation: "{" [29:21 - 29:22] CompoundStmt= -// CHECK: Punctuation: "}" [29:22 - 29:23] CompoundStmt= -// CHECK: Punctuation: "~" [37:3 - 37:4] CXXDestructor=~C:37:3 -// CHECK: Identifier: "C" [37:4 - 37:5] CXXDestructor=~C:37:3 - -// RUN: env LIBCLANG_DISABLE_CRASH_RECOVERY=1 c-index-test -test-annotate-tokens=%s:32:1:32:13 %s | FileCheck %s -check-prefix=CHECK2 -// CHECK2: Keyword: "if" [32:3 - 32:5] IfStmt= +// CHECK: Punctuation: "}" [29:22 - 29:23] CompoundStmt= +// CHECK: Punctuation: "~" [37:3 - 37:4] CXXDestructor=~C:37:3 +// CHECK: Identifier: "C" [37:4 - 37:5] CXXDestructor=~C:37:3 +// CHECK: Keyword: "auto" [40:1 - 40:5] FunctionDecl=test5:40:6 +// CHECK: Identifier: "test5" [40:6 - 40:11] FunctionDecl=test5:40:6 +// CHECK: Punctuation: "(" [40:11 - 40:12] FunctionDecl=test5:40:6 +// CHECK: Identifier: "X" [40:12 - 40:13] TypeRef=struct X:7:8 +// CHECK: Punctuation: ")" [40:13 - 40:14] FunctionDecl=test5:40:6 +// CHECK: Punctuation: "->" [40:15 - 40:17] FunctionDecl=test5:40:6 +// CHECK: Identifier: "X" [40:18 - 40:19] TypeRef=struct X:7:8 +// CHECK: Punctuation: ";" [40:19 - 40:20] + +// RUN: env LIBCLANG_DISABLE_CRASH_RECOVERY=1 c-index-test -test-annotate-tokens=%s:32:1:32:13 %s | FileCheck %s -check-prefix=CHECK2 +// CHECK2: Keyword: "if" [32:3 - 32:5] IfStmt= // CHECK2: Punctuation: "(" [32:6 - 32:7] IfStmt= // CHECK2: Keyword: "int" [32:7 - 32:10] VarDecl=p:32:11 (Definition) // CHECK2: Identifier: "p" [32:11 - 32:12] VarDecl=p:32:11 (Definition) Modified: cfe/trunk/tools/libclang/CIndex.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=321698&r1=321697&r2=321698&view=diff == --- cfe/trunk/tools/libclang/CIndex.cpp (original) +++ cfe/trunk/tools/libclang/CIndex.cpp Wed Jan 3 02:04:37 2018 @@ -782,12 +782,22 @@ bool CursorVisitor::VisitDeclaratorDecl( if (VisitNestedNameSpecifierLoc(QualifierLoc)) return true; - return false; -} - -/// \brief Compare two base or member initializers based on their source order. -static int CompareCXXCtorInitializers(CXXCtorInitializer *const *X, - CXXCtorInitializer *const *Y) { + return false; +} + +static bool HasTrailingReturnType(FunctionDecl *ND) { + const QualType Ty = ND->getType(); + if (const FunctionType *AFT = Ty->getAs()) { +if (const FunctionProtoType *FT = dyn_cast
r321700 - Fix line endings.
Author: yvvan Date: Wed Jan 3 02:33:21 2018 New Revision: 321700 URL: http://llvm.org/viewvc/llvm-project?rev=321700&view=rev Log: Fix line endings. Modified: cfe/trunk/test/Index/annotate-tokens.cpp cfe/trunk/test/Index/print-type-size.cpp cfe/trunk/tools/c-index-test/c-index-test.c cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/test/Index/annotate-tokens.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens.cpp?rev=321700&r1=321699&r2=321700&view=diff == --- cfe/trunk/test/Index/annotate-tokens.cpp (original) +++ cfe/trunk/test/Index/annotate-tokens.cpp Wed Jan 3 02:33:21 2018 @@ -34,15 +34,15 @@ void test4() { } class C { - ~C(); -}; - -auto test5(X) -> X; - -// RUN: c-index-test -test-annotate-tokens=%s:1:1:41:1 %s -std=c++14 -fno-delayed-template-parsing | FileCheck %s -// CHECK: Keyword: "struct" [1:1 - 1:7] StructDecl=bonk:1:8 (Definition) -// CHECK: Identifier: "bonk" [1:8 - 1:12] StructDecl=bonk:1:8 (Definition) -// CHECK: Punctuation: "{" [1:13 - 1:14] StructDecl=bonk:1:8 (Definition) + ~C(); +}; + +auto test5(X) -> X; + +// RUN: c-index-test -test-annotate-tokens=%s:1:1:41:1 %s -std=c++14 -fno-delayed-template-parsing | FileCheck %s +// CHECK: Keyword: "struct" [1:1 - 1:7] StructDecl=bonk:1:8 (Definition) +// CHECK: Identifier: "bonk" [1:8 - 1:12] StructDecl=bonk:1:8 (Definition) +// CHECK: Punctuation: "{" [1:13 - 1:14] StructDecl=bonk:1:8 (Definition) // CHECK: Punctuation: "}" [1:15 - 1:16] StructDecl=bonk:1:8 (Definition) // CHECK: Punctuation: ";" [1:16 - 1:17] // CHECK: Keyword: "void" [2:1 - 2:5] FunctionDecl=test:2:6 (Definition) @@ -183,20 +183,20 @@ auto test5(X) -> X; // CHECK: Punctuation: "(" [29:18 - 29:19] CXXMethod=foo:29:15 (Definition) // CHECK: Punctuation: ")" [29:19 - 29:20] CXXMethod=foo:29:15 (Definition) // CHECK: Punctuation: "{" [29:21 - 29:22] CompoundStmt= -// CHECK: Punctuation: "}" [29:22 - 29:23] CompoundStmt= -// CHECK: Punctuation: "~" [37:3 - 37:4] CXXDestructor=~C:37:3 -// CHECK: Identifier: "C" [37:4 - 37:5] CXXDestructor=~C:37:3 -// CHECK: Keyword: "auto" [40:1 - 40:5] FunctionDecl=test5:40:6 -// CHECK: Identifier: "test5" [40:6 - 40:11] FunctionDecl=test5:40:6 -// CHECK: Punctuation: "(" [40:11 - 40:12] FunctionDecl=test5:40:6 -// CHECK: Identifier: "X" [40:12 - 40:13] TypeRef=struct X:7:8 -// CHECK: Punctuation: ")" [40:13 - 40:14] FunctionDecl=test5:40:6 -// CHECK: Punctuation: "->" [40:15 - 40:17] FunctionDecl=test5:40:6 -// CHECK: Identifier: "X" [40:18 - 40:19] TypeRef=struct X:7:8 -// CHECK: Punctuation: ";" [40:19 - 40:20] - -// RUN: env LIBCLANG_DISABLE_CRASH_RECOVERY=1 c-index-test -test-annotate-tokens=%s:32:1:32:13 %s | FileCheck %s -check-prefix=CHECK2 -// CHECK2: Keyword: "if" [32:3 - 32:5] IfStmt= +// CHECK: Punctuation: "}" [29:22 - 29:23] CompoundStmt= +// CHECK: Punctuation: "~" [37:3 - 37:4] CXXDestructor=~C:37:3 +// CHECK: Identifier: "C" [37:4 - 37:5] CXXDestructor=~C:37:3 +// CHECK: Keyword: "auto" [40:1 - 40:5] FunctionDecl=test5:40:6 +// CHECK: Identifier: "test5" [40:6 - 40:11] FunctionDecl=test5:40:6 +// CHECK: Punctuation: "(" [40:11 - 40:12] FunctionDecl=test5:40:6 +// CHECK: Identifier: "X" [40:12 - 40:13] TypeRef=struct X:7:8 +// CHECK: Punctuation: ")" [40:13 - 40:14] FunctionDecl=test5:40:6 +// CHECK: Punctuation: "->" [40:15 - 40:17] FunctionDecl=test5:40:6 +// CHECK: Identifier: "X" [40:18 - 40:19] TypeRef=struct X:7:8 +// CHECK: Punctuation: ";" [40:19 - 40:20] + +// RUN: env LIBCLANG_DISABLE_CRASH_RECOVERY=1 c-index-test -test-annotate-tokens=%s:32:1:32:13 %s | FileCheck %s -check-prefix=CHECK2 +// CHECK2: Keyword: "if" [32:3 - 32:5] IfStmt= // CHECK2: Punctuation: "(" [32:6 - 32:7] IfStmt= // CHECK2: Keyword: "int" [32:7 - 32:10] VarDecl=p:32:11 (Definition) // CHECK2: Identifier: "p" [32:11 - 32:12] VarDecl=p:32:11 (Definition) Modified: cfe/trunk/test/Index/print-type-size.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type-size.cpp?rev=321700&r1=321699&r2=321700&view=diff == --- cfe/trunk/test/Index/print-type-size.cpp (original) +++ cfe/trunk/test/Index/print-type-size.cpp Wed Jan 3 02:33:21 2018 @@ -1,14 +1,14 @@ // from SemaCXX/class-layout.cpp // RUN: c-index-test -test-print-type-size %s -target x86_64-pc-linux-gnu | FileCheck -check-prefix=CHECK64 %s // RUN: c-index-test -test-print-type-size %s -target i386-apple-darwin9 | FileCheck -check-prefix=CHECK32 %s - -namespace basic { - -// CHECK64: VarDecl=v:[[@LINE+2]]:6 (Definition) (invalid) [type=void] [typekind=Void] -// CHECK32: VarDecl=v:[[@LINE+1]]:6 (Definition) (invalid) [type=void] [typekind=Void] -void v; - -// CHECK64: VarDecl=v1:[[@LINE+2]]:7 (Definition) [type=void *] [typekind=Pointer] [sizeof=8] [alignof=8] + +namespace basic { + +// CHECK64: VarDecl=v:[[@LINE+2]]:6 (Definition) (invalid) [t
r321701 - Fix more line endings.
Author: yvvan Date: Wed Jan 3 02:40:11 2018 New Revision: 321701 URL: http://llvm.org/viewvc/llvm-project?rev=321701&view=rev Log: Fix more line endings. 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=321701&r1=321700&r2=321701&view=diff == --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Wed Jan 3 02:40:11 2018 @@ -29,13 +29,13 @@ * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes. * * The policy about the libclang API was always to keep it source and ABI - * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. - */ -#define CINDEX_VERSION_MAJOR 0 -#define CINDEX_VERSION_MINOR 46 - -#define CINDEX_VERSION_ENCODE(major, minor) ( \ - ((major) * 1) \ + * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. + */ +#define CINDEX_VERSION_MAJOR 0 +#define CINDEX_VERSION_MINOR 46 + +#define CINDEX_VERSION_ENCODE(major, minor) ( \ + ((major) * 1) \ + ((minor) * 1)) #define CINDEX_VERSION CINDEX_VERSION_ENCODE( \ @@ -2638,22 +2638,22 @@ CINDEX_LINKAGE enum CXCursorKind clang_g /** * \brief Determine whether the given cursor kind represents a declaration. - */ -CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); - -/** - * \brief Determine whether the given declaration is invalid. - * - * A declaration is invalid if it could not be parsed successfully. - * - * \returns non-zero if the cursor represents a declaration and it is - * invalid, otherwise NULL. - */ -CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor); - -/** - * \brief Determine whether the given cursor kind represents a simple - * reference. + */ +CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); + +/** + * \brief Determine whether the given declaration is invalid. + * + * A declaration is invalid if it could not be parsed successfully. + * + * \returns non-zero if the cursor represents a declaration and it is + * invalid, otherwise NULL. + */ +CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor); + +/** + * \brief Determine whether the given cursor kind represents a simple + * reference. * * Note that other kinds of cursors (such as expressions) can also refer to * other cursors. Use clang_getCursorReferenced() to determine whether a ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r321709 - [libclang] Fix cursors for functions with trailing return type
Author: yvvan Date: Wed Jan 3 06:35:48 2018 New Revision: 321709 URL: http://llvm.org/viewvc/llvm-project?rev=321709&view=rev Log: [libclang] Fix cursors for functions with trailing return type This one was rolled back as follow-up to the failing commit. Second try. For the function declaration auto foo5(Foo) -> Foo; the parameter tokens were mapped to cursors representing the FunctionDecl: Keyword: "auto" [1:1 - 1:5] FunctionDecl=test5:1:6 Identifier: "test5" [1:6 - 1:11] FunctionDecl=test5:1:6 Punctuation: "(" [1:11 - 1:12] FunctionDecl=test5:1:6 Identifier: "X" [1:12 - 1:13] FunctionDecl=test5:1:6 // Ops, not a TypeRef Punctuation: ")" [1:13 - 1:14] FunctionDecl=test5:1:6 Punctuation: "->" [1:15 - 1:17] FunctionDecl=test5:1:6 Identifier: "X" [1:18 - 1:19] TypeRef=struct X:7:8 Punctuation: ";" [1:19 - 1:20] Fix this by ensuring that the trailing return type is not visited as first. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D40561 Modified: cfe/trunk/test/Index/annotate-tokens.cpp cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/test/Index/annotate-tokens.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens.cpp?rev=321709&r1=321708&r2=321709&view=diff == --- cfe/trunk/test/Index/annotate-tokens.cpp (original) +++ cfe/trunk/test/Index/annotate-tokens.cpp Wed Jan 3 06:35:48 2018 @@ -37,7 +37,9 @@ class C { ~C(); }; -// RUN: c-index-test -test-annotate-tokens=%s:1:1:38:1 %s -fno-delayed-template-parsing | FileCheck %s +auto test5(X) -> X; + +// RUN: c-index-test -test-annotate-tokens=%s:1:1:41:1 %s -std=c++14 -fno-delayed-template-parsing | FileCheck %s // CHECK: Keyword: "struct" [1:1 - 1:7] StructDecl=bonk:1:8 (Definition) // CHECK: Identifier: "bonk" [1:8 - 1:12] StructDecl=bonk:1:8 (Definition) // CHECK: Punctuation: "{" [1:13 - 1:14] StructDecl=bonk:1:8 (Definition) @@ -184,6 +186,14 @@ class C { // CHECK: Punctuation: "}" [29:22 - 29:23] CompoundStmt= // CHECK: Punctuation: "~" [37:3 - 37:4] CXXDestructor=~C:37:3 // CHECK: Identifier: "C" [37:4 - 37:5] CXXDestructor=~C:37:3 +// CHECK: Keyword: "auto" [40:1 - 40:5] FunctionDecl=test5:40:6 +// CHECK: Identifier: "test5" [40:6 - 40:11] FunctionDecl=test5:40:6 +// CHECK: Punctuation: "(" [40:11 - 40:12] FunctionDecl=test5:40:6 +// CHECK: Identifier: "X" [40:12 - 40:13] TypeRef=struct X:7:8 +// CHECK: Punctuation: ")" [40:13 - 40:14] FunctionDecl=test5:40:6 +// CHECK: Punctuation: "->" [40:15 - 40:17] FunctionDecl=test5:40:6 +// CHECK: Identifier: "X" [40:18 - 40:19] TypeRef=struct X:7:8 +// CHECK: Punctuation: ";" [40:19 - 40:20] // RUN: env LIBCLANG_DISABLE_CRASH_RECOVERY=1 c-index-test -test-annotate-tokens=%s:32:1:32:13 %s | FileCheck %s -check-prefix=CHECK2 // CHECK2: Keyword: "if" [32:3 - 32:5] IfStmt= Modified: cfe/trunk/tools/libclang/CIndex.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=321709&r1=321708&r2=321709&view=diff == --- cfe/trunk/tools/libclang/CIndex.cpp (original) +++ cfe/trunk/tools/libclang/CIndex.cpp Wed Jan 3 06:35:48 2018 @@ -785,6 +785,16 @@ bool CursorVisitor::VisitDeclaratorDecl( return false; } +static bool HasTrailingReturnType(FunctionDecl *ND) { + const QualType Ty = ND->getType(); + if (const FunctionType *AFT = Ty->getAs()) { +if (const FunctionProtoType *FT = dyn_cast(AFT)) + return FT->hasTrailingReturn(); + } + + return false; +} + /// \brief Compare two base or member initializers based on their source order. static int CompareCXXCtorInitializers(CXXCtorInitializer *const *X, CXXCtorInitializer *const *Y) { @@ -804,14 +814,16 @@ bool CursorVisitor::VisitFunctionDecl(Fu // written. This requires a bit of work. TypeLoc TL = TSInfo->getTypeLoc().IgnoreParens(); FunctionTypeLoc FTL = TL.getAs(); +const bool HasTrailingRT = HasTrailingReturnType(ND); // If we have a function declared directly (without the use of a typedef), // visit just the return type. Otherwise, just visit the function's type // now. -if ((FTL && !isa(ND) && Visit(FTL.getReturnLoc())) || +if ((FTL && !isa(ND) && !HasTrailingRT && + Visit(FTL.getReturnLoc())) || (!FTL && Visit(TL))) return true; - + // Visit the nested-name-specifier, if present. if (NestedNameSpecifierLoc QualifierLoc = ND->getQualifierLoc()) if (VisitNestedNameSpecifierLoc(QualifierLoc)) @@ -827,7 +839,11 @@ bool CursorVisitor::VisitFunctionDecl(Fu // Visit the function parameters, if we have a function type. if (FTL && VisitFunctionTypeLoc(FTL, true)) return true; - + +// Visit the function's trailing return type. +if (FTL && HasTrailingRT && Visit(FTL.getReturnLoc())) + return true; + // FIXME: Attribu
Re: r321697 - [libclang] Support querying whether a declaration is invalid
Ok, I've asked Nikolai to recheck it on Linux and re-commited the rolled back change which is not connected with the failing one. From: hwennb...@google.com on behalf of Hans Wennborg Sent: Wednesday, January 3, 2018 3:27:48 PM To: Ivan Donchevskii; cfe-commits Subject: Re: r321697 - [libclang] Support querying whether a declaration is invalid I don't, but reverting your change made the test pass again. I was able to reproduce locally by adding -target ppc64le-unknown-linux to the run-line in test/Index/opencl-types.cl. On Wed, Jan 3, 2018 at 3:23 PM, Ivan Donchevskii wrote: > Hi! > I saw it but I don't see an issue in this change. Do you have an idea why > that happened? > > > From: hwennb...@google.com on behalf of Hans Wennborg > > Sent: Wednesday, January 3, 2018 3:21:52 PM > To: Ivan Donchevskii > Cc: cfe-commits > Subject: Re: r321697 - [libclang] Support querying whether a declaration is > invalid > > This caused failures on the buildbots. I've reverted it and the > commits that depended on it in r321708. See that commit message for > more details. > > On Wed, Jan 3, 2018 at 10:49 AM, Ivan Donchevskii via cfe-commits > wrote: >> Author: yvvan >> Date: Wed Jan 3 01:49:31 2018 >> New Revision: 321697 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=321697&view=rev >> Log: >> [libclang] Support querying whether a declaration is invalid >> >> This is useful for e.g. highlighting purposes in an IDE. >> >> Patch by Nikolai Kosjar. >> >> Differential Revision: https://reviews.llvm.org/D40072 >> >> Modified: >> cfe/trunk/include/clang-c/Index.h >> cfe/trunk/test/Index/print-type-size.cpp >> cfe/trunk/tools/c-index-test/c-index-test.c >> cfe/trunk/tools/libclang/CIndex.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=321697&r1=321696&r2=321697&view=diff >> >> == >> --- cfe/trunk/include/clang-c/Index.h (original) >> +++ cfe/trunk/include/clang-c/Index.h Wed Jan 3 01:49:31 2018 >> @@ -29,13 +29,13 @@ >> * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking >> changes. >> * >> * The policy about the libclang API was always to keep it source and ABI >> - * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. >> - */ >> -#define CINDEX_VERSION_MAJOR 0 >> -#define CINDEX_VERSION_MINOR 45 >> - >> -#define CINDEX_VERSION_ENCODE(major, minor) ( \ >> - ((major) * 1) \ >> + * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. >> + */ >> +#define CINDEX_VERSION_MAJOR 0 >> +#define CINDEX_VERSION_MINOR 46 >> + >> +#define CINDEX_VERSION_ENCODE(major, minor) ( \ >> + ((major) * 1) \ >> + ((minor) * 1)) >> >> #define CINDEX_VERSION CINDEX_VERSION_ENCODE( \ >> @@ -2638,12 +2638,22 @@ CINDEX_LINKAGE enum CXCursorKind clang_g >> >> /** >> * \brief Determine whether the given cursor kind represents a >> declaration. >> - */ >> -CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); >> - >> -/** >> - * \brief Determine whether the given cursor kind represents a simple >> - * reference. >> + */ >> +CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); >> + >> +/** >> + * \brief Determine whether the given declaration is invalid. >> + * >> + * A declaration is invalid if it could not be parsed successfully. >> + * >> + * \returns non-zero if the cursor represents a declaration and it is >> + * invalid, otherwise NULL. >> + */ >> +CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor); >> + >> +/** >> + * \brief Determine whether the given cursor kind represents a simple >> + * reference. >> * >> * Note that other kinds of cursors (such as expressions) can also refer >> to >> * other cursors. Use clang_getCursorReferenced() to determine whether a >> >> Modified: cfe/trunk/test/Index/print-type-size.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type-size.cpp?rev=321697&r1=321696&r2=321697&view=diff >> >> == >> --- cfe/trunk/test/
r321794 - [libclang] Support querying whether a declaration is invalid
Author: yvvan Date: Thu Jan 4 02:59:50 2018 New Revision: 321794 URL: http://llvm.org/viewvc/llvm-project?rev=321794&view=rev Log: [libclang] Support querying whether a declaration is invalid This is useful for e.g. highlighting purposes in an IDE. Note: First version of this patch was reverted due to failing tests in opencl-types.cl with -target ppc64le-unknown-linux. These tests are adapted now. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D40072 Modified: cfe/trunk/include/clang-c/Index.h cfe/trunk/test/Index/opencl-types.cl cfe/trunk/test/Index/print-type-size.cpp cfe/trunk/tools/c-index-test/c-index-test.c cfe/trunk/tools/libclang/CIndex.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=321794&r1=321793&r2=321794&view=diff == --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Thu Jan 4 02:59:50 2018 @@ -32,7 +32,7 @@ * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. */ #define CINDEX_VERSION_MAJOR 0 -#define CINDEX_VERSION_MINOR 45 +#define CINDEX_VERSION_MINOR 46 #define CINDEX_VERSION_ENCODE(major, minor) ( \ ((major) * 1) \ @@ -2642,6 +2642,16 @@ CINDEX_LINKAGE enum CXCursorKind clang_g CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); /** + * \brief Determine whether the given declaration is invalid. + * + * A declaration is invalid if it could not be parsed successfully. + * + * \returns non-zero if the cursor represents a declaration and it is + * invalid, otherwise NULL. + */ +CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor); + +/** * \brief Determine whether the given cursor kind represents a simple * reference. * Modified: cfe/trunk/test/Index/opencl-types.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/opencl-types.cl?rev=321794&r1=321793&r2=321794&view=diff == --- cfe/trunk/test/Index/opencl-types.cl (original) +++ cfe/trunk/test/Index/opencl-types.cl Thu Jan 4 02:59:50 2018 @@ -16,11 +16,11 @@ void kernel testFloatTypes() { double4 vectorDouble; } -// CHECK: VarDecl=scalarHalf:11:8 (Definition) [type=half] [typekind=Half] [isPOD=1] +// CHECK: VarDecl=scalarHalf:11:8 (Definition){{( \(invalid\))?}} [type=half] [typekind=Half] [isPOD=1] // CHECK: VarDecl=vectorHalf:12:9 (Definition) [type=half4] [typekind=Typedef] [canonicaltype=half __attribute__((ext_vector_type(4)))] [canonicaltypekind=Unexposed] [isPOD=1] // CHECK: VarDecl=scalarFloat:13:9 (Definition) [type=float] [typekind=Float] [isPOD=1] // CHECK: VarDecl=vectorFloat:14:10 (Definition) [type=float4] [typekind=Typedef] [canonicaltype=float __attribute__((ext_vector_type(4)))] [canonicaltypekind=Unexposed] [isPOD=1] -// CHECK: VarDecl=scalarDouble:15:10 (Definition) [type=double] [typekind=Double] [isPOD=1] +// CHECK: VarDecl=scalarDouble:15:10 (Definition){{( \(invalid\))?}} [type=double] [typekind=Double] [isPOD=1] // CHECK: VarDecl=vectorDouble:16:11 (Definition) [type=double4] [typekind=Typedef] [canonicaltype=double __attribute__((ext_vector_type(4)))] [canonicaltypekind=Unexposed] [isPOD=1] #pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable @@ -45,10 +45,10 @@ void kernel OCLImage3dROTest(read_only i // CHECK: ParmDecl=scalarOCLImage2dArrayRO:32:61 (Definition) [type=__read_only image2d_array_t] [typekind=OCLImage2dArrayRO] [isPOD=1] // CHECK: ParmDecl=scalarOCLImage2dDepthRO:33:61 (Definition) [type=__read_only image2d_depth_t] [typekind=OCLImage2dDepthRO] [isPOD=1] // CHECK: ParmDecl=scalarOCLImage2dArrayDepthRO:34:72 (Definition) [type=__read_only image2d_array_depth_t] [typekind=OCLImage2dArrayDepthRO] [isPOD=1] -// CHECK: ParmDecl=scalarOCLImage2dMSAARO:35:59 (Definition) [type=__read_only image2d_msaa_t] [typekind=OCLImage2dMSAARO] [isPOD=1] -// CHECK: ParmDecl=scalarOCLImage2dArrayMSAARO:36:70 (Definition) [type=__read_only image2d_array_msaa_t] [typekind=OCLImage2dArrayMSAARO] [isPOD=1] -// CHECK: ParmDecl=scalarOCLImage2dMSAADepthRO:37:70 (Definition) [type=__read_only image2d_msaa_depth_t] [typekind=OCLImage2dMSAADepthRO] [isPOD=1] -// CHECK: ParmDecl=scalarOCLImage2dArrayMSAADepthRO:38:81 (Definition) [type=__read_only image2d_array_msaa_depth_t] [typekind=OCLImage2dArrayMSAADepthRO] [isPOD=1] +// CHECK: ParmDecl=scalarOCLImage2dMSAARO:35:59 (Definition){{( \(invalid\))?}} [type=__read_only image2d_msaa_t] [typekind=OCLImage2dMSAARO] [isPOD=1] +// CHECK: ParmDecl=scalarOCLImage2dArrayMSAARO:36:70 (Definition){{( \(invalid\))?}} [type=__read_only image2d_array_msaa_t] [typekind=OCLImage2dArrayMSAARO] [isPOD=1] +// CHECK: ParmDecl=scalarOCLImage2dMSAADepthRO:37:70 (Definition){{( \(invalid\))?}}
r334070 - [Frontend] Honor UserFilesAreVolatile flag getting file buffer in ASTUnit
Author: yvvan Date: Wed Jun 6 00:17:26 2018 New Revision: 334070 URL: http://llvm.org/viewvc/llvm-project?rev=334070&view=rev Log: [Frontend] Honor UserFilesAreVolatile flag getting file buffer in ASTUnit Do not memory map the main file if the flag UserFilesAreVolatile is set to true in ASTUnit when calling FileSystem::getBufferForFile. Differential Revision: https://reviews.llvm.org/D47460 Modified: cfe/trunk/include/clang/Basic/FileManager.h cfe/trunk/lib/Basic/FileManager.cpp cfe/trunk/lib/Frontend/ASTUnit.cpp cfe/trunk/unittests/Frontend/ASTUnitTest.cpp Modified: cfe/trunk/include/clang/Basic/FileManager.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=334070&r1=334069&r2=334070&view=diff == --- cfe/trunk/include/clang/Basic/FileManager.h (original) +++ cfe/trunk/include/clang/Basic/FileManager.h Wed Jun 6 00:17:26 2018 @@ -239,7 +239,7 @@ public: getBufferForFile(const FileEntry *Entry, bool isVolatile = false, bool ShouldCloseOpenFile = true); llvm::ErrorOr> - getBufferForFile(StringRef Filename); + getBufferForFile(StringRef Filename, bool isVolatile = false); /// Get the 'stat' information for the given \p Path. /// Modified: cfe/trunk/lib/Basic/FileManager.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=334070&r1=334069&r2=334070&view=diff == --- cfe/trunk/lib/Basic/FileManager.cpp (original) +++ cfe/trunk/lib/Basic/FileManager.cpp Wed Jun 6 00:17:26 2018 @@ -450,13 +450,13 @@ FileManager::getBufferForFile(const File } llvm::ErrorOr> -FileManager::getBufferForFile(StringRef Filename) { +FileManager::getBufferForFile(StringRef Filename, bool isVolatile) { if (FileSystemOpts.WorkingDir.empty()) -return FS->getBufferForFile(Filename); +return FS->getBufferForFile(Filename, -1, true, isVolatile); SmallString<128> FilePath(Filename); FixupRelativePath(FilePath); - return FS->getBufferForFile(FilePath.c_str()); + return FS->getBufferForFile(FilePath.c_str(), -1, true, isVolatile); } /// getStatValue - Get the 'stat' information for the specified path, Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=334070&r1=334069&r2=334070&view=diff == --- cfe/trunk/lib/Frontend/ASTUnit.cpp (original) +++ cfe/trunk/lib/Frontend/ASTUnit.cpp Wed Jun 6 00:17:26 2018 @@ -156,7 +156,8 @@ static bool moveOnNoError(llvm::ErrorOr< static std::unique_ptr getBufferForFileHandlingRemapping(const CompilerInvocation &Invocation, vfs::FileSystem *VFS, - StringRef FilePath) { + StringRef FilePath, + bool isVolatile) { const auto &PreprocessorOpts = Invocation.getPreprocessorOpts(); // Try to determine if the main file has been remapped, either from the @@ -176,7 +177,7 @@ getBufferForFileHandlingRemapping(const llvm::sys::fs::UniqueID MID = MPathStatus->getUniqueID(); if (MainFileID == MID) { // We found a remapping. Try to load the resulting, remapped source. - BufferOwner = valueOrNull(VFS->getBufferForFile(RF.second)); + BufferOwner = valueOrNull(VFS->getBufferForFile(RF.second, -1, true, isVolatile)); if (!BufferOwner) return nullptr; } @@ -201,7 +202,7 @@ getBufferForFileHandlingRemapping(const // If the main source file was not remapped, load it now. if (!Buffer && !BufferOwner) { -BufferOwner = valueOrNull(VFS->getBufferForFile(FilePath)); +BufferOwner = valueOrNull(VFS->getBufferForFile(FilePath, -1, true, isVolatile)); if (!BufferOwner) return nullptr; } @@ -707,7 +708,7 @@ ASTDeserializationListener *ASTUnit::get std::unique_ptr ASTUnit::getBufferForFile(StringRef Filename, std::string *ErrorStr) { assert(FileMgr); - auto Buffer = FileMgr->getBufferForFile(Filename); + auto Buffer = FileMgr->getBufferForFile(Filename, UserFilesAreVolatile); if (Buffer) return std::move(*Buffer); if (ErrorStr) @@ -1278,7 +1279,7 @@ ASTUnit::getMainBufferWithPrecompiledPre PreambleInvocationIn.getFrontendOpts().Inputs[0].getFile(); std::unique_ptr MainFileBuffer = getBufferForFileHandlingRemapping(PreambleInvocationIn, VFS.get(), -MainFilePath); +MainFilePath, UserFilesAreVolatile); if (!MainFileBuffer) return nullptr; Modified: cfe/trunk/unittests/Frontend/ASTUnitTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Frontend/ASTUnitTest.cpp?rev=334070&r1=334069&r2=334070&view=di
r334072 - Fix build - use llvm::make_unique
Author: yvvan Date: Wed Jun 6 01:25:54 2018 New Revision: 334072 URL: http://llvm.org/viewvc/llvm-project?rev=334072&view=rev Log: Fix build - use llvm::make_unique Modified: cfe/trunk/unittests/Frontend/ASTUnitTest.cpp Modified: cfe/trunk/unittests/Frontend/ASTUnitTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Frontend/ASTUnitTest.cpp?rev=334072&r1=334071&r2=334072&view=diff == --- cfe/trunk/unittests/Frontend/ASTUnitTest.cpp (original) +++ cfe/trunk/unittests/Frontend/ASTUnitTest.cpp Wed Jun 6 01:25:54 2018 @@ -35,7 +35,7 @@ protected: std::unique_ptr createASTUnit(bool isVolatile) { EXPECT_FALSE(llvm::sys::fs::createTemporaryFile("ast-unit", "cpp", FD, InputFileName)); -input_file = std::make_unique(InputFileName, FD); +input_file = llvm::make_unique(InputFileName, FD); input_file->os() << ""; const char *Args[] = {"clang", "-xc++", InputFileName.c_str()}; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r334593 - [libclang] Optionally add code completion results for arrow instead of dot
Author: yvvan Date: Wed Jun 13 05:37:08 2018 New Revision: 334593 URL: http://llvm.org/viewvc/llvm-project?rev=334593&view=rev Log: [libclang] Optionally add code completion results for arrow instead of dot Follow up for D41537 - libclang part. Differential Revision: https://reviews.llvm.org/D46862 Added: cfe/trunk/test/Index/complete-arrow-dot.cpp Modified: cfe/trunk/include/clang-c/Index.h cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h cfe/trunk/tools/c-index-test/c-index-test.c cfe/trunk/tools/libclang/CIndex.cpp cfe/trunk/tools/libclang/CIndexCodeCompletion.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=334593&r1=334592&r2=334593&view=diff == --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Wed Jun 13 05:37:08 2018 @@ -32,7 +32,7 @@ * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. */ #define CINDEX_VERSION_MAJOR 0 -#define CINDEX_VERSION_MINOR 48 +#define CINDEX_VERSION_MINOR 49 #define CINDEX_VERSION_ENCODE(major, minor) ( \ ((major) * 1) \ @@ -1327,7 +1327,7 @@ enum CXTranslationUnit_Flags { CXTranslationUnit_SingleFileParse = 0x400, /** - * \brief Used in combination with CXTranslationUnit_SkipFunctionBodies to + * Used in combination with CXTranslationUnit_SkipFunctionBodies to * constrain the skipping of function bodies to the preamble. * * The function bodies of the main file are not skipped. @@ -4749,6 +4749,20 @@ typedef struct { } CXToken; /** + * Get the raw lexical token starting with the given location. + * + * \param TU the translation unit whose text is being tokenized. + * + * \param Location the source location with which the token starts. + * + * \returns The token starting with the given location or NULL if no such token + * exist. The returned pointer must be freed with clang_disposeTokens before the + * translation unit is destroyed. + */ +CINDEX_LINKAGE CXToken *clang_getToken(CXTranslationUnit TU, + CXSourceLocation Location); + +/** * Determine the kind of the given token. */ CINDEX_LINKAGE CXTokenKind clang_getTokenKind(CXToken); @@ -5244,6 +5258,70 @@ typedef struct { } CXCodeCompleteResults; /** + * Retrieve the number of fix-its for the given completion index. + * + * Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts + * option was set. + * + * \param results The structure keeping all completion results + * + * \param completion_index The index of the completion + * + * \return The number of fix-its which must be applied before the completion at + * completion_index can be applied + */ +CINDEX_LINKAGE unsigned +clang_getCompletionNumFixIts(CXCodeCompleteResults *results, + unsigned completion_index); + +/** + * Fix-its that *must* be applied before inserting the text for the + * corresponding completion. + * + * By default, clang_codeCompleteAt() only returns completions with empty + * fix-its. Extra completions with non-empty fix-its should be explicitly + * requested by setting CXCodeComplete_IncludeCompletionsWithFixIts. + * + * For the clients to be able to compute position of the cursor after applying + * fix-its, the following conditions are guaranteed to hold for + * replacement_range of the stored fix-its: + * - Ranges in the fix-its are guaranteed to never contain the completion + * point (or identifier under completion point, if any) inside them, except + * at the start or at the end of the range. + * - If a fix-it range starts or ends with completion point (or starts or + * ends after the identifier under completion point), it will contain at + * least one character. It allows to unambiguously recompute completion + * point after applying the fix-it. + * + * The intuition is that provided fix-its change code around the identifier we + * complete, but are not allowed to touch the identifier itself or the + * completion point. One example of completions with corrections are the ones + * replacing '.' with '->' and vice versa: + * + * std::unique_ptr> vec_ptr; + * In 'vec_ptr.^', one of the completions is 'push_back', it requires + * replacing '.' with '->'. + * In 'vec_ptr->^', one of the completions is 'release', it requires + * replacing '->' with '.'. + * + * \param results The structure keeping all completion results + * + * \param completion_index The index of the completion + * + * \param fixit_index The index of the fix-it for the completion at + * completion_index + * + * \param replacement_range The fix-it range that must be replaced before the + * completion at completion_index can be applied + * + * \returns The fix-it string that must replace the code at replacement_range + * before the co
r335211 - [Sema] Fix overloaded static functions for templates
Author: yvvan Date: Thu Jun 21 01:34:50 2018 New Revision: 335211 URL: http://llvm.org/viewvc/llvm-project?rev=335211&view=rev Log: [Sema] Fix overloaded static functions for templates Apply almost the same fix as https://reviews.llvm.org/D36390 but for templates. Differential Revision: https://reviews.llvm.org/D43453 Modified: cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/test/Index/complete-call.cpp Modified: cfe/trunk/lib/Sema/SemaOverload.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=335211&r1=335210&r2=335211&view=diff == --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) +++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Jun 21 01:34:50 2018 @@ -6363,63 +6363,61 @@ bool Sema::diagnoseArgIndependentDiagnos /// the overload candidate set. void Sema::AddFunctionCandidates(const UnresolvedSetImpl &Fns, ArrayRef Args, - OverloadCandidateSet& CandidateSet, + OverloadCandidateSet &CandidateSet, TemplateArgumentListInfo *ExplicitTemplateArgs, bool SuppressUserConversions, bool PartialOverloading, bool FirstArgumentIsBase) { for (UnresolvedSetIterator F = Fns.begin(), E = Fns.end(); F != E; ++F) { NamedDecl *D = F.getDecl()->getUnderlyingDecl(); -if (FunctionDecl *FD = dyn_cast(D)) { - ArrayRef FunctionArgs = Args; - if (isa(FD) && !cast(FD)->isStatic()) { -QualType ObjectType; -Expr::Classification ObjectClassification; -if (Args.size() > 0) { - if (Expr *E = Args[0]) { -// Use the explicit base to restrict the lookup: -ObjectType = E->getType(); -ObjectClassification = E->Classify(Context); - } // .. else there is an implit base. - FunctionArgs = Args.slice(1); -} -AddMethodCandidate(cast(FD), F.getPair(), - cast(FD)->getParent(), ObjectType, - ObjectClassification, FunctionArgs, CandidateSet, - SuppressUserConversions, PartialOverloading); - } else { -// Slice the first argument (which is the base) when we access -// static method as non-static -if (Args.size() > 0 && (!Args[0] || (FirstArgumentIsBase && isa(FD) && - !isa(FD { - assert(cast(FD)->isStatic()); - FunctionArgs = Args.slice(1); -} -AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet, - SuppressUserConversions, PartialOverloading); - } -} else { - FunctionTemplateDecl *FunTmpl = cast(D); - if (isa(FunTmpl->getTemplatedDecl()) && - !cast(FunTmpl->getTemplatedDecl())->isStatic()) { -QualType ObjectType; -Expr::Classification ObjectClassification; +ArrayRef FunctionArgs = Args; + +FunctionTemplateDecl *FunTmpl = dyn_cast(D); +FunctionDecl *FD = +FunTmpl ? FunTmpl->getTemplatedDecl() : cast(D); + +if (isa(FD) && !cast(FD)->isStatic()) { + QualType ObjectType; + Expr::Classification ObjectClassification; + if (Args.size() > 0) { if (Expr *E = Args[0]) { // Use the explicit base to restrict the lookup: ObjectType = E->getType(); ObjectClassification = E->Classify(Context); -} // .. else there is an implit base. +} // .. else there is an implicit base. +FunctionArgs = Args.slice(1); + } + if (FunTmpl) { AddMethodTemplateCandidate( FunTmpl, F.getPair(), cast(FunTmpl->getDeclContext()), ExplicitTemplateArgs, ObjectType, ObjectClassification, -Args.slice(1), CandidateSet, SuppressUserConversions, +FunctionArgs, CandidateSet, SuppressUserConversions, PartialOverloading); } else { -AddTemplateOverloadCandidate(FunTmpl, F.getPair(), - ExplicitTemplateArgs, Args, - CandidateSet, SuppressUserConversions, - PartialOverloading); +AddMethodCandidate(cast(FD), F.getPair(), + cast(FD)->getParent(), ObjectType, + ObjectClassification, FunctionArgs, CandidateSet, + SuppressUserConversions, PartialOverloading); + } +} else { + // This branch handles both standalone functions and static methods. + + // Slice the first argument (which is the base) when we access + // static method as non-static. + if (Args.size() > 0 && + (!Args[0] || (FirstArgumentIsBase && isa(FD) && +
r335220 - Fix line endings in recently updated test file
Author: yvvan Date: Thu Jun 21 05:39:24 2018 New Revision: 335220 URL: http://llvm.org/viewvc/llvm-project?rev=335220&view=rev Log: Fix line endings in recently updated test file Modified: cfe/trunk/test/Index/complete-call.cpp Modified: cfe/trunk/test/Index/complete-call.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-call.cpp?rev=335220&r1=335219&r2=335220&view=diff == --- cfe/trunk/test/Index/complete-call.cpp (original) +++ cfe/trunk/test/Index/complete-call.cpp Thu Jun 21 05:39:24 2018 @@ -109,39 +109,39 @@ void test() { struct Bar2 : public Bar { Bar2() { Bar::foo_1(); - } -}; - -struct BarTemplates { - static void foo_1() {} - void foo_1(float) {} - static void foo_1(int) {} - - template - static void foo_1(T1 a, T2 b) { a + b; } - - template - void foo_1(T1 a, T2 b, float c) { a + b + c; } - - template - static void foo_1(T2 a, int b, T1 c) { a + b + c; } -}; - -void testTemplates() { - BarTemplates::foo_1(); - BarTemplates b; - b.foo_1(); -} - -struct Bar2Template : public BarTemplates { - Bar2Template() { -BarTemplates::foo_1(); - } -}; - -// RUN: c-index-test -code-completion-at=%s:47:9 %s | FileCheck -check-prefix=CHECK-CC1 %s -// CHECK-CC1: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1) -// CHECK-CC1: Completion contexts: + } +}; + +struct BarTemplates { + static void foo_1() {} + void foo_1(float) {} + static void foo_1(int) {} + + template + static void foo_1(T1 a, T2 b) { a + b; } + + template + void foo_1(T1 a, T2 b, float c) { a + b + c; } + + template + static void foo_1(T2 a, int b, T1 c) { a + b + c; } +}; + +void testTemplates() { + BarTemplates::foo_1(); + BarTemplates b; + b.foo_1(); +} + +struct Bar2Template : public BarTemplates { + Bar2Template() { +BarTemplates::foo_1(); + } +}; + +// RUN: c-index-test -code-completion-at=%s:47:9 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1) +// CHECK-CC1: Completion contexts: // CHECK-CC1-NEXT: Any type // CHECK-CC1-NEXT: Any value // CHECK-CC1-NEXT: Enum tag @@ -887,30 +887,30 @@ struct Bar2Template : public BarTemplate // CHECK-CC62-NEXT: Enum tag // CHECK-CC62-NEXT: Union tag // CHECK-CC62-NEXT: Struct tag -// CHECK-CC62-NEXT: Class name -// CHECK-CC62-NEXT: Nested name specifier -// CHECK-CC62-NEXT: Objective-C interface - -// RUN: c-index-test -code-completion-at=%s:131:23 %s | FileCheck -check-prefix=CHECK-CC63 %s -// CHECK-CC63: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1) -// CHECK-CC63: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter float}{RightParen )} (1) -// CHECK-CC63: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter int}{RightParen )} (1) -// CHECK-CC63: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter T1 a}{Comma , }{Placeholder T2 b}{RightParen )} (1) -// CHECK-CC63: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter T1 a}{Comma , }{Placeholder T2 b}{Comma , }{Placeholder float c}{RightParen )} (1) -// CHECK-CC63: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter T2 a}{Comma , }{Placeholder int b}{Comma , }{Placeholder T1 c}{RightParen )} (1) - -// RUN: c-index-test -code-completion-at=%s:133:11 %s | FileCheck -check-prefix=CHECK-CC64 %s -// CHECK-CC64: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1) -// CHECK-CC64: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter float}{RightParen )} (1) -// CHECK-CC64: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter int}{RightParen )} (1) -// CHECK-CC64: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter T1 a}{Comma , }{Placeholder T2 b}{RightParen )} (1) -// CHECK-CC64: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter T2 a}{Comma , }{Placeholder int b}{Comma , }{Placeholder T1 c}{RightParen )} (1) - -// RUN: c-index-test -code-completion-at=%s:138:25 %s | FileCheck -check-prefix=CHECK-CC65 %s -// CHECK-CC65: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1) -// CHECK-CC65: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter float}{RightParen )} (1) -// CHECK-CC65: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter int}{RightParen )} (1) -// CHECK-CC65: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter T1 a}{Comma , }{Placeholder T2 b}{RightParen )} (1) -// CHECK-CC65: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter T1 a}{Comma , }{Placeholder T2 b}{Comma , }{Placeholder float c}{RightParen )} (1) -// CHECK-CC65: OverloadCandidat
r347654 - [libclang] Fix clang_Cursor_getNumArguments and clang_Cursor_getArgument for CXXConstructExpr
Author: yvvan Date: Tue Nov 27 04:02:39 2018 New Revision: 347654 URL: http://llvm.org/viewvc/llvm-project?rev=347654&view=rev Log: [libclang] Fix clang_Cursor_getNumArguments and clang_Cursor_getArgument for CXXConstructExpr Constructors have the same methods for arguments as call expressions. Let's provide a way to get their arguments the same way. Differential Revision: https://reviews.llvm.org/D54934 Modified: cfe/trunk/test/Index/print-type.cpp cfe/trunk/tools/libclang/CXCursor.cpp Modified: cfe/trunk/test/Index/print-type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type.cpp?rev=347654&r1=347653&r2=347654&view=diff == --- cfe/trunk/test/Index/print-type.cpp (original) +++ cfe/trunk/test/Index/print-type.cpp Tue Nov 27 04:02:39 2018 @@ -77,6 +77,8 @@ using baz = C>; auto autoTemplPointer = &autoTemplRefParam; +outer::Foo parameter; +outer::inner::Bar construct(¶meter); // 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] @@ -185,3 +187,4 @@ auto autoTemplPointer = &autoTemplRefPar // CHECK: DeclRefExpr=templRefParam:71:40 [type=Specialization &>] [typekind=Unexposed] [templateargs/1= [type=Specialization &] [typekind=LValueReference]] [canonicaltype=Specialization &>] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization &] [typekind=LValueReference]] [isPOD=1] // CHECK: TypeAliasDecl=baz:76:7 (Definition) [type=baz] [typekind=Typedef] [templateargs/1= [type=A] [typekind=Unexposed]] [canonicaltype=A] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=void] [typekind=Void]] [isPOD=0] // CHECK: VarDecl=autoTemplPointer:78:6 (Definition) [type=Specialization &> *] [typekind=Auto] [canonicaltype=Specialization &> *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=Specialization &>] [pointeekind=Record] +// CHECK: CallExpr=Bar:17:3 [type=outer::inner::Bar] [typekind=Elaborated] [canonicaltype=outer::inner::Bar] [canonicaltypekind=Record] [args= [outer::Foo *] [Pointer]] [isPOD=0] [nbFields=3] Modified: cfe/trunk/tools/libclang/CXCursor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=347654&r1=347653&r2=347654&view=diff == --- cfe/trunk/tools/libclang/CXCursor.cpp (original) +++ cfe/trunk/tools/libclang/CXCursor.cpp Tue Nov 27 04:02:39 2018 @@ -1164,6 +1164,9 @@ int clang_Cursor_getNumArguments(CXCurso if (const CallExpr *CE = dyn_cast(E)) { return CE->getNumArgs(); } +if (const CXXConstructExpr *CE = dyn_cast(E)) { + return CE->getNumArgs(); +} } return -1; @@ -1189,6 +1192,13 @@ CXCursor clang_Cursor_getArgument(CXCurs if (i < CE->getNumArgs()) { return cxcursor::MakeCXCursor(CE->getArg(i), getCursorDecl(C), + cxcursor::getCursorTU(C)); + } +} +if (const CXXConstructExpr *CE = dyn_cast(E)) { + if (i < CE->getNumArgs()) { +return cxcursor::MakeCXCursor(CE->getArg(i), + getCursorDecl(C), cxcursor::getCursorTU(C)); } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r348764 - [libclang] Revert removal of tidy plugin support from libclang introduced in r347496
Author: yvvan Date: Mon Dec 10 07:58:50 2018 New Revision: 348764 URL: http://llvm.org/viewvc/llvm-project?rev=348764&view=rev Log: [libclang] Revert removal of tidy plugin support from libclang introduced in r347496 Differential Revision: https://reviews.llvm.org/D55415 Modified: cfe/trunk/tools/libclang/CIndex.cpp cfe/trunk/tools/libclang/CMakeLists.txt Modified: cfe/trunk/tools/libclang/CIndex.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=348764&r1=348763&r2=348764&view=diff == --- cfe/trunk/tools/libclang/CIndex.cpp (original) +++ cfe/trunk/tools/libclang/CIndex.cpp Mon Dec 10 07:58:50 2018 @@ -8938,3 +8938,16 @@ cxindex::Logger::~Logger() { OS << "--\n"; } } + +#ifdef CLANG_TOOL_EXTRA_BUILD +// This anchor is used to force the linker to link the clang-tidy plugin. +extern volatile int ClangTidyPluginAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED ClangTidyPluginAnchorDestination = +ClangTidyPluginAnchorSource; + +// This anchor is used to force the linker to link the clang-include-fixer +// plugin. +extern volatile int ClangIncludeFixerPluginAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED ClangIncludeFixerPluginAnchorDestination = +ClangIncludeFixerPluginAnchorSource; +#endif Modified: cfe/trunk/tools/libclang/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CMakeLists.txt?rev=348764&r1=348763&r2=348764&view=diff == --- cfe/trunk/tools/libclang/CMakeLists.txt (original) +++ cfe/trunk/tools/libclang/CMakeLists.txt Mon Dec 10 07:58:50 2018 @@ -47,6 +47,15 @@ if (CLANG_ENABLE_ARCMT) list(APPEND LIBS clangARCMigrate) endif () +if (TARGET clangTidyPlugin) + add_definitions(-DCLANG_TOOL_EXTRA_BUILD) + list(APPEND LIBS clangTidyPlugin) + list(APPEND LIBS clangIncludeFixerPlugin) + if(LLVM_ENABLE_MODULES) +list(APPEND LLVM_COMPILE_FLAGS "-fmodules-ignore-macro=CLANG_TOOL_EXTRA_BUILD") + endif() +endif () + find_library(DL_LIBRARY_PATH dl) if (DL_LIBRARY_PATH) list(APPEND LIBS dl) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r355586 - [libclang] Fix CXTranslationUnit_KeepGoing
Author: yvvan Date: Thu Mar 7 02:13:50 2019 New Revision: 355586 URL: http://llvm.org/viewvc/llvm-project?rev=355586&view=rev Log: [libclang] Fix CXTranslationUnit_KeepGoing Since commit 56f5487e4387a69708f70724d00e9e076153 [modules] Round-trip -Werror flag through explicit module build. the behavior of CXTranslationUnit_KeepGoing changed: Unresolved #includes are fatal errors again. As a consequence, some templates are not instantiated and lead to confusing errors. Revert to the old behavior: With CXTranslationUnit_KeepGoing fatal errors are mapped to errors. Patch by Nikolai Kosjar. Differential Revision: https://reviews.llvm.org/D58501 Added: cfe/trunk/test/Index/Inputs/keep-going-template-instantiations.h cfe/trunk/test/Index/keep-going-template-instantiations.cpp Modified: cfe/trunk/include/clang/Basic/Diagnostic.h cfe/trunk/lib/Basic/DiagnosticIDs.cpp cfe/trunk/test/Index/keep-going.cpp cfe/trunk/tools/libclang/CIndex.cpp cfe/trunk/unittests/Basic/DiagnosticTest.cpp Modified: cfe/trunk/include/clang/Basic/Diagnostic.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=355586&r1=355585&r2=355586&view=diff == --- cfe/trunk/include/clang/Basic/Diagnostic.h (original) +++ cfe/trunk/include/clang/Basic/Diagnostic.h Thu Mar 7 02:13:50 2019 @@ -209,8 +209,8 @@ private: // Used by __extension__ unsigned char AllExtensionsSilenced = 0; - // Suppress diagnostics after a fatal error? - bool SuppressAfterFatalError = true; + // Treat fatal errors like errors. + bool FatalsAsError = false; // Suppress all diagnostics. bool SuppressAllDiagnostics = false; @@ -614,9 +614,11 @@ public: void setErrorsAsFatal(bool Val) { GetCurDiagState()->ErrorsAsFatal = Val; } bool getErrorsAsFatal() const { return GetCurDiagState()->ErrorsAsFatal; } - /// When set to true (the default), suppress further diagnostics after - /// a fatal error. - void setSuppressAfterFatalError(bool Val) { SuppressAfterFatalError = Val; } + /// \brief When set to true, any fatal error reported is made an error. + /// + /// This setting takes precedence over the setErrorsAsFatal setting above. + void setFatalsAsError(bool Val) { FatalsAsError = Val; } + bool getFatalsAsError() const { return FatalsAsError; } /// When set to true mask warnings that come from system headers. void setSuppressSystemWarnings(bool Val) { Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=355586&r1=355585&r2=355586&view=diff == --- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original) +++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Thu Mar 7 02:13:50 2019 @@ -481,6 +481,11 @@ DiagnosticIDs::getDiagnosticSeverity(uns Result = diag::Severity::Fatal; } + // If explicitly requested, map fatal errors to errors. + if (Result == diag::Severity::Fatal && + Diag.CurDiagID != diag::fatal_too_many_errors && Diag.FatalsAsError) +Result = diag::Severity::Error; + // Custom diagnostics always are emitted in system headers. bool ShowInSystemHeader = !GetDiagInfo(DiagID) || GetDiagInfo(DiagID)->WarnShowInSystemHeader; @@ -660,7 +665,7 @@ bool DiagnosticIDs::ProcessDiag(Diagnost // If a fatal error has already been emitted, silence all subsequent // diagnostics. - if (Diag.FatalErrorOccurred && Diag.SuppressAfterFatalError) { + if (Diag.FatalErrorOccurred) { if (DiagLevel >= DiagnosticIDs::Error && Diag.Client->IncludeInDiagnosticCounts()) { ++Diag.NumErrors; Added: cfe/trunk/test/Index/Inputs/keep-going-template-instantiations.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Inputs/keep-going-template-instantiations.h?rev=355586&view=auto == --- cfe/trunk/test/Index/Inputs/keep-going-template-instantiations.h (added) +++ cfe/trunk/test/Index/Inputs/keep-going-template-instantiations.h Thu Mar 7 02:13:50 2019 @@ -0,0 +1,3 @@ +template struct c {}; +using d = c; +struct foo : public d {}; Added: cfe/trunk/test/Index/keep-going-template-instantiations.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/keep-going-template-instantiations.cpp?rev=355586&view=auto == --- cfe/trunk/test/Index/keep-going-template-instantiations.cpp (added) +++ cfe/trunk/test/Index/keep-going-template-instantiations.cpp Thu Mar 7 02:13:50 2019 @@ -0,0 +1,5 @@ +#include "missing.h" +#include + +// RUN: env CINDEXTEST_KEEP_GOING=1 c-index-test -test-load-source none -I%S/Inputs %s 2>&1 | FileCheck %s +// CHECK-NOT: error: expected class name Modified: cfe/trunk/test/Index/keep-going.cpp URL: http://llvm.org/viewvc/llvm-
r359448 - [libclang] Restore old clang_Cursor_isAnonymous behaviour
Author: yvvan Date: Mon Apr 29 06:44:07 2019 New Revision: 359448 URL: http://llvm.org/viewvc/llvm-project?rev=359448&view=rev Log: [libclang] Restore old clang_Cursor_isAnonymous behaviour D54996 Changed the behaviour of clang_Cursor_isAnonymous, but there is no alternative available to get the old behaviour in some cases, which is essential for determining if a record is syntactically accessible, e.g. struct { int x; int y; } foo; struct { struct { int x; int y; }; } bar; void fun(struct { int x; int y; } *param); The only 'anonymous' struct here is the one nested in bar, since there is no way to reference the struct itself, only the fields within. Though the anonymity applies to the instance itself, not the type. To avoid confusion, I have added a new function called clang_Cursor_isAnonymousRecordDecl which has the old behaviour of clang_Cursor_isAnonymous (and updated the doc for the latter as well, which was seemingly forgotten). Patch by Jorn Vernee. Differential Revision: https://reviews.llvm.org/D61232 Modified: cfe/trunk/include/clang-c/Index.h cfe/trunk/test/Index/print-type.c cfe/trunk/tools/c-index-test/c-index-test.c cfe/trunk/tools/libclang/CXType.cpp Modified: cfe/trunk/include/clang-c/Index.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=359448&r1=359447&r2=359448&view=diff == --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Mon Apr 29 06:44:07 2019 @@ -32,7 +32,7 @@ * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. */ #define CINDEX_VERSION_MAJOR 0 -#define CINDEX_VERSION_MINOR 55 +#define CINDEX_VERSION_MINOR 56 #define CINDEX_VERSION_ENCODE(major, minor) ( \ ((major) * 1) \ @@ -3921,10 +3921,16 @@ CINDEX_LINKAGE CXType clang_Type_getModi CINDEX_LINKAGE long long clang_Cursor_getOffsetOfField(CXCursor C); /** + * Determine whether the given cursor represents an anonymous + * tag or namespace + */ +CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C); + +/** * Determine whether the given cursor represents an anonymous record * declaration. */ -CINDEX_LINKAGE unsigned clang_Cursor_isAnonymous(CXCursor C); +CINDEX_LINKAGE unsigned clang_Cursor_isAnonymousRecordDecl(CXCursor C); enum CXRefQualifierKind { /** No ref-qualifier was provided. */ Modified: cfe/trunk/test/Index/print-type.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type.c?rev=359448&r1=359447&r2=359448&view=diff == --- cfe/trunk/test/Index/print-type.c (original) +++ cfe/trunk/test/Index/print-type.c Mon Apr 29 06:44:07 2019 @@ -15,6 +15,20 @@ int f2(int incompletearray[]); enum Enum{i}; enum Enum elaboratedEnumType(); struct Struct{}; struct Struct elaboratedStructType(); +struct { + int x; + int y; +} foo; + +struct { + struct { +int x; +int y; + }; +} bar; + +void fun(struct { int x; int y; } *param); + // RUN: c-index-test -test-print-type %s | FileCheck %s // CHECK: FunctionDecl=f:3:6 (Definition) [type=int *(int *, char *, FooType, int *, void (*)(int))] [typekind=FunctionProto] [canonicaltype=int *(int *, char *, int, int *, void (*)(int))] [canonicaltypekind=FunctionProto] [resulttype=int *] [resulttypekind=Pointer] [args= [int *] [Pointer] [char *] [Pointer] [FooType] [Typedef] [int [5]] [ConstantArray] [void (*)(int)] [Pointer]] [isPOD=0] // CHECK: ParmDecl=p:3:13 (Definition) [type=int *] [typekind=Pointer] [isPOD=1] [pointeetype=int] [pointeekind=Int] @@ -53,3 +67,7 @@ struct Struct{}; struct Struct elaborate // CHECK: StructDecl=Struct:16:8 (Definition) [type=struct Struct] [typekind=Record] [isPOD=1] // CHECK: FunctionDecl=elaboratedStructType:16:32 [type=struct Struct ()] [typekind=FunctionNoProto] [canonicaltype=struct Struct ()] [canonicaltypekind=FunctionNoProto] [resulttype=struct Struct] [resulttypekind=Elaborated] [isPOD=0] // CHECK: TypeRef=struct Struct:16:8 [type=struct Struct] [typekind=Record] [isPOD=1] +// CHECK: StructDecl=:18:1 (Definition) [type=struct (anonymous at {{.*}}print-type.c:18:1)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1] [isAnonRecDecl=0] +// CHECK: StructDecl=:23:1 (Definition) [type=struct (anonymous at {{.*}}print-type.c:23:1)] [typekind=Record] [isPOD=1] [nbFields=1] [isAnon=1] [isAnonRecDecl=0] +// CHECK: StructDecl=:24:3 (Definition) [type=struct (anonymous at {{.*}}print-type.c:24:3)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1] [isAnonRecDecl=1] +// CHECK: StructDecl=:30:10 (Definition) [type=struct (anonymous at {{.*}}print-type.c:30:10)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1] [isAnonRecDecl=0] 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=
r359453 - [libclang] Add missing export for clang_Cursor_isAnonymousRecordDecl
Author: yvvan Date: Mon Apr 29 07:13:11 2019 New Revision: 359453 URL: http://llvm.org/viewvc/llvm-project?rev=359453&view=rev Log: [libclang] Add missing export for clang_Cursor_isAnonymousRecordDecl Follow up for D61232 to fix build. Modified: cfe/trunk/tools/libclang/libclang.exports Modified: cfe/trunk/tools/libclang/libclang.exports URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=359453&r1=359452&r2=359453&view=diff == --- cfe/trunk/tools/libclang/libclang.exports (original) +++ cfe/trunk/tools/libclang/libclang.exports Mon Apr 29 07:13:11 2019 @@ -39,6 +39,7 @@ clang_Cursor_getSpellingNameRange clang_Cursor_getTranslationUnit clang_Cursor_getReceiverType clang_Cursor_isAnonymous +clang_Cursor_isAnonymousRecordDecl clang_Cursor_isBitField clang_Cursor_isDynamicCall clang_Cursor_isExternalSymbol ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r342721 - [CodeComplete] Generate completion fix-its for C code as well
Author: yvvan Date: Fri Sep 21 04:23:22 2018 New Revision: 342721 URL: http://llvm.org/viewvc/llvm-project?rev=342721&view=rev Log: [CodeComplete] Generate completion fix-its for C code as well Current completion fix-its approach does not provide OtherOpBase for C code. But we can easily proceed in this case taking the original Base type. Differential Revision: https://reviews.llvm.org/D52261 Modified: cfe/trunk/lib/Parse/ParseExpr.cpp cfe/trunk/test/CodeCompletion/member-access.c Modified: cfe/trunk/lib/Parse/ParseExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=342721&r1=342720&r2=342721&view=diff == --- cfe/trunk/lib/Parse/ParseExpr.cpp (original) +++ cfe/trunk/lib/Parse/ParseExpr.cpp Fri Sep 21 04:23:22 2018 @@ -1766,6 +1766,8 @@ Parser::ParsePostfixExpressionSuffix(Exp Expr *Base = LHS.get(); Expr *CorrectedBase = CorrectedLHS.get(); +if (!CorrectedBase && !getLangOpts().CPlusPlus) + CorrectedBase = Base; // Code completion for a member access expression. Actions.CodeCompleteMemberReferenceExpr( Modified: cfe/trunk/test/CodeCompletion/member-access.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/member-access.c?rev=342721&r1=342720&r2=342721&view=diff == --- cfe/trunk/test/CodeCompletion/member-access.c (original) +++ cfe/trunk/test/CodeCompletion/member-access.c Fri Sep 21 04:23:22 2018 @@ -10,3 +10,22 @@ void test(struct Point *p) { // CHECK-CC1: x // CHECK-CC1: y // CHECK-CC1: z +} + +struct Point2 { + float x; +}; + +void test2(struct Point2 p) { + p-> +} + +void test3(struct Point2 *p) { + p. +} + +// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:20:6 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: x (requires fix-it: {20:4-20:6} to ".") + +// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:24:5 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s +// CHECK-CC3: x (requires fix-it: {24:4-24:5} to "->") ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r365017 - [clang-tidy] Fix the YAML created for checks like modernize-pass-by-value
Author: yvvan Date: Wed Jul 3 03:21:50 2019 New Revision: 365017 URL: http://llvm.org/viewvc/llvm-project?rev=365017&view=rev Log: [clang-tidy] Fix the YAML created for checks like modernize-pass-by-value Currently this check generates the replacement with the newline in the end. The proper way to export it to YAML is to have two \n\n instead of one. Without this fix clients should reinterpret the replacement as "#include " instead of "#include \n" Differential Revision: https://reviews.llvm.org/D63482 Modified: cfe/trunk/include/clang/Tooling/ReplacementsYaml.h cfe/trunk/unittests/Tooling/ReplacementsYamlTest.cpp Modified: cfe/trunk/include/clang/Tooling/ReplacementsYaml.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ReplacementsYaml.h?rev=365017&r1=365016&r2=365017&view=diff == --- cfe/trunk/include/clang/Tooling/ReplacementsYaml.h (original) +++ cfe/trunk/include/clang/Tooling/ReplacementsYaml.h Wed Jul 3 03:21:50 2019 @@ -35,7 +35,13 @@ template <> struct MappingTraitshttp://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ReplacementsYamlTest.cpp?rev=365017&r1=365016&r2=365017&view=diff == --- cfe/trunk/unittests/Tooling/ReplacementsYamlTest.cpp (original) +++ cfe/trunk/unittests/Tooling/ReplacementsYamlTest.cpp Wed Jul 3 03:21:50 2019 @@ -46,6 +46,30 @@ TEST(ReplacementsYamlTest, serializesRep YamlContentStream.str().c_str()); } +TEST(ReplacementsYamlTest, serializesNewLines) { + TranslationUnitReplacements Doc; + + Doc.MainSourceFile = "/path/to/source.cpp"; + Doc.Replacements.emplace_back("/path/to/file1.h", 0, 0, "#include \n"); + + std::string YamlContent; + llvm::raw_string_ostream YamlContentStream(YamlContent); + + yaml::Output YAML(YamlContentStream); + YAML << Doc; + + // NOTE: If this test starts to fail for no obvious reason, check whitespace. + ASSERT_STREQ("---\n" + "MainSourceFile: '/path/to/source.cpp'\n" + "Replacements:\n" // Extra whitespace here! + " - FilePath:'/path/to/file1.h'\n" + "Offset: 0\n" + "Length: 0\n" + "ReplacementText: '#include \n\n'\n" + "...\n", + YamlContentStream.str().c_str()); +} + TEST(ReplacementsYamlTest, deserializesReplacements) { std::string YamlContent = "---\n" "MainSourceFile: /path/to/source.cpp\n" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r349038 - [clang-tidy] Share the forced linking code between clang-tidy tool and plugin
Author: yvvan Date: Thu Dec 13 06:37:17 2018 New Revision: 349038 URL: http://llvm.org/viewvc/llvm-project?rev=349038&view=rev Log: [clang-tidy] Share the forced linking code between clang-tidy tool and plugin Extract code that forces linking to the separate header and include it in both plugin and standalone tool Differential Revision: https://reviews.llvm.org/D55595 Added: clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h Modified: clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Added: clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h?rev=349038&view=auto == --- clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h (added) +++ clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h Thu Dec 13 06:37:17 2018 @@ -0,0 +1,108 @@ +//===- ClangTidyForceLinker.h - clang-tidy ===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "llvm/Support/Compiler.h" + +namespace clang { +namespace tidy { + +// This anchor is used to force the linker to link the CERTModule. +extern volatile int CERTModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination = +CERTModuleAnchorSource; + +// This anchor is used to force the linker to link the AbseilModule. +extern volatile int AbseilModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED AbseilModuleAnchorDestination = +AbseilModuleAnchorSource; + +// This anchor is used to force the linker to link the BoostModule. +extern volatile int BoostModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED BoostModuleAnchorDestination = +BoostModuleAnchorSource; + +// This anchor is used to force the linker to link the BugproneModule. +extern volatile int BugproneModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED BugproneModuleAnchorDestination = +BugproneModuleAnchorSource; + +// This anchor is used to force the linker to link the LLVMModule. +extern volatile int LLVMModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination = +LLVMModuleAnchorSource; + +// This anchor is used to force the linker to link the CppCoreGuidelinesModule. +extern volatile int CppCoreGuidelinesModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination = +CppCoreGuidelinesModuleAnchorSource; + +// This anchor is used to force the linker to link the FuchsiaModule. +extern volatile int FuchsiaModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED FuchsiaModuleAnchorDestination = +FuchsiaModuleAnchorSource; + +// This anchor is used to force the linker to link the GoogleModule. +extern volatile int GoogleModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination = +GoogleModuleAnchorSource; + +// This anchor is used to force the linker to link the AndroidModule. +extern volatile int AndroidModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination = +AndroidModuleAnchorSource; + +// This anchor is used to force the linker to link the MiscModule. +extern volatile int MiscModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination = +MiscModuleAnchorSource; + +// This anchor is used to force the linker to link the ModernizeModule. +extern volatile int ModernizeModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED ModernizeModuleAnchorDestination = +ModernizeModuleAnchorSource; + +#if CLANG_ENABLE_STATIC_ANALYZER +// This anchor is used to force the linker to link the MPIModule. +extern volatile int MPIModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED MPIModuleAnchorDestination = +MPIModuleAnchorSource; +#endif + +// This anchor is used to force the linker to link the PerformanceModule. +extern volatile int PerformanceModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED PerformanceModuleAnchorDestination = +PerformanceModuleAnchorSource; + +// This anchor is used to force the linker to link the PortabilityModule. +extern volatile int PortabilityModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED PortabilityModuleAnchorDestination = +PortabilityModuleAnchorSource; + +// This anchor is used to force the linker to link the ReadabilityModule. +extern volatile int ReadabilityModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED ReadabilityModuleAnchorDestination = +ReadabilityModuleAnchorSource; + +// This anchor is used to force the linker to link the ObjCModule. +extern volatile int ObjCModuleAnchorSource; +static int LLVM_ATTRIBUTE_UNUSED ObjCModuleAnchorDestinat
[clang-tools-extra] r349131 - [clang-tidy] Share the forced linking code between clang-tidy tool and plugin
Author: yvvan Date: Thu Dec 13 23:29:06 2018 New Revision: 349131 URL: http://llvm.org/viewvc/llvm-project?rev=349131&view=rev Log: [clang-tidy] Share the forced linking code between clang-tidy tool and plugin Extract code that forces linking to the separate header and include it in both plugin and standalone tool. Try 2: missing header guard and "clang/Config/config.h" are added to the new header. Differential Revision: https://reviews.llvm.org/D55595 Added: clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h - copied, changed from r349120, clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h Modified: clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Copied: clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h (from r349120, clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h) URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h?p2=clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h&p1=clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h&r1=349120&r2=349131&rev=349131&view=diff == --- clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h (original) +++ clang-tools-extra/trunk/clang-tidy/ClangTidyForceLinker.h Thu Dec 13 23:29:06 2018 @@ -7,6 +7,10 @@ // //===--===// +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYFORCELINKER_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYFORCELINKER_H + +#include "clang/Config/config.h" #include "llvm/Support/Compiler.h" namespace clang { @@ -106,3 +110,5 @@ static int LLVM_ATTRIBUTE_UNUSED ZirconM } // namespace tidy } // namespace clang + +#endif Modified: clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp?rev=349131&r1=349130&r2=349131&view=diff == --- clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp Thu Dec 13 23:29:06 2018 @@ -8,6 +8,7 @@ //===--===// #include "../ClangTidy.h" +#include "../ClangTidyForceLinker.h" #include "../ClangTidyModule.h" #include "clang/Config/config.h" #include "clang/Frontend/CompilerInstance.h" @@ -75,96 +76,3 @@ volatile int ClangTidyPluginAnchorSource static clang::FrontendPluginRegistry::Add X("clang-tidy", "clang-tidy"); - -namespace clang { -namespace tidy { - -// This anchor is used to force the linker to link the AbseilModule. -extern volatile int AbseilModuleAnchorSource; -static int LLVM_ATTRIBUTE_UNUSED AbseilModuleAnchorDestination = -AbseilModuleAnchorSource; - -// This anchor is used to force the linker to link the AndroidModule. -extern volatile int AndroidModuleAnchorSource; -static int LLVM_ATTRIBUTE_UNUSED AndroidModuleAnchorDestination = -AndroidModuleAnchorSource; - -// This anchor is used to force the linker to link the BoostModule. -extern volatile int BoostModuleAnchorSource; -static int LLVM_ATTRIBUTE_UNUSED BoostModuleAnchorDestination = -BoostModuleAnchorSource; - -// This anchor is used to force the linker to link the CERTModule. -extern volatile int CERTModuleAnchorSource; -static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination = -CERTModuleAnchorSource; - -// This anchor is used to force the linker to link the CppCoreGuidelinesModule. -extern volatile int CppCoreGuidelinesModuleAnchorSource; -static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination = -CppCoreGuidelinesModuleAnchorSource; - -// This anchor is used to force the linker to link the FuchsiaModule. -extern volatile int FuchsiaModuleAnchorSource; -static int LLVM_ATTRIBUTE_UNUSED FuchsiaModuleAnchorDestination = -FuchsiaModuleAnchorSource; - -// This anchor is used to force the linker to link the GoogleModule. -extern volatile int GoogleModuleAnchorSource; -static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination = -GoogleModuleAnchorSource; - -// This anchor is used to force the linker to link the HICPPModule. -extern volatile int HICPPModuleAnchorSource; -static int LLVM_ATTRIBUTE_UNUSED HICPPModuleAnchorDestination = -HICPPModuleAnchorSource; - -// This anchor is used to force the linker to link the LLVMModule. -extern volatile int LLVMModuleAnchorSource; -static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination = -LLVMModuleAnchorSource; - -// This anchor is used to force the linker to link the MiscModule. -extern volatile int MiscModuleAnchorSource; -static int LLVM_ATTRIBUTE_UNUSED MiscModuleAnchorDestination = -MiscModuleAnchorSource; - -// This anchor is used to force
[clang-tools-extra] r349132 - [clang-tidy] Remove extra config.h includes
Author: yvvan Date: Thu Dec 13 23:44:52 2018 New Revision: 349132 URL: http://llvm.org/viewvc/llvm-project?rev=349132&view=rev Log: [clang-tidy] Remove extra config.h includes It's included in a new header ClangTidyForceLinker.h and should not be included the second time. Follow up for the https://reviews.llvm.org/D55595 Modified: clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Modified: clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp?rev=349132&r1=349131&r2=349132&view=diff == --- clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/plugin/ClangTidyPlugin.cpp Thu Dec 13 23:44:52 2018 @@ -10,7 +10,6 @@ #include "../ClangTidy.h" #include "../ClangTidyForceLinker.h" #include "../ClangTidyModule.h" -#include "clang/Config/config.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendPluginRegistry.h" #include "clang/Frontend/MultiplexConsumer.h" Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=349132&r1=349131&r2=349132&view=diff == --- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Thu Dec 13 23:44:52 2018 @@ -17,7 +17,6 @@ #include "../ClangTidy.h" #include "../ClangTidyForceLinker.h" -#include "clang/Config/config.h" #include "clang/Tooling/CommonOptionsParser.h" #include "llvm/Support/Process.h" #include "llvm/Support/Signals.h" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r350805 - [libclang] Fix clang_Cursor_isAnonymous
Author: yvvan Date: Thu Jan 10 01:34:44 2019 New Revision: 350805 URL: http://llvm.org/viewvc/llvm-project?rev=350805&view=rev Log: [libclang] Fix clang_Cursor_isAnonymous Use the same logic as in TypePrinter::printTag to determine that the tag is anonymous and the separate check for namespaces. Differential Revision: https://reviews.llvm.org/D54996 Modified: cfe/trunk/test/Index/print-type.cpp cfe/trunk/tools/c-index-test/c-index-test.c cfe/trunk/tools/libclang/CXType.cpp Modified: cfe/trunk/test/Index/print-type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type.cpp?rev=350805&r1=350804&r2=350805&view=diff == --- cfe/trunk/test/Index/print-type.cpp (original) +++ cfe/trunk/test/Index/print-type.cpp Thu Jan 10 01:34:44 2019 @@ -79,6 +79,17 @@ auto autoTemplPointer = &autoTemplRefPar outer::Foo parameter; outer::inner::Bar construct(¶meter); + +class X { + struct { int a; }; + class { public: int b; }; + union { int c; int d;}; + enum { Test }; +}; + +namespace { + int a; +} // 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] @@ -188,3 +199,8 @@ outer::inner::Bar construct(¶meter); // CHECK: TypeAliasDecl=baz:76:7 (Definition) [type=baz] [typekind=Typedef] [templateargs/1= [type=A] [typekind=Unexposed]] [canonicaltype=A] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=void] [typekind=Void]] [isPOD=0] // CHECK: VarDecl=autoTemplPointer:78:6 (Definition) [type=Specialization &> *] [typekind=Auto] [canonicaltype=Specialization &> *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=Specialization &>] [pointeekind=Record] // CHECK: CallExpr=Bar:17:3 [type=outer::inner::Bar] [typekind=Elaborated] [canonicaltype=outer::inner::Bar] [canonicaltypekind=Record] [args= [outer::Foo *] [Pointer]] [isPOD=0] [nbFields=3] +// CHECK: StructDecl=:84:3 (Definition) [type=X::(anonymous struct at {{.*}}print-type.cpp:84:3)] [typekind=Record] [isPOD=1] [nbFields=1] [isAnon=1] +// CHECK: ClassDecl=:85:3 (Definition) [type=X::(anonymous class at {{.*}}print-type.cpp:85:3)] [typekind=Record] [isPOD=1] [nbFields=1] [isAnon=1] +// 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] 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=350805&r1=350804&r2=350805&view=diff == --- cfe/trunk/tools/c-index-test/c-index-test.c (original) +++ cfe/trunk/tools/c-index-test/c-index-test.c Thu Jan 10 01:34:44 2019 @@ -1654,13 +1654,14 @@ static enum CXChildVisitResult PrintType if (numFields != 0) { printf(" [nbFields=%d]", numFields); } -/* Print if it is an anonymous record. */ -{ - unsigned isAnon = clang_Cursor_isAnonymous(cursor); - if (isAnon != 0) { -printf(" [isAnon=%d]", isAnon); - } -} + } +} + +/* Print if it is an anonymous record or namespace. */ +{ + unsigned isAnon = clang_Cursor_isAnonymous(cursor); + if (isAnon != 0) { +printf(" [isAnon=%d]", isAnon); } } Modified: cfe/trunk/tools/libclang/CXType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=350805&r1=350804&r2=350805&view=diff == --- cfe/trunk/tools/libclang/CXType.cpp (original) +++ cfe/trunk/tools/libclang/CXType.cpp Thu Jan 10 01:34:44 2019 @@ -1229,11 +1229,15 @@ unsigned clang_Cursor_isAnonymous(CXCurs if (!clang_isDeclaration(C.kind)) return 0; const Decl *D = cxcursor::getCursorDecl(C); - if (const RecordDecl *FD = dyn_cast_or_null(D)) -return FD->isAnonymousStructOrUnion(); + if (const NamespaceDecl *ND = dyn_cast_or_null(D)) { +return ND->isAnonymousNamespace(); + } else if (const TagDecl *TD = dyn_cast_or_null(D)) { +return TD->getTypedefNameForAnonDecl() == nullptr && + TD->getIdentifier() == nullptr; + } + return 0; } - CXType clang_Type_getNamedType(CXType CT){ QualType T = GetQualType(CT); const Type *TP = T.getTypePtrOrNull(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r316758 - Test commit
Author: yvvan Date: Fri Oct 27 04:05:40 2017 New Revision: 316758 URL: http://llvm.org/viewvc/llvm-project?rev=316758&view=rev Log: Test commit Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=316758&r1=316757&r2=316758&view=diff == --- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original) +++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri Oct 27 04:05:40 2017 @@ -47,7 +47,7 @@ namespace { /// the result set (when it returns true) and which declarations should be /// filtered out (returns false). typedef bool (ResultBuilder::*LookupFilter)(const NamedDecl *) const; - + typedef CodeCompletionResult Result; private: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r322546 - Add missing CINDEX_LINKAGE
Author: yvvan Date: Tue Jan 16 04:11:59 2018 New Revision: 322546 URL: http://llvm.org/viewvc/llvm-project?rev=322546&view=rev Log: Add missing CINDEX_LINKAGE Follow up for [libclang] Add PrintingPolicy for pretty printing declarations Differential Revision: https://reviews.llvm.org/D39903 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=322546&r1=322545&r2=322546&view=diff == --- cfe/trunk/include/clang-c/Index.h (original) +++ cfe/trunk/include/clang-c/Index.h Tue Jan 16 04:11:59 2018 @@ -4136,16 +4136,16 @@ enum CXPrintingPolicyProperty { /** * \brief Get a property value for the given printing policy. */ -unsigned +CINDEX_LINKAGE unsigned clang_PrintingPolicy_getProperty(CXPrintingPolicy Policy, enum CXPrintingPolicyProperty Property); /** * \brief Set a property value for the given printing policy. */ -void clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy, - enum CXPrintingPolicyProperty Property, - unsigned Value); +CINDEX_LINKAGE void clang_PrintingPolicy_setProperty(CXPrintingPolicy Policy, + enum CXPrintingPolicyProperty Property, + unsigned Value); /** * \brief Retrieve the default policy for the cursor. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits