r260847 - c-index-test: Fix libdeps corresponding to r260841.

2016-02-14 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Sun Feb 14 03:19:04 2016
New Revision: 260847

URL: http://llvm.org/viewvc/llvm-project?rev=260847&view=rev
Log:
c-index-test: Fix libdeps corresponding to r260841.

Modified:
cfe/trunk/tools/c-index-test/CMakeLists.txt

Modified: cfe/trunk/tools/c-index-test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/CMakeLists.txt?rev=260847&r1=260846&r2=260847&view=diff
==
--- cfe/trunk/tools/c-index-test/CMakeLists.txt (original)
+++ cfe/trunk/tools/c-index-test/CMakeLists.txt Sun Feb 14 03:19:04 2016
@@ -22,6 +22,9 @@ if (LLVM_BUILD_STATIC)
 else()
   target_link_libraries(c-index-test
 libclang
+clangAST
+clangBasic
+clangFrontend
 clangIndex
   )
 endif()


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


Re: r260842 - [index] Enhance c-index-test tool and have it link and test the clangIndex library directly.

2016-02-14 Thread NAKAMURA Takumi via cfe-commits
Okay, I won't object as far as it were safe that libclang (many clang/llvm
libraries are linked) and other static libraries could stand side-by-side.

I supposed c-index-test is the tool to run and check libclang.

FYI, you should specify libraries that are used in the target. Updated
in r260847.

On Sun, Feb 14, 2016 at 4:53 PM Argyrios Kyrtzidis 
wrote:

> On Feb 13, 2016, at 11:34 PM, NAKAMURA Takumi 
> wrote:
>
> I guess it would break layering violation.
>
>
> Not sure what you mean, what is the layering violation ?
> I don’t see an issue with a tool binary linking both against the libclang
> C API and a C++ library. I could add yet another tool binary to link just
> against the C++ library but I preferred the simplicity of merging the
> functionality into the existing one and avoid maintaining yet another one.
>
>
> libclang exports just C API and it involves clangIndex, but coremain
> requires clangIndex and other dependent modules.
>
> I think you should do;
>   - Export C++ API in libclang. (But I don't expect it would work for
> win32)
>   - Link libclang as static. Then c-index-test became the test that didn't
> test "libclang".
>
> On Sun, Feb 14, 2016 at 3:43 PM Argyrios Kyrtzidis via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: akirtzidis
>> Date: Sun Feb 14 00:39:11 2016
>> New Revision: 260842
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=260842&view=rev
>> Log:
>> [index] Enhance c-index-test tool and have it link and test the
>> clangIndex library directly.
>>
>> Added:
>> cfe/trunk/test/Index/Core/
>> cfe/trunk/test/Index/Core/index-source.m
>> cfe/trunk/tools/c-index-test/core_main.cpp
>> Modified:
>> cfe/trunk/include/clang/Index/IndexSymbol.h
>> cfe/trunk/lib/Index/IndexSymbol.cpp
>> cfe/trunk/tools/c-index-test/CMakeLists.txt
>> cfe/trunk/tools/c-index-test/c-index-test.c
>>
>> Modified: cfe/trunk/include/clang/Index/IndexSymbol.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexSymbol.h?rev=260842&r1=260841&r2=260842&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Index/IndexSymbol.h (original)
>> +++ cfe/trunk/include/clang/Index/IndexSymbol.h Sun Feb 14 00:39:11 2016
>> @@ -11,6 +11,7 @@
>>  #define LLVM_CLANG_INDEX_INDEXSYMBOL_H
>>
>>  #include "clang/Basic/LLVM.h"
>> +#include "llvm/ADT/STLExtras.h"
>>  #include "llvm/Support/DataTypes.h"
>>
>>  namespace clang {
>> @@ -107,6 +108,13 @@ struct SymbolInfo {
>>
>>  SymbolInfo getSymbolInfo(const Decl *D);
>>
>> +void applyForEachSymbolRole(SymbolRoleSet Roles,
>> +llvm::function_ref Fn);
>> +void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS);
>> +StringRef getSymbolKindString(SymbolKind K);
>> +StringRef getTemplateKindStr(SymbolCXXTemplateKind TK);
>> +StringRef getSymbolLanguageString(SymbolLanguage K);
>> +
>>  } // namespace index
>>  } // namespace clang
>>
>>
>> Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=260842&r1=260841&r2=260842&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
>> +++ cfe/trunk/lib/Index/IndexSymbol.cpp Sun Feb 14 00:39:11 2016
>> @@ -185,3 +185,102 @@ SymbolInfo index::getSymbolInfo(const De
>>
>>return Info;
>>  }
>> +
>> +void index::applyForEachSymbolRole(SymbolRoleSet Roles,
>> +   llvm::function_ref
>> Fn) {
>> +#define APPLY_FOR_ROLE(Role) \
>> +  if (Roles & (unsigned)SymbolRole::Role) \
>> +Fn(SymbolRole::Role)
>> +
>> +  APPLY_FOR_ROLE(Declaration);
>> +  APPLY_FOR_ROLE(Definition);
>> +  APPLY_FOR_ROLE(Reference);
>> +  APPLY_FOR_ROLE(Read);
>> +  APPLY_FOR_ROLE(Write);
>> +  APPLY_FOR_ROLE(Call);
>> +  APPLY_FOR_ROLE(Dynamic);
>> +  APPLY_FOR_ROLE(AddressOf);
>> +  APPLY_FOR_ROLE(Implicit);
>> +  APPLY_FOR_ROLE(RelationChildOf);
>> +  APPLY_FOR_ROLE(RelationBaseOf);
>> +  APPLY_FOR_ROLE(RelationOverrideOf);
>> +  APPLY_FOR_ROLE(RelationReceivedBy);
>> +
>> +#undef APPLY_FOR_ROLE
>> +}
>> +
>> +void index::printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS) {
>> +  bool VisitedOnce = false;
>> +  applyForEachSymbolRole(Roles, [&](SymbolRole Role) {
>> +if (VisitedOnce)
>> +  OS << '/';
>> +else
>> +  VisitedOnce = true;
>> +switch (Role) {
>> +case SymbolRole::Declaration: OS << "Decl"; break;
>> +case SymbolRole::Definition: OS << "Def"; break;
>> +case SymbolRole::Reference: OS << "Ref"; break;
>> +case SymbolRole::Read: OS << "Read"; break;
>> +case SymbolRole::Write: OS << "Writ"; break;
>> +case SymbolRole::Call: OS << "Call"; break;
>> +case SymbolRole::Dynamic: OS << "Dyn"; break;
>> +case SymbolRole::AddressOf: OS << "Addr"; break;
>> +case SymbolRole::Implicit: OS << "Impl"; break;
>> +case SymbolRole::R

r260850 - Don't leak the ASTUnit when done with testing.

2016-02-14 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Feb 14 07:18:06 2016
New Revision: 260850

URL: http://llvm.org/viewvc/llvm-project?rev=260850&view=rev
Log:
Don't leak the ASTUnit when done with testing.

Found by lsan.

Modified:
cfe/trunk/tools/c-index-test/core_main.cpp

Modified: cfe/trunk/tools/c-index-test/core_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/core_main.cpp?rev=260850&r1=260849&r2=260850&view=diff
==
--- cfe/trunk/tools/c-index-test/core_main.cpp (original)
+++ cfe/trunk/tools/c-index-test/core_main.cpp Sun Feb 14 07:18:06 2016
@@ -123,9 +123,8 @@ static bool printSourceSymbols(ArrayRef<
  /*WrappedAction=*/nullptr);
 
   auto PCHContainerOps = std::make_shared();
-  ASTUnit *Unit =
-   ASTUnit::LoadFromCompilerInvocationAction(CInvok.get(), PCHContainerOps,
- Diags, IndexAction.get());
+  std::unique_ptr Unit(ASTUnit::LoadFromCompilerInvocationAction(
+  CInvok.get(), PCHContainerOps, Diags, IndexAction.get()));
 
   if (!Unit)
 return true;


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


Re: [PATCH] Add ObjCBoxable handling to ObjCMigrator

2016-02-14 Thread Alex Denisov via cfe-commits
Rebased against trunk:



objc_migrator_objc_boxable.patch
Description: Binary data


--
AlexDenisov
Software Engineer, http://lowlevelbits.org

> On 05 Dec 2015, at 22:19, John McCall  wrote:
> 
>> On Dec 5, 2015, at 7:58 AM, AlexDenisov <1101.deb...@gmail.com> wrote:
>> Extend ObjCMigrator to cover automatic migration from message sending to 
>> boxable literals, e.g.:
>> 
>> ```before
>> typedef struct __attribute__((objc_boxable)) CGRect CGRect;
>> /// ...
>> CGRect rect;
>> [NSValue valueWithBytes:&rect objCType:@encode(CGRect)];
>> [NSValue valueWithCGPoint:functionReturningCGPoint()];
>> ```
>> 
>> ```after
>> typedef struct __attribute__((objc_boxable)) CGRect CGRect;
>> /// ...
>> CGRect rect;
>> @(rect);
>> @(functionReturningCGPoint());
>> ```
>> 
>> I will appreciate any ideas how to improve it since the implementation is 
>> far from beautiful.
>> 
>> 
> 
> CC’ing Argyrios, who knows the migration code much better than I do.
> 
> John.



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r260851 - As reported in https://llvm.org/bugs/show_bug.cgi?id=25496, on FreeBSD,

2016-02-14 Thread Dimitry Andric via cfe-commits
Author: dim
Date: Sun Feb 14 10:08:20 2016
New Revision: 260851

URL: http://llvm.org/viewvc/llvm-project?rev=260851&view=rev
Log:
As reported in https://llvm.org/bugs/show_bug.cgi?id=25496, on FreeBSD,
C++ programs compiled for profiling (using `-pg`) should be linked with
`-lc++_p` (or `-lstdc++_p`, depending on the `-stdlib=` setting), not
with the regular C++ libraries.

Add a `FreeBSD::AddCXXStdlibLibArgs()` override to handle this, and add
a test case for it.  While here, extend the test case for the proper
passing of -lm and -lm_p.

Reviewers: compnerd, davide, dws, emaste
Reviewed By: compnerd
Differential Revision: http://reviews.llvm.org/D16264

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/test/Driver/freebsd.cpp

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=260851&r1=260850&r2=260851&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Sun Feb 14 10:08:20 2016
@@ -3128,6 +3128,22 @@ void FreeBSD::AddClangCXXStdlibIncludeAr
   }
 }
 
+void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args,
+  ArgStringList &CmdArgs) const {
+  CXXStdlibType Type = GetCXXStdlibType(Args);
+  bool Profiling = Args.hasArg(options::OPT_pg);
+
+  switch (Type) {
+  case ToolChain::CST_Libcxx:
+CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++");
+break;
+
+  case ToolChain::CST_Libstdcxx:
+CmdArgs.push_back(Profiling ? "-lstdc++_p" : "-lstdc++");
+break;
+  }
+}
+
 Tool *FreeBSD::buildAssembler() const {
   return new tools::freebsd::Assembler(*this);
 }

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=260851&r1=260850&r2=260851&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Sun Feb 14 10:08:20 2016
@@ -728,6 +728,8 @@ public:
   void AddClangCXXStdlibIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+   llvm::opt::ArgStringList &CmdArgs) const override;
 
   bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
   bool isPIEDefault() const override;

Modified: cfe/trunk/test/Driver/freebsd.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/freebsd.cpp?rev=260851&r1=260850&r2=260851&view=diff
==
--- cfe/trunk/test/Driver/freebsd.cpp (original)
+++ cfe/trunk/test/Driver/freebsd.cpp Sun Feb 14 10:08:20 2016
@@ -2,5 +2,12 @@
 // RUN:   | FileCheck --check-prefix=CHECK-TEN %s
 // RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd9.2 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NINE %s
-// CHECK-TEN: -lc++
-// CHECK-NINE: -lstdc++
+// CHECK-TEN: "-lc++" "-lm"
+// CHECK-NINE: "-lstdc++" "-lm"
+
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd10.0 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG-TEN %s
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd9.2 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG-NINE %s
+// CHECK-PG-TEN: "-lc++_p" "-lm_p"
+// CHECK-PG-NINE: "-lstdc++_p" "-lm_p"


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


Re: r260851 - As reported in https://llvm.org/bugs/show_bug.cgi?id=25496, on FreeBSD,

2016-02-14 Thread Dimitry Andric via cfe-commits
On 14 Feb 2016, at 17:08, Dimitry Andric via cfe-commits 
 wrote:
> 
> Author: dim
> Date: Sun Feb 14 10:08:20 2016
> New Revision: 260851
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=260851&view=rev
> Log:
> As reported in https://llvm.org/bugs/show_bug.cgi?id=25496, on FreeBSD,
> C++ programs compiled for profiling (using `-pg`) should be linked with
> `-lc++_p` (or `-lstdc++_p`, depending on the `-stdlib=` setting), not
> with the regular C++ libraries.
> 
> Add a `FreeBSD::AddCXXStdlibLibArgs()` override to handle this, and add
> a test case for it.  While here, extend the test case for the proper
> passing of -lm and -lm_p.
> 
> Reviewers: compnerd, davide, dws, emaste
> Reviewed By: compnerd
> Differential Revision: http://reviews.llvm.org/D16264

Hi Hans,

I would like to merge this to the 3.8 branch.  This only affects FreeBSD.

-Dimitry



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r260850 - Don't leak the ASTUnit when done with testing.

2016-02-14 Thread Argyrios Kyrtzidis via cfe-commits
Thanks!

> On Feb 14, 2016, at 5:18 AM, Benjamin Kramer via cfe-commits 
>  wrote:
> 
> Author: d0k
> Date: Sun Feb 14 07:18:06 2016
> New Revision: 260850
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=260850&view=rev
> Log:
> Don't leak the ASTUnit when done with testing.
> 
> Found by lsan.
> 
> Modified:
>cfe/trunk/tools/c-index-test/core_main.cpp
> 
> Modified: cfe/trunk/tools/c-index-test/core_main.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/core_main.cpp?rev=260850&r1=260849&r2=260850&view=diff
> ==
> --- cfe/trunk/tools/c-index-test/core_main.cpp (original)
> +++ cfe/trunk/tools/c-index-test/core_main.cpp Sun Feb 14 07:18:06 2016
> @@ -123,9 +123,8 @@ static bool printSourceSymbols(ArrayRef<
>  /*WrappedAction=*/nullptr);
> 
>   auto PCHContainerOps = std::make_shared();
> -  ASTUnit *Unit =
> -   ASTUnit::LoadFromCompilerInvocationAction(CInvok.get(), PCHContainerOps,
> - Diags, IndexAction.get());
> +  std::unique_ptr Unit(ASTUnit::LoadFromCompilerInvocationAction(
> +  CInvok.get(), PCHContainerOps, Diags, IndexAction.get()));
> 
>   if (!Unit)
> return true;
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


Re: r260847 - c-index-test: Fix libdeps corresponding to r260841.

2016-02-14 Thread Argyrios Kyrtzidis via cfe-commits
Which configuration required them ?
I was under the impression CMake is passing the transitive libdeps.

> On Feb 14, 2016, at 1:19 AM, NAKAMURA Takumi via cfe-commits 
>  wrote:
> 
> Author: chapuni
> Date: Sun Feb 14 03:19:04 2016
> New Revision: 260847
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=260847&view=rev
> Log:
> c-index-test: Fix libdeps corresponding to r260841.
> 
> Modified:
>cfe/trunk/tools/c-index-test/CMakeLists.txt
> 
> Modified: cfe/trunk/tools/c-index-test/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/CMakeLists.txt?rev=260847&r1=260846&r2=260847&view=diff
> ==
> --- cfe/trunk/tools/c-index-test/CMakeLists.txt (original)
> +++ cfe/trunk/tools/c-index-test/CMakeLists.txt Sun Feb 14 03:19:04 2016
> @@ -22,6 +22,9 @@ if (LLVM_BUILD_STATIC)
> else()
>   target_link_libraries(c-index-test
> libclang
> +clangAST
> +clangBasic
> +clangFrontend
> clangIndex
>   )
> endif()
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


r260856 - Fix some typos in the clang doc

2016-02-14 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Sun Feb 14 14:20:58 2016
New Revision: 260856

URL: http://llvm.org/viewvc/llvm-project?rev=260856&view=rev
Log:
Fix some typos in the clang doc

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/docs/CrossCompilation.rst
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/docs/SanitizerCoverage.rst

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=260856&r1=260855&r2=260856&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Sun Feb 14 14:20:58 2016
@@ -666,7 +666,7 @@ Adding additional style options
 ===
 
 Each additional style option adds costs to the clang-format project. Some of
-these costs affect the clang-format developement itself, as we need to make
+these costs affect the clang-format development itself, as we need to make
 sure that any given combination of options work and that new features don't
 break any of the existing options in any way. There are also costs for end 
users
 as options become less discoverable and people have to think about and make a

Modified: cfe/trunk/docs/CrossCompilation.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CrossCompilation.rst?rev=260856&r1=260855&r2=260856&view=diff
==
--- cfe/trunk/docs/CrossCompilation.rst (original)
+++ cfe/trunk/docs/CrossCompilation.rst Sun Feb 14 14:20:58 2016
@@ -32,7 +32,7 @@ when compiling your code.
 
 On the other hand, Clang/LLVM is natively a cross-compiler, meaning that
 one set of programs can compile to all targets by setting the ``-target``
-option. That makes it a lot easier for programers wishing to compile to
+option. That makes it a lot easier for programmers wishing to compile to
 different platforms and architectures, and for compiler developers that
 only have to maintain one build system, and for OS distributions, that
 need only one set of main packages.

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=260856&r1=260855&r2=260856&view=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Sun Feb 14 14:20:58 2016
@@ -1857,7 +1857,7 @@ in the `ARM C Language Extensions Releas
 
`_.
 Note that these intrinsics are implemented as motion barriers that block
 reordering of memory accesses and side effect instructions. Other instructions
-like simple arithmatic may be reordered around the intrinsic. If you expect to
+like simple arithmetic may be reordered around the intrinsic. If you expect to
 have no reordering at all, use inline assembly instead.
 
 X86/X86-64 Language Extensions

Modified: cfe/trunk/docs/SanitizerCoverage.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SanitizerCoverage.rst?rev=260856&r1=260855&r2=260856&view=diff
==
--- cfe/trunk/docs/SanitizerCoverage.rst (original)
+++ cfe/trunk/docs/SanitizerCoverage.rst Sun Feb 14 14:20:58 2016
@@ -110,8 +110,8 @@ Sancov matches these files using module
 
 Action (required)
   -print- Print coverage addresses
-  -covered-functions- Print all covered funcions.
-  -not-covered-functions- Print all not covered funcions.
+  -covered-functions- Print all covered functions.
+  -not-covered-functions- Print all not covered functions.
   -html-report  - Print HTML coverage report.
 
 Options


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


Re: [libcxx] r260514 - Teach __hash_table how to handle unordered_map's __hash_value_type.

2016-02-14 Thread Duncan P. N. Exon Smith via cfe-commits
(For anyone else trying to line up this commit message with the
patch: it looks like this message is a dup of r260513, and this
patch is one of its described follow-ups:

> On 2016-Feb-11, at 04:25, Eric Fiselier via cfe-commits 
>  wrote:
> 
> The following changes are planed for future revisions:
> 
>  * Fix LWG issue #2469 by delegating 'unordered_map::operator[]' to use
>'__emplace_unique_key_args'.

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


Re: r260496 - [Objective-c] Stop attaching section "datacoal_nt" to global variables.

2016-02-14 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2016-Feb-10, at 22:36, Akira Hatanaka via cfe-commits 
>  wrote:
> 
> Author: ahatanak
> Date: Thu Feb 11 00:36:35 2016
> New Revision: 260496
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=260496&view=rev
> Log:
> [Objective-c] Stop attaching section "datacoal_nt" to global variables.
> 
> The current macho linker just copies symbols in section datacoal_nt to
> section data, so it doesn't really matter whether or not section
> "datacoal_nt" is attached to the global variable.
> 
> This is a follow-up to r250370, which made changes in llvm to stop
> putting functions and data in the *coal* sections.
> 
> rdar://problem/24528611
> 
> Modified:
>cfe/trunk/lib/CodeGen/CGObjCMac.cpp
>cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
>cfe/trunk/test/CodeGenObjC/exceptions-asm-attribute.m
>cfe/trunk/test/CodeGenObjC/metadata-symbols-64.m
>cfe/trunk/test/CodeGenObjC/metadata_symbols.m
> 
> Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=260496&r1=260495&r2=260496&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Thu Feb 11 00:36:35 2016
> @@ -6409,7 +6409,7 @@ llvm::Constant *CGObjCNonFragileABIMac::
>   const ObjCProtocolDecl *PD) {
>   llvm::GlobalVariable *&Entry = Protocols[PD->getIdentifier()];
> 
> -  if (!Entry) {
> +  if (!Entry)
> // We use the initializer as a marker of whether this is a forward
> // reference or not. At module finalization we add the empty
> // contents for protocols which were referenced but never defined.
> @@ -6418,8 +6418,6 @@ llvm::Constant *CGObjCNonFragileABIMac::
>  false, llvm::GlobalValue::ExternalLinkage,
>  nullptr,
>  "\01l_OBJC_PROTOCOL_$_" + 
> PD->getObjCRuntimeNameAsString());
> -Entry->setSection("__DATA,__datacoal_nt,coalesced");
> -  }
> 
>   return Entry;
> }
> @@ -6546,7 +6544,6 @@ llvm::Constant *CGObjCNonFragileABIMac::
>"\01l_OBJC_PROTOCOL_$_" + 
> PD->getObjCRuntimeNameAsString());
> Entry->setAlignment(
>   CGM.getDataLayout().getABITypeAlignment(ObjCTypes.ProtocolnfABITy));
> -Entry->setSection("__DATA,__datacoal_nt,coalesced");
> 
> Protocols[PD->getIdentifier()] = Entry;
>   }
> @@ -7271,8 +7268,6 @@ CGObjCNonFragileABIMac::GetInterfaceEHTy
> 
>   if (ForDefinition)
> Entry->setSection("__DATA,__objc_const");
> -  else
> -Entry->setSection("__DATA,__datacoal_nt,coalesced");
> 
>   return Entry;
> }
> 
> Modified: cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp?rev=260496&r1=260495&r2=260496&view=diff
> ==
> --- cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp (original)
> +++ cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp Thu Feb 11 00:36:35 
> 2016
> @@ -6981,7 +6981,7 @@ void RewriteModernObjC::RewriteObjCProto
> Result += "static ";
>   Result += "struct _protocol_t _OBJC_PROTOCOL_";
>   Result += PDecl->getNameAsString();
> -  Result += " __attribute__ ((used, section 
> (\"__DATA,__datacoal_nt,coalesced\"))) = {\n";
> +  Result += " __attribute__ ((used)) = {\n";
>   Result += "\t0,\n"; // id is; is null
>   Result += "\t\""; Result += PDecl->getNameAsString(); Result += "\",\n";
>   if (SuperProtocols.size() > 0) {
> 
> Modified: cfe/trunk/test/CodeGenObjC/exceptions-asm-attribute.m
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/exceptions-asm-attribute.m?rev=260496&r1=260495&r2=260496&view=diff
> ==
> --- cfe/trunk/test/CodeGenObjC/exceptions-asm-attribute.m (original)
> +++ cfe/trunk/test/CodeGenObjC/exceptions-asm-attribute.m Thu Feb 11 00:36:35 
> 2016
> @@ -12,7 +12,7 @@
> // CHECK-X86_64: @"OBJC_CLASS_$_MySecretNamespace.A" = global {{.*}}, section 
> "__DATA, __objc_data", align 8
> // CHECK-X86_64: @"OBJC_METACLASS_$_MySecretNamespace.A" = global {{.*}}, 
> section "__DATA, __objc_data", align 8
> // CHECK-X86_64: @OBJC_CLASS_NAME_ = {{.*}}, section 
> "__TEXT,__objc_classname,cstring_literals", align 1
> -// CHECK-X86_64: @"OBJC_EHTYPE_$_MySecretNamespace.EH1" = weak global 
> {{.*}}, section "__DATA,__datacoal_nt,coalesced", align 8
> +// CHECK-X86_64: @"OBJC_EHTYPE_$_MySecretNamespace.EH1" = weak global 
> {{.*}}, align 8
> // CHECK-X86_64: @"OBJC_EHTYPE_$_MySecretNamespace.EH2" = external global
> // CHECK-X86_64: @"OBJC_EHTYPE_$_MySecretNamespace.EH3" = global {{.*}}, 
> section "__DATA,__objc_const", align 8
> // CHECK-X86_64: @"OBJC_LABEL_CLASS_$" = private global {{.*}}, section 
> "__DATA, __objc_classlist, regular, no_dead_strip",

Re: r260201 - [CMake] Providing a CMake cache for 3-stage builds

2016-02-14 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2016-Feb-08, at 22:01, Chris Bieneman via cfe-commits 
>  wrote:
> 
> Author: cbieneman
> Date: Tue Feb  9 00:01:47 2016
> New Revision: 260201
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=260201&view=rev
> Log:
> [CMake] Providing a CMake cache for 3-stage builds
> 
> This cache file can be used to generate a 3-stage clang build. You can 
> configure using the following CMake command:
> 
> cmake -C /cmake/caches/3-stage.cmake -G Ninja 
> 
> You can then run "ninja stage3-clang" to build stage1, stage2 and stage3 
> clangs.
> 
> This is useful for finding non-determinism the compiler by verifying that 
> stage2 and stage3 are identical.
> 
> Added:
>cfe/trunk/cmake/caches/3-stage.cmake

This is awesome to have!  Thanks for doing this.

> Added: cfe/trunk/cmake/caches/3-stage.cmake
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/3-stage.cmake?rev=260201&view=auto
> ==
> --- cfe/trunk/cmake/caches/3-stage.cmake (added)
> +++ cfe/trunk/cmake/caches/3-stage.cmake Tue Feb  9 00:01:47 2016
> @@ -0,0 +1,34 @@
> +set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
> +set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
> +set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
> +set(LLVM_TARGETS_TO_BUILD X86 CACHE STRING "")
> +set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
> +
> +set(CLANG_BOOTSTRAP_PASSTHROUGH 
> +  CLANG_ENABLE_BOOTSTRAP
> +  LLVM_BUILD_EXTERNAL_COMPILER_RT
> +  LLVM_TARGETS_TO_BUILD
> +  CLANG_BOOTSTRAP_PASSTHROUGH
> +  BOOTSTRAP_LLVM_ENABLE_LTO
> +  CMAKE_BUILD_TYPE
> +  CACHE STRING "")
> +
> +set(CLANG_BOOTSTRAP_TARGETS
> +  clang
> +  check-all
> +  check-llvm
> +  check-clang
> +  test-suite
> +  stage3
> +  stage3-clang
> +  stage3-check-all
> +  stage3-check-llvm
> +  stage3-check-clang
> +  stage3-test-suite CACHE STRING "")
> +
> +set(BOOTSTRAP_CLANG_BOOTSTRAP_TARGETS
> +  clang
> +  check-all
> +  check-llvm
> +  check-clang
> +  test-suite CACHE STRING "")
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


Re: [PATCH] D16264: For FreeBSD, use _p variants of libraries for linking C++ programs

2016-02-14 Thread Dimitry Andric via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL260851: As reported in 
https://llvm.org/bugs/show_bug.cgi?id=25496, on FreeBSD, (authored by dim).

Changed prior to commit:
  http://reviews.llvm.org/D16264?vs=47913&id=47930#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16264

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h
  cfe/trunk/test/Driver/freebsd.cpp

Index: cfe/trunk/test/Driver/freebsd.cpp
===
--- cfe/trunk/test/Driver/freebsd.cpp
+++ cfe/trunk/test/Driver/freebsd.cpp
@@ -2,5 +2,12 @@
 // RUN:   | FileCheck --check-prefix=CHECK-TEN %s
 // RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd9.2 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NINE %s
-// CHECK-TEN: -lc++
-// CHECK-NINE: -lstdc++
+// CHECK-TEN: "-lc++" "-lm"
+// CHECK-NINE: "-lstdc++" "-lm"
+
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd10.0 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG-TEN %s
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd9.2 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG-NINE %s
+// CHECK-PG-TEN: "-lc++_p" "-lm_p"
+// CHECK-PG-NINE: "-lstdc++_p" "-lm_p"
Index: cfe/trunk/lib/Driver/ToolChains.h
===
--- cfe/trunk/lib/Driver/ToolChains.h
+++ cfe/trunk/lib/Driver/ToolChains.h
@@ -728,6 +728,8 @@
   void AddClangCXXStdlibIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+   llvm::opt::ArgStringList &CmdArgs) const override;
 
   bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
   bool isPIEDefault() const override;
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -3128,6 +3128,22 @@
   }
 }
 
+void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args,
+  ArgStringList &CmdArgs) const {
+  CXXStdlibType Type = GetCXXStdlibType(Args);
+  bool Profiling = Args.hasArg(options::OPT_pg);
+
+  switch (Type) {
+  case ToolChain::CST_Libcxx:
+CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++");
+break;
+
+  case ToolChain::CST_Libstdcxx:
+CmdArgs.push_back(Profiling ? "-lstdc++_p" : "-lstdc++");
+break;
+  }
+}
+
 Tool *FreeBSD::buildAssembler() const {
   return new tools::freebsd::Assembler(*this);
 }


Index: cfe/trunk/test/Driver/freebsd.cpp
===
--- cfe/trunk/test/Driver/freebsd.cpp
+++ cfe/trunk/test/Driver/freebsd.cpp
@@ -2,5 +2,12 @@
 // RUN:   | FileCheck --check-prefix=CHECK-TEN %s
 // RUN: %clangxx %s -### -o %t.o -target amd64-unknown-freebsd9.2 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NINE %s
-// CHECK-TEN: -lc++
-// CHECK-NINE: -lstdc++
+// CHECK-TEN: "-lc++" "-lm"
+// CHECK-NINE: "-lstdc++" "-lm"
+
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd10.0 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG-TEN %s
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd9.2 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG-NINE %s
+// CHECK-PG-TEN: "-lc++_p" "-lm_p"
+// CHECK-PG-NINE: "-lstdc++_p" "-lm_p"
Index: cfe/trunk/lib/Driver/ToolChains.h
===
--- cfe/trunk/lib/Driver/ToolChains.h
+++ cfe/trunk/lib/Driver/ToolChains.h
@@ -728,6 +728,8 @@
   void AddClangCXXStdlibIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+   llvm::opt::ArgStringList &CmdArgs) const override;
 
   bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
   bool isPIEDefault() const override;
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -3128,6 +3128,22 @@
   }
 }
 
+void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args,
+  ArgStringList &CmdArgs) const {
+  CXXStdlibType Type = GetCXXStdlibType(Args);
+  bool Profiling = Args.hasArg(options::OPT_pg);
+
+  switch (Type) {
+  case ToolChain::CST_Libcxx:
+CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++");
+break;
+
+  case ToolChain::CST_Libstdcxx:
+CmdArgs.push_back(Profiling ? "-lstdc++_p" : "-lstdc++");
+break;
+  }
+}
+
 Tool *FreeBSD::buildAssembler() const {
   return new tools::freebsd::Assembler(*this);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin

r260858 - [index] Factor libclang's functionality to determing the mangled name of symbols into the clangIndex library.

2016-02-14 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Sun Feb 14 16:30:14 2016
New Revision: 260858

URL: http://llvm.org/viewvc/llvm-project?rev=260858&view=rev
Log:
[index] Factor libclang's functionality to determing the mangled name of 
symbols into the clangIndex library.

Added:
cfe/trunk/include/clang/Index/CodegenNameGenerator.h
cfe/trunk/lib/Index/CodegenNameGenerator.cpp
Modified:
cfe/trunk/include/clang/AST/Mangle.h
cfe/trunk/include/clang/Index/IndexDataConsumer.h
cfe/trunk/lib/AST/Mangle.cpp
cfe/trunk/lib/Index/CMakeLists.txt
cfe/trunk/lib/Index/IndexingAction.cpp
cfe/trunk/test/Index/Core/index-source.m
cfe/trunk/tools/c-index-test/core_main.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/Mangle.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Mangle.h?rev=260858&r1=260857&r2=260858&view=diff
==
--- cfe/trunk/include/clang/AST/Mangle.h (original)
+++ cfe/trunk/include/clang/AST/Mangle.h Sun Feb 14 16:30:14 2016
@@ -124,6 +124,7 @@ public:
   void mangleBlock(const DeclContext *DC, const BlockDecl *BD,
raw_ostream &Out);
 
+  void mangleObjCMethodNameWithoutSize(const ObjCMethodDecl *MD, raw_ostream 
&);
   void mangleObjCMethodName(const ObjCMethodDecl *MD, raw_ostream &);
 
   virtual void mangleStaticGuardVariable(const VarDecl *D, raw_ostream &) = 0;

Added: cfe/trunk/include/clang/Index/CodegenNameGenerator.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/CodegenNameGenerator.h?rev=260858&view=auto
==
--- cfe/trunk/include/clang/Index/CodegenNameGenerator.h (added)
+++ cfe/trunk/include/clang/Index/CodegenNameGenerator.h Sun Feb 14 16:30:14 
2016
@@ -0,0 +1,52 @@
+//===- CodegenNameGenerator.h - Codegen name generation 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Determines the name that the symbol will get for code generation.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_INDEX_CODEGENNAMEGENERATOR_H
+#define LLVM_CLANG_INDEX_CODEGENNAMEGENERATOR_H
+
+#include "clang/Basic/LLVM.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+  class ASTContext;
+  class Decl;
+
+namespace index {
+
+class CodegenNameGenerator {
+public:
+  explicit CodegenNameGenerator(ASTContext &Ctx);
+  ~CodegenNameGenerator();
+
+  /// \returns true on failure to produce a name for the given decl, false on
+  /// success.
+  bool writeName(const Decl *D, raw_ostream &OS);
+
+  /// Version of \c writeName function that returns a string.
+  std::string getName(const Decl *D);
+
+  /// This can return multiple mangled names when applicable, e.g. for C++
+  /// constructors/destructors.
+  std::vector getAllManglings(const Decl *D);
+
+private:
+  struct Implementation;
+  std::unique_ptr Impl;
+};
+
+} // namespace index
+} // namespace clang
+
+#endif // LLVM_CLANG_INDEX_CODEGENNAMEGENERATOR_H

Modified: cfe/trunk/include/clang/Index/IndexDataConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexDataConsumer.h?rev=260858&r1=260857&r2=260858&view=diff
==
--- cfe/trunk/include/clang/Index/IndexDataConsumer.h (original)
+++ cfe/trunk/include/clang/Index/IndexDataConsumer.h Sun Feb 14 16:30:14 2016
@@ -13,6 +13,7 @@
 #include "clang/Index/IndexSymbol.h"
 
 namespace clang {
+  class ASTContext;
   class DeclContext;
   class Expr;
   class FileID;
@@ -33,6 +34,8 @@ public:
 
   virtual ~IndexDataConsumer() {}
 
+  virtual void initialize(ASTContext &Ctx) {}
+
   /// \returns true to continue indexing, or false to abort.
   virtual bool handleDeclOccurence(const Decl *D, SymbolRoleSet Roles,
ArrayRef Relations,

Modified: cfe/trunk/lib/AST/Mangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Mangle.cpp?rev=260858&r1=260857&r2=260858&view=diff
==
--- cfe/trunk/lib/AST/Mangle.cpp (original)
+++ cfe/trunk/lib/AST/Mangle.cpp Sun Feb 14 16:30:14 2016
@@ -254,11 +254,8 @@ void MangleContext::mangleBlock(const De
   mangleFunctionBlock(*this, Buffer, BD, Out);
 }
 
-void MangleContext::mangleObjCMethodName(const ObjCMethodDecl *MD,
- raw_ostream &Out) {
-  SmallString<64> Name;
-  llvm::raw_svector_ostream OS(Name);
-  
+void MangleContext::mangleObjCMethodNameWithoutSize(const ObjCMethodDecl *MD,
+raw_ostream &OS) {
   const 

r260861 - [test/Index] Set a specific target for the test.

2016-02-14 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Sun Feb 14 16:38:38 2016
New Revision: 260861

URL: http://llvm.org/viewvc/llvm-project?rev=260861&view=rev
Log:
[test/Index] Set a specific target for the test.

Modified:
cfe/trunk/test/Index/Core/index-source.m

Modified: cfe/trunk/test/Index/Core/index-source.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=260861&r1=260860&r2=260861&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.m (original)
+++ cfe/trunk/test/Index/Core/index-source.m Sun Feb 14 16:38:38 2016
@@ -1,4 +1,4 @@
-// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+// RUN: c-index-test core -print-source-symbols -- %s -target 
x86_64-apple-macosx10.7 | FileCheck %s
 
 @interface Base
 // CHECK: [[@LINE-1]]:12 | objc-class/ObjC | Base | c:objc(cs)Base | 
_OBJC_CLASS_$_Base | Decl | rel: 0


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


[PATCH] D17248: [Sema] PR26444 fix crash when alignment value is <= 2**16

2016-02-14 Thread don hinton via cfe-commits
hintonda created this revision.
hintonda added a reviewer: majnemer.
hintonda added a subscriber: cfe-commits.

Sema allows max values up to 2**28, use unsigned instead of unsiged
short to hold values that large.

http://reviews.llvm.org/D17248

Files:
  lib/CodeGen/CGValue.h
  test/Sema/attr-aligned.c

Index: test/Sema/attr-aligned.c
===
--- test/Sema/attr-aligned.c
+++ test/Sema/attr-aligned.c
@@ -2,6 +2,7 @@
 
 int x __attribute__((aligned(3))); // expected-error {{requested alignment is 
not a power of 2}}
 int y __attribute__((aligned(1 << 29))); // expected-error {{requested 
alignment must be 268435456 bytes or smaller}}
+int y __attribute__((aligned(1 << 28)));
 
 // PR3254
 short g0[3] __attribute__((aligned));
Index: lib/CodeGen/CGValue.h
===
--- lib/CodeGen/CGValue.h
+++ lib/CodeGen/CGValue.h
@@ -445,7 +445,7 @@
   // Qualifiers
   Qualifiers Quals;
 
-  unsigned short Alignment;
+  unsigned Alignment;
 
   /// DestructedFlag - This is set to true if some external code is
   /// responsible for setting up a destructor for the slot.  Otherwise


Index: test/Sema/attr-aligned.c
===
--- test/Sema/attr-aligned.c
+++ test/Sema/attr-aligned.c
@@ -2,6 +2,7 @@
 
 int x __attribute__((aligned(3))); // expected-error {{requested alignment is not a power of 2}}
 int y __attribute__((aligned(1 << 29))); // expected-error {{requested alignment must be 268435456 bytes or smaller}}
+int y __attribute__((aligned(1 << 28)));
 
 // PR3254
 short g0[3] __attribute__((aligned));
Index: lib/CodeGen/CGValue.h
===
--- lib/CodeGen/CGValue.h
+++ lib/CodeGen/CGValue.h
@@ -445,7 +445,7 @@
   // Qualifiers
   Qualifiers Quals;
 
-  unsigned short Alignment;
+  unsigned Alignment;
 
   /// DestructedFlag - This is set to true if some external code is
   /// responsible for setting up a destructor for the slot.  Otherwise
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r260847 - c-index-test: Fix libdeps corresponding to r260841.

2016-02-14 Thread NAKAMURA Takumi via cfe-commits
BUILD_SHARED_LIBS requires them. Especially, Win32 DLL (PRIVATE) is most
strict.
CMake's transitive (PUBLIC/INTERFACE) libdeps sometimes misses incomplete
deps.

To make sure libdeps to be fine, I think we need to run a Win32 DLL builder.
It requires not msvc but cygming.
http://bb.pgr.jp/builders/i686-mingw32-RA-on-linux

Don't worry, I am watching it and can fix deps asap.

On Mon, Feb 15, 2016 at 2:21 AM Argyrios Kyrtzidis 
wrote:

> Which configuration required them ?
> I was under the impression CMake is passing the transitive libdeps.
>
> > On Feb 14, 2016, at 1:19 AM, NAKAMURA Takumi via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> > Author: chapuni
> > Date: Sun Feb 14 03:19:04 2016
> > New Revision: 260847
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=260847&view=rev
> > Log:
> > c-index-test: Fix libdeps corresponding to r260841.
> >
> > Modified:
> >cfe/trunk/tools/c-index-test/CMakeLists.txt
> >
> > Modified: cfe/trunk/tools/c-index-test/CMakeLists.txt
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/CMakeLists.txt?rev=260847&r1=260846&r2=260847&view=diff
> >
> ==
> > --- cfe/trunk/tools/c-index-test/CMakeLists.txt (original)
> > +++ cfe/trunk/tools/c-index-test/CMakeLists.txt Sun Feb 14 03:19:04 2016
> > @@ -22,6 +22,9 @@ if (LLVM_BUILD_STATIC)
> > else()
> >   target_link_libraries(c-index-test
> > libclang
> > +clangAST
> > +clangBasic
> > +clangFrontend
> > clangIndex
> >   )
> > endif()
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16360: unordered_map: Avoid unnecessary mallocs when no insert occurs

2016-02-14 Thread Duncan P. N. Exon Smith via cfe-commits
dexonsmith updated this revision to Diff 47936.
dexonsmith added a comment.

Updated the patch to apply against r260513.  The logic is much simpler now; 
thanks Eric for the cleanup.

Let me know if there's anything else to do!


http://reviews.llvm.org/D16360

Files:
  include/__hash_table
  test/libcxx/containers/unord/unord.map/insert_dup_alloc.pass.cpp

Index: test/libcxx/containers/unord/unord.map/insert_dup_alloc.pass.cpp
===
--- /dev/null
+++ test/libcxx/containers/unord/unord.map/insert_dup_alloc.pass.cpp
@@ -0,0 +1,88 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Check that we don't allocate when trying to insert a duplicate value into a
+// unordered_map.
+
+#include 
+#include 
+#include "count_new.hpp"
+#include "MoveOnly.h"
+
+int main() {
+  {
+std::unordered_map s;
+assert(globalMemCounter.checkNewCalledEq(0));
+
+for (int i = 0; i < 100; ++i) {
+  std::pair P(3, i);
+  s.insert(P);
+  s.insert(std::make_pair(3, i));
+  s.insert(std::make_pair(3, unsigned(i)));
+  s.insert(s.end(), std::make_pair(3, i));
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+  s.emplace(std::make_pair(3, i));
+  s.emplace_hint(s.end(), std::make_pair(3, i));
+#endif
+  {
+const std::pair P(3, i);
+s.insert(P);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+s.emplace(P);
+s.emplace_hint(s.end(), P);
+#endif
+  }
+}
+
+assert(s.size() == 1);
+assert(s.count(3) == 1);
+assert(s.at(3) == 0);
+assert(globalMemCounter.checkNewCalledEq(2));
+  }
+  assert(globalMemCounter.checkOutstandingNewEq(0));
+  globalMemCounter.reset();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+  {
+std::unordered_map s;
+assert(globalMemCounter.checkNewCalledEq(0));
+
+for (int i = 0; i < 100; i++) {
+  s.insert(std::make_pair(MoveOnly(3), MoveOnly(i)));
+  s.insert(s.end(), std::make_pair(MoveOnly(3), MoveOnly(i)));
+  s.emplace(std::make_pair(MoveOnly(3), MoveOnly(i)));
+  s.emplace_hint(s.end(), std::make_pair(MoveOnly(3), MoveOnly(i)));
+}
+
+assert(s.size() == 1);
+assert(s.count(MoveOnly(3)) == 1);
+assert(s.at(MoveOnly(3)) == 0);
+assert(globalMemCounter.checkNewCalledEq(2));
+  }
+  assert(globalMemCounter.checkOutstandingNewEq(0));
+  globalMemCounter.reset();
+  {
+std::unordered_map s;
+assert(globalMemCounter.checkNewCalledEq(0));
+
+for (int i = 0; i < 100; i++) {
+  s.insert(std::make_pair(3, MoveOnly(i)));
+  s.insert(s.end(), std::make_pair(3, MoveOnly(i)));
+  s.emplace(std::make_pair(3, MoveOnly(i)));
+  s.emplace_hint(s.end(), std::make_pair(3, MoveOnly(i)));
+}
+
+assert(s.size() == 1);
+assert(s.count(3) == 1);
+assert(s.at(3) == 0);
+assert(globalMemCounter.checkNewCalledEq(2));
+  }
+  assert(globalMemCounter.checkOutstandingNewEq(0));
+  globalMemCounter.reset();
+#endif
+}
Index: include/__hash_table
===
--- include/__hash_table
+++ include/__hash_table
@@ -100,6 +100,14 @@
 return size_t(1) << (std::numeric_limits::digits - __clz(__n-1));
 }
 
+template ::type>
+struct __is_pair_with_key : false_type {};
+
+template 
+struct __is_pair_with_key<_Pair, _Key, pair<_First, _Second>>
+: is_same::type, _Key> {};
+
 template  class __hash_table;
 
 template   class _LIBCPP_TYPE_VIS_ONLY __hash_iterator;
@@ -901,6 +909,7 @@
 
 typedef typename _NodeTypes::__node_value_type   __node_value_type;
 typedef typename _NodeTypes::__container_value_type  __container_value_type;
+typedef typename _NodeTypes::key_typekey_type;
 typedef value_type&  reference;
 typedef const value_type&const_reference;
 typedef typename __alloc_traits::pointer pointer;
@@ -1039,13 +1048,41 @@
 
 #ifndef _LIBCPP_CXX03_LANG
 template 
+_LIBCPP_INLINE_VISIBILITY
 pair __emplace_unique_key_args(_Key const& __k, _Args&&... __args);
 
 template 
-pair __emplace_unique(_Args&&... __args);
+_LIBCPP_INLINE_VISIBILITY
+pair __emplace_unique_impl(_Args&&... __args);
+
+template 
+_LIBCPP_INLINE_VISIBILITY
+pair __emplace_unique(_Pp&& __x) {
+  return __emplace_unique_extract_key(_VSTD::forward<_Pp>(__x),
+  __is_pair_with_key<_Pp, key_type>());
+}
 template 
+_LIBCPP_INLINE_VISIBILITY
+pair __emplace_unique(_Args&&... __args) {
+  return __emplace_unique_impl(_VSTD::forward<_Args>(__args)...);
+}
+
+te

r260865 - silence -Wreturn-type warnings

2016-02-14 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sun Feb 14 18:36:52 2016
New Revision: 260865

URL: http://llvm.org/viewvc/llvm-project?rev=260865&view=rev
Log:
silence -Wreturn-type warnings

These codepaths would generate warnings with GCC on linux even though the switch
was covered.  Add llvm_unreachable markers to indicate that the switch should be
covered.  NFC.

Modified:
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/lib/Index/IndexingContext.cpp
cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=260865&r1=260864&r2=260865&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Sun Feb 14 18:36:52 2016
@@ -266,6 +266,7 @@ StringRef index::getSymbolKindString(Sym
   case SymbolKind::CXXTypeAlias: return "type-alias";
   case SymbolKind::CXXInterface: return "c++-__interface";
   }
+  llvm_unreachable("invalid symbol kind");
 }
 
 StringRef index::getTemplateKindStr(SymbolCXXTemplateKind TK) {
@@ -275,6 +276,7 @@ StringRef index::getTemplateKindStr(Symb
   case SymbolCXXTemplateKind::TemplatePartialSpecialization : return "TPS";
   case SymbolCXXTemplateKind::TemplateSpecialization: return "TS";
   }
+  llvm_unreachable("invalid template kind");
 }
 
 StringRef index::getSymbolLanguageString(SymbolLanguage K) {
@@ -283,4 +285,5 @@ StringRef index::getSymbolLanguageString
   case SymbolLanguage::ObjC: return "ObjC";
   case SymbolLanguage::CXX: return "C++";
   }
+  llvm_unreachable("invalid symbol language kind");
 }

Modified: cfe/trunk/lib/Index/IndexingContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingContext.cpp?rev=260865&r1=260864&r2=260865&view=diff
==
--- cfe/trunk/lib/Index/IndexingContext.cpp (original)
+++ cfe/trunk/lib/Index/IndexingContext.cpp Sun Feb 14 18:36:52 2016
@@ -135,6 +135,7 @@ bool IndexingContext::isTemplateImplicit
 case TSK_ExplicitInstantiationDefinition:
   return true;
   }
+  llvm_unreachable("invalid TemplateSpecializationKind");
 }
 
 bool IndexingContext::shouldIgnoreIfImplicit(const Decl *D) {

Modified: cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp?rev=260865&r1=260864&r2=260865&view=diff
==
--- cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp (original)
+++ cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp Sun Feb 14 18:36:52 2016
@@ -1263,6 +1263,7 @@ static CXIdxEntityKind getEntityKindFrom
   case SymbolKind::CXXTypeAlias: return CXIdxEntity_CXXTypeAlias;
   case SymbolKind::CXXInterface: return CXIdxEntity_CXXInterface;
   }
+  llvm_unreachable("invalid symbol kind");
 }
 
 static CXIdxEntityCXXTemplateKind
@@ -1275,6 +1276,7 @@ getEntityKindFromSymbolCXXTemplateKind(S
   case SymbolCXXTemplateKind::TemplateSpecialization:
 return CXIdxEntity_TemplateSpecialization;
   }
+  llvm_unreachable("invalid template kind");
 }
 
 static CXIdxEntityLanguage getEntityLangFromSymbolLang(SymbolLanguage L) {
@@ -1283,4 +1285,5 @@ static CXIdxEntityLanguage getEntityLang
   case SymbolLanguage::ObjC: return CXIdxEntityLang_ObjC;
   case SymbolLanguage::CXX: return CXIdxEntityLang_CXX;
   }
+  llvm_unreachable("invalid symbol language");
 }


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


r260864 - Sema: constify EvalAddr, EvalVal

2016-02-14 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sun Feb 14 18:36:49 2016
New Revision: 260864

URL: http://llvm.org/viewvc/llvm-project?rev=260864&view=rev
Log:
Sema: constify EvalAddr, EvalVal

Propagate const throughout these methods as they are non-mutating analyzers of
state.  NFC.

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=260864&r1=260863&r2=260864&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Sun Feb 14 18:36:49 2016
@@ -5818,10 +5818,12 @@ void Sema::CheckStrncatArguments(const C
 
 //===--- CHECK: Return Address of Stack Variable 
--===//
 
-static Expr *EvalVal(Expr *E, SmallVectorImpl &refVars,
- Decl *ParentDecl);
-static Expr *EvalAddr(Expr* E, SmallVectorImpl &refVars,
-  Decl *ParentDecl);
+static const Expr *EvalVal(const Expr *E,
+   SmallVectorImpl &refVars,
+   const Decl *ParentDecl);
+static const Expr *EvalAddr(const Expr *E,
+SmallVectorImpl &refVars,
+const Decl *ParentDecl);
 
 /// CheckReturnStackAddr - Check if a return statement returns the address
 ///   of a stack variable.
@@ -5829,8 +5831,8 @@ static void
 CheckReturnStackAddr(Sema &S, Expr *RetValExp, QualType lhsType,
  SourceLocation ReturnLoc) {
 
-  Expr *stackE = nullptr;
-  SmallVector refVars;
+  const Expr *stackE = nullptr;
+  SmallVector refVars;
 
   // Perform checking for returned stack addresses, local blocks,
   // label addresses or references to temporaries.
@@ -5858,7 +5860,8 @@ CheckReturnStackAddr(Sema &S, Expr *RetV
 diagRange = refVars[0]->getSourceRange();
   }
 
-  if (DeclRefExpr *DR = dyn_cast(stackE)) { //address of local 
var.
+  if (const DeclRefExpr *DR = dyn_cast(stackE)) {
+// address of local var
 S.Diag(diagLoc, diag::warn_ret_stack_addr_ref) << 
lhsType->isReferenceType()
  << DR->getDecl()->getDeclName() << diagRange;
   } else if (isa(stackE)) { // local block.
@@ -5873,12 +5876,12 @@ CheckReturnStackAddr(Sema &S, Expr *RetV
   // Display the "trail" of reference variables that we followed until we
   // found the problematic expression using notes.
   for (unsigned i = 0, e = refVars.size(); i != e; ++i) {
-VarDecl *VD = cast(refVars[i]->getDecl());
+const VarDecl *VD = cast(refVars[i]->getDecl());
 // If this var binds to another reference var, show the range of the next
 // var, otherwise the var binds to the problematic expression, in which 
case
 // show the range of the expression.
-SourceRange range = (i < e-1) ? refVars[i+1]->getSourceRange()
-  : stackE->getSourceRange();
+SourceRange range = (i < e - 1) ? refVars[i + 1]->getSourceRange()
+: stackE->getSourceRange();
 S.Diag(VD->getLocation(), diag::note_ref_var_local_bind)
 << VD->getDeclName() << range;
   }
@@ -5910,8 +5913,9 @@ CheckReturnStackAddr(Sema &S, Expr *RetV
 ///   * arbitrary interplay between "&" and "*" operators
 ///   * pointer arithmetic from an address of a stack variable
 ///   * taking the address of an array element where the array is on the stack
-static Expr *EvalAddr(Expr *E, SmallVectorImpl &refVars,
-  Decl *ParentDecl) {
+static const Expr *EvalAddr(const Expr *E,
+SmallVectorImpl &refVars,
+const Decl *ParentDecl) {
   if (E->isTypeDependent())
 return nullptr;
 
@@ -5928,13 +5932,13 @@ static Expr *EvalAddr(Expr *E, SmallVect
   // EvalAddr and EvalVal appropriately.
   switch (E->getStmtClass()) {
   case Stmt::DeclRefExprClass: {
-DeclRefExpr *DR = cast(E);
+const DeclRefExpr *DR = cast(E);
 
 // If we leave the immediate function, the lifetime isn't about to end.
 if (DR->refersToEnclosingVariableOrCapture())
   return nullptr;
 
-if (VarDecl *V = dyn_cast(DR->getDecl()))
+if (const VarDecl *V = dyn_cast(DR->getDecl()))
   // If this is a reference variable, follow through to the expression that
   // it points to.
   if (V->hasLocalStorage() &&
@@ -5950,44 +5954,44 @@ static Expr *EvalAddr(Expr *E, SmallVect
   case Stmt::UnaryOperatorClass: {
 // The only unary operator that make sense to handle here
 // is AddrOf.  All others don't make sense as pointers.
-UnaryOperator *U = cast(E);
+const UnaryOperator *U = cast(E);
 
 if (U->getOpcode() == UO_AddrOf)
   return EvalVal(U->getSubExpr(), refVars, ParentDecl);
-else
-  return nullptr;
+return nullptr;
   }
 
   case Stmt::BinaryOperatorClass: {
 // Handle pointer arithmetic.  All other binary operators are not valid
 // in this contex

r260866 - [AST/index] Introduce an option 'SuppressTemplateArgsInCXXConstructors' in printing policy.

2016-02-14 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Sun Feb 14 19:32:36 2016
New Revision: 260866

URL: http://llvm.org/viewvc/llvm-project?rev=260866&view=rev
Log:
[AST/index] Introduce an option 'SuppressTemplateArgsInCXXConstructors' in 
printing policy.

Enable it for USRs and names when indexing.
Forward references can have different template argument names; including them
makes USRs and names unstable, since the name depends on whether we saw a 
forward reference or not.

Added:
cfe/trunk/test/Index/Core/index-source.cpp
Modified:
cfe/trunk/include/clang/AST/PrettyPrinter.h
cfe/trunk/include/clang/Index/IndexSymbol.h
cfe/trunk/lib/AST/DeclarationName.cpp
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/tools/c-index-test/core_main.cpp

Modified: cfe/trunk/include/clang/AST/PrettyPrinter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/PrettyPrinter.h?rev=260866&r1=260865&r2=260866&view=diff
==
--- cfe/trunk/include/clang/AST/PrettyPrinter.h (original)
+++ cfe/trunk/include/clang/AST/PrettyPrinter.h Sun Feb 14 19:32:36 2016
@@ -40,6 +40,7 @@ struct PrintingPolicy {
   SuppressUnwrittenScope(false), SuppressInitializers(false),
   ConstantArraySizeAsWritten(false), AnonymousTagLocations(true),
   SuppressStrongLifetime(false), SuppressLifetimeQualifiers(false),
+  SuppressTemplateArgsInCXXConstructors(false),
   Bool(LO.Bool), TerseOutput(false), PolishForDeclaration(false),
   Half(LO.Half), MSWChar(LO.MicrosoftExt && !LO.WChar),
   IncludeNewlines(true), MSVCFormatting(false) { }
@@ -136,7 +137,11 @@ struct PrintingPolicy {
   /// \brief When true, suppress printing of lifetime qualifier in
   /// ARC.
   unsigned SuppressLifetimeQualifiers : 1;
-  
+
+  /// When true, suppresses printing template arguments in names of C++
+  /// constructors.
+  unsigned SuppressTemplateArgsInCXXConstructors : 1;
+
   /// \brief Whether we can use 'bool' rather than '_Bool', even if the 
language
   /// doesn't actually have 'bool' (because, e.g., it is defined as a macro).
   unsigned Bool : 1;

Modified: cfe/trunk/include/clang/Index/IndexSymbol.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexSymbol.h?rev=260866&r1=260865&r2=260866&view=diff
==
--- cfe/trunk/include/clang/Index/IndexSymbol.h (original)
+++ cfe/trunk/include/clang/Index/IndexSymbol.h Sun Feb 14 19:32:36 2016
@@ -16,6 +16,7 @@
 
 namespace clang {
   class Decl;
+  class LangOptions;
 
 namespace index {
 
@@ -111,6 +112,10 @@ SymbolInfo getSymbolInfo(const Decl *D);
 void applyForEachSymbolRole(SymbolRoleSet Roles,
 llvm::function_ref Fn);
 void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS);
+
+/// \returns true if no name was printed, false otherwise.
+bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS);
+
 StringRef getSymbolKindString(SymbolKind K);
 StringRef getTemplateKindStr(SymbolCXXTemplateKind TK);
 StringRef getSymbolLanguageString(SymbolLanguage K);

Modified: cfe/trunk/lib/AST/DeclarationName.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclarationName.cpp?rev=260866&r1=260865&r2=260866&view=diff
==
--- cfe/trunk/lib/AST/DeclarationName.cpp (original)
+++ cfe/trunk/lib/AST/DeclarationName.cpp Sun Feb 14 19:32:36 2016
@@ -12,7 +12,7 @@
 //
 
//===--===//
 #include "clang/AST/ASTContext.h"
-#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/Type.h"
 #include "clang/AST/TypeLoc.h"
@@ -140,6 +140,12 @@ static void printCXXConstructorDestructo
 OS << *ClassRec->getDecl();
 return;
   }
+  if (Policy.SuppressTemplateArgsInCXXConstructors) {
+if (auto *InjTy = ClassType->getAs()) {
+  OS << *InjTy->getDecl();
+  return;
+}
+  }
   if (!Policy.LangOpts.CPlusPlus) {
 // Passed policy is the default one from operator <<, use a C++ policy.
 LangOptions LO;

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=260866&r1=260865&r2=260866&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Sun Feb 14 19:32:36 2016
@@ -11,6 +11,7 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/PrettyPrinter.h"
 
 using namespace clang;
 using namespace clang::index;
@@ -234,6 +235,24 @@ void index::printSymbolRoles(SymbolRoleS
   });
 }
 
+bool index::printSymbolName(const Decl *D, const LangOptions &LO,
+ 

r260867 - Sema: prevent assertion on stack return checking

2016-02-14 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sun Feb 14 19:51:24 2016
New Revision: 260867

URL: http://llvm.org/viewvc/llvm-project?rev=260867&view=rev
Log:
Sema: prevent assertion on stack return checking

In the case that the array indexing itself is within a type dependent context,
bail out of the evaluation.  We would previously try to symbolically evaluate
the expression which would then try to evaluate a non-address expression as an
address, triggering an assertion in Asserts builds.

We only need to consider the array subscript expression itself as in the case
that the base itself being type dependent is handled appropriately in EvalAddr.

Resolves PR26599.

Added:
cfe/trunk/test/SemaCXX/return-stack-addr-2.cpp
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=260867&r1=260866&r2=260867&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Sun Feb 14 19:51:24 2016
@@ -6144,8 +6144,10 @@ static const Expr *EvalVal(const Expr *E
   // Array subscripts are potential references to data on the stack.  We
   // retrieve the DeclRefExpr* for the array variable if it indeed
   // has local storage.
-  return EvalAddr(cast(E)->getBase(), refVars,
-  ParentDecl);
+  const auto *ASE = cast(E);
+  if (ASE->isTypeDependent())
+return nullptr;
+  return EvalAddr(ASE->getBase(), refVars, ParentDecl);
 }
 
 case Stmt::OMPArraySectionExprClass: {

Added: cfe/trunk/test/SemaCXX/return-stack-addr-2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/return-stack-addr-2.cpp?rev=260867&view=auto
==
--- cfe/trunk/test/SemaCXX/return-stack-addr-2.cpp (added)
+++ cfe/trunk/test/SemaCXX/return-stack-addr-2.cpp Sun Feb 14 19:51:24 2016
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -std=c++11 %s
+// expected-no-diagnostics
+
+namespace PR26599 {
+template 
+struct S;
+
+struct I {};
+
+template 
+void *&non_pointer() {
+  void *&r = S()[I{}];
+  return r;
+}
+
+template 
+void *&pointer() {
+  void *&r = S()[nullptr];
+  return r;
+}
+}
+


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


[clang-tools-extra] r260869 - Improve documentation

2016-02-14 Thread Felix Berger via cfe-commits
Author: flx
Date: Sun Feb 14 21:27:54 2016
New Revision: 260869

URL: http://llvm.org/viewvc/llvm-project?rev=260869&view=rev
Log:
Improve documentation

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/performance-for-range-copy.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/performance-for-range-copy.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/performance-for-range-copy.rst?rev=260869&r1=260868&r2=260869&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/performance-for-range-copy.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/performance-for-range-copy.rst 
Sun Feb 14 21:27:54 2016
@@ -10,8 +10,8 @@ The check is only applied to loop variab
 which means they are not trivially copyable or have a non-trivial copy
 constructor or destructor.
 
-To ensure that it is safe to replace the copy with const reference the 
following
-heuristic is employed:
+To ensure that it is safe to replace the copy with a const reference the
+following heuristic is employed:
 
 1. The loop variable is const qualified.
 2. The loop variable is not const, but only const methods or operators are


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


[clang-tools-extra] r260870 - [clang-tidy] Only invoke ForRangeCopyCheck on expensive-to-copy types.

2016-02-14 Thread Felix Berger via cfe-commits
Author: flx
Date: Sun Feb 14 21:36:23 2016
New Revision: 260870

URL: http://llvm.org/viewvc/llvm-project?rev=260870&view=rev
Log:
[clang-tidy] Only invoke ForRangeCopyCheck on expensive-to-copy types.

Summary:
Fix oversight not checking the value of the Optional returned by
isExpensiveToCopy().

Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D17064

Modified:
clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp?rev=260870&r1=260869&r2=260870&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp Sun 
Feb 14 21:36:23 2016
@@ -135,7 +135,9 @@ bool ForRangeCopyCheck::handleConstValue
   } else if (!LoopVar.getType().isConstQualified()) {
 return false;
   }
-  if (!type_traits::isExpensiveToCopy(LoopVar.getType(), Context))
+  llvm::Optional Expensive =
+  type_traits::isExpensiveToCopy(LoopVar.getType(), Context);
+  if (!Expensive || !*Expensive)
 return false;
   auto Diagnostic =
   diag(LoopVar.getLocation(),
@@ -150,8 +152,9 @@ bool ForRangeCopyCheck::handleConstValue
 bool ForRangeCopyCheck::handleCopyIsOnlyConstReferenced(
 const VarDecl &LoopVar, const CXXForRangeStmt &ForRange,
 ASTContext &Context) {
-  if (LoopVar.getType().isConstQualified() ||
-  !type_traits::isExpensiveToCopy(LoopVar.getType(), Context)) {
+  llvm::Optional Expensive =
+  type_traits::isExpensiveToCopy(LoopVar.getType(), Context);
+  if (LoopVar.getType().isConstQualified() || !Expensive || !*Expensive) {
 return false;
   }
   // Collect all DeclRefExprs to the loop variable and all CallExprs and

Modified: clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp?rev=260870&r1=260869&r2=260870&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp Sun 
Feb 14 21:36:23 2016
@@ -127,6 +127,7 @@ bool operator!=(const Mutable& M1, const
 }
 
 void use(const Mutable &M);
+void use(int I);
 void useTwice(const Mutable &M1, const Mutable &M2);
 void useByValue(Mutable M);
 void useByConstValue(const Mutable M);
@@ -170,6 +171,30 @@ void negativeNonConstNonMemberOperatorIn
   }
 }
 
+void negativeConstCheapToCopy() {
+  for (const int I : View>()) {
+  }
+}
+
+void negativeConstCheapToCopyTypedef() {
+  typedef const int ConstInt;
+  for (ConstInt C  : View>()) {
+  }
+}
+
+void negativeCheapToCopy() {
+  for (int I : View>()) {
+use(I);
+  }
+}
+
+void negativeCheapToCopyTypedef() {
+  typedef int Int;
+  for (Int I : View>()) {
+use(I);
+  }
+}
+
 void positiveOnlyConstMethodInvoked() {
   for (auto M : View>()) {
 // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but 
only used as const reference; consider making it a const reference 
[performance-for-range-copy]


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


Re: [PATCH] D17064: Only invoke ForRangeCopyCheck on expensive-to-copy types.

2016-02-14 Thread Felix Berger via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL260870: [clang-tidy] Only invoke ForRangeCopyCheck on 
expensive-to-copy types. (authored by flx).

Changed prior to commit:
  http://reviews.llvm.org/D17064?vs=47419&id=47940#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17064

Files:
  clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
@@ -127,6 +127,7 @@
 }
 
 void use(const Mutable &M);
+void use(int I);
 void useTwice(const Mutable &M1, const Mutable &M2);
 void useByValue(Mutable M);
 void useByConstValue(const Mutable M);
@@ -170,6 +171,30 @@
   }
 }
 
+void negativeConstCheapToCopy() {
+  for (const int I : View>()) {
+  }
+}
+
+void negativeConstCheapToCopyTypedef() {
+  typedef const int ConstInt;
+  for (ConstInt C  : View>()) {
+  }
+}
+
+void negativeCheapToCopy() {
+  for (int I : View>()) {
+use(I);
+  }
+}
+
+void negativeCheapToCopyTypedef() {
+  typedef int Int;
+  for (Int I : View>()) {
+use(I);
+  }
+}
+
 void positiveOnlyConstMethodInvoked() {
   for (auto M : View>()) {
 // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but 
only used as const reference; consider making it a const reference 
[performance-for-range-copy]
Index: clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
@@ -135,7 +135,9 @@
   } else if (!LoopVar.getType().isConstQualified()) {
 return false;
   }
-  if (!type_traits::isExpensiveToCopy(LoopVar.getType(), Context))
+  llvm::Optional Expensive =
+  type_traits::isExpensiveToCopy(LoopVar.getType(), Context);
+  if (!Expensive || !*Expensive)
 return false;
   auto Diagnostic =
   diag(LoopVar.getLocation(),
@@ -150,8 +152,9 @@
 bool ForRangeCopyCheck::handleCopyIsOnlyConstReferenced(
 const VarDecl &LoopVar, const CXXForRangeStmt &ForRange,
 ASTContext &Context) {
-  if (LoopVar.getType().isConstQualified() ||
-  !type_traits::isExpensiveToCopy(LoopVar.getType(), Context)) {
+  llvm::Optional Expensive =
+  type_traits::isExpensiveToCopy(LoopVar.getType(), Context);
+  if (LoopVar.getType().isConstQualified() || !Expensive || !*Expensive) {
 return false;
   }
   // Collect all DeclRefExprs to the loop variable and all CallExprs and


Index: clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
@@ -127,6 +127,7 @@
 }
 
 void use(const Mutable &M);
+void use(int I);
 void useTwice(const Mutable &M1, const Mutable &M2);
 void useByValue(Mutable M);
 void useByConstValue(const Mutable M);
@@ -170,6 +171,30 @@
   }
 }
 
+void negativeConstCheapToCopy() {
+  for (const int I : View>()) {
+  }
+}
+
+void negativeConstCheapToCopyTypedef() {
+  typedef const int ConstInt;
+  for (ConstInt C  : View>()) {
+  }
+}
+
+void negativeCheapToCopy() {
+  for (int I : View>()) {
+use(I);
+  }
+}
+
+void negativeCheapToCopyTypedef() {
+  typedef int Int;
+  for (Int I : View>()) {
+use(I);
+  }
+}
+
 void positiveOnlyConstMethodInvoked() {
   for (auto M : View>()) {
 // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]
Index: clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/performance/ForRangeCopyCheck.cpp
@@ -135,7 +135,9 @@
   } else if (!LoopVar.getType().isConstQualified()) {
 return false;
   }
-  if (!type_traits::isExpensiveToCopy(LoopVar.getType(), Context))
+  llvm::Optional Expensive =
+  type_traits::isExpensiveToCopy(LoopVar.getType(), Context);
+  if (!Expensive || !*Expensive)
 return false;
   auto Diagnostic =
   diag(LoopVar.getLocation(),
@@ -150,8 +152,9 @@
 bool ForRangeCopyCheck::handleCopyIsOnlyConstReferenced(
 const VarDecl &LoopVar, const CXXForRangeStmt &ForRange,
 ASTContext &Context) {
-  if (LoopVar.getType().isConstQualified() ||
-  !type_traits::isExpensiveToCopy(LoopVar.getType(), Context)) {
+  llvm::Optional Expensive =
+  type_traits::isExpen

r260872 - Add isAnyPointer() matchers. Register missing matchers.

2016-02-14 Thread Felix Berger via cfe-commits
Author: flx
Date: Sun Feb 14 22:00:39 2016
New Revision: 260872

URL: http://llvm.org/viewvc/llvm-project?rev=260872&view=rev
Log:
Add isAnyPointer() matchers. Register missing matchers.

Summary:
The isAnyPointer() matcher is useful for http://reviews.llvm.org/D15623.

Reviewers: alexfh, klimek

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D15819

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=260872&r1=260871&r2=260872&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Sun Feb 14 22:00:39 2016
@@ -3673,6 +3673,19 @@ AST_MATCHER(QualType, isAnyCharacter) {
 return Node->isAnyCharacterType();
 }
 
+ \brief Matches QualType nodes that are of any pointer type.
+///
+/// Given
+/// \code
+///   int *i = nullptr;
+///   int j;
+/// \endcode
+/// varDecl(hasType(isAnyPointer()))
+///   matches "int *i", but not "int j".
+AST_MATCHER(QualType, isAnyPointer) {
+  return Node->isAnyPointerType();
+}
+
 /// \brief Matches QualType nodes that are const-qualified, i.e., that
 /// include "top-level" const.
 ///

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=260872&r1=260871&r2=260872&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Sun Feb 14 22:00:39 2016
@@ -264,6 +264,8 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(innerType);
   REGISTER_MATCHER(integerLiteral);
   REGISTER_MATCHER(isAnonymous);
+  REGISTER_MATCHER(isAnyCharacter);
+  REGISTER_MATCHER(isAnyPointer);
   REGISTER_MATCHER(isArrow);
   REGISTER_MATCHER(isBaseInitializer);
   REGISTER_MATCHER(isCatchAll);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=260872&r1=260871&r2=260872&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Sun Feb 14 22:00:39 2016
@@ -1479,6 +1479,14 @@ TEST(IsInteger, ReportsNoFalsePositives)
   to(varDecl(hasType(isInteger();
 }
 
+TEST(IsAnyPointer, MatchesPointers) {
+  EXPECT_TRUE(matches("int* i = nullptr;", varDecl(hasType(isAnyPointer();
+}
+
+TEST(IsAnyPointer, ReportsNoFalsePositives) {
+  EXPECT_TRUE(notMatches("int i = 0;", varDecl(hasType(isAnyPointer();
+}
+
 TEST(IsAnyCharacter, MatchesCharacters) {
   EXPECT_TRUE(matches("char i = 0;", varDecl(hasType(isAnyCharacter();
 }


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


Re: [PATCH] D16517: ClangTidy check to flag uninitialized builtin and pointer fields.

2016-02-14 Thread Felix Berger via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL260873: [clang-tidy] ClangTidy check to flag uninitialized 
builtin and pointer fields. (authored by flx).

Changed prior to commit:
  http://reviews.llvm.org/D16517?vs=47757&id=47942#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16517

Files:
  clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
  
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
@@ -0,0 +1,67 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- -- -std=c++98
+
+struct PositiveFieldBeforeConstructor {
+  int F;
+  PositiveFieldBeforeConstructor() /* some comment */ {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F
+  // CHECK-FIXES: PositiveFieldBeforeConstructor() : F() /* some comment */ {}
+};
+
+struct PositiveFieldAfterConstructor {
+  PositiveFieldAfterConstructor() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F, G, H
+  // CHECK-FIXES: PositiveFieldAfterConstructor() : F(), G(), H() {}
+  int F;
+  bool G /* with comment */;
+  int *H;
+  PositiveFieldBeforeConstructor IgnoredField;
+};
+
+struct PositiveSeparateDefinition {
+  PositiveSeparateDefinition();
+  int F;
+};
+
+PositiveSeparateDefinition::PositiveSeparateDefinition() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these built-in/pointer fields: F
+// CHECK-FIXES: PositiveSeparateDefinition::PositiveSeparateDefinition() : F() {}
+
+struct PositiveMixedFieldOrder {
+  PositiveMixedFieldOrder() : /* some comment */ J(0), L(0), M(0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: I, K, N
+  // CHECK-FIXES: PositiveMixedFieldOrder() : I(), /* some comment */ J(0), K(), L(0), M(0), N() {}
+  int I;
+  int J;
+  int K;
+  int L;
+  int M;
+  int N;
+};
+
+struct PositiveAfterBaseInitializer : public PositiveMixedFieldOrder {
+  PositiveAfterBaseInitializer() : PositiveMixedFieldOrder() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F
+  // CHECK-FIXES: PositiveAfterBaseInitializer() : PositiveMixedFieldOrder(), F() {}
+  int F;
+};
+
+struct NegativeFieldInitialized {
+  int F;
+
+  NegativeFieldInitialized() : F() {}
+};
+
+struct NegativeFieldInitializedInDefinition {
+  int F;
+
+  NegativeFieldInitializedInDefinition();
+};
+
+NegativeFieldInitializedInDefinition::NegativeFieldInitializedInDefinition() : F() {}
+
+struct NegativeInitializedInBody {
+  NegativeInitializedInBody() { I = 0; }
+  int I;
+};
+
+
Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -0,0 +1,111 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t
+
+struct PositiveFieldBeforeConstructor {
+  int F;
+  // CHECK-FIXES: int F{};
+  PositiveFieldBeforeConstructor() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F
+  // CHECK-FIXES: PositiveFieldBeforeConstructor() {}
+};
+
+struct PositiveFieldAfterConstructor {
+  PositiveFieldAfterConstructor() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F, G
+  // CHECK-FIXES: PositiveFieldAfterConstructor() {}
+  int F;
+  // CHECK-FIXES: int F{};
+  bool G /* with comment */;
+  // CHECK-FIXES: bool G{} /* with comment */;
+  PositiveFieldBeforeConstructor IgnoredField;
+};
+
+struct PositiveSeparateDefinition {
+  PositiveSeparateDefinition();
+  int F;
+  // CHECK-FIXES: int F{};
+};
+
+PositiveSeparateDefinition::PositiveSeparateDefinition() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these built-in/po

r260874 - clangIndex requires LLVMIR as Core, since r260858 uses llvm/IR.

2016-02-14 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Sun Feb 14 22:29:36 2016
New Revision: 260874

URL: http://llvm.org/viewvc/llvm-project?rev=260874&view=rev
Log:
clangIndex requires LLVMIR as Core, since r260858 uses llvm/IR.

Modified:
cfe/trunk/lib/Index/CMakeLists.txt

Modified: cfe/trunk/lib/Index/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/CMakeLists.txt?rev=260874&r1=260873&r2=260874&view=diff
==
--- cfe/trunk/lib/Index/CMakeLists.txt (original)
+++ cfe/trunk/lib/Index/CMakeLists.txt Sun Feb 14 22:29:36 2016
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  Core
   Support
   )
 


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


[clang-tools-extra] r260873 - [clang-tidy] ClangTidy check to flag uninitialized builtin and pointer fields.

2016-02-14 Thread Felix Berger via cfe-commits
Author: flx
Date: Sun Feb 14 22:27:56 2016
New Revision: 260873

URL: http://llvm.org/viewvc/llvm-project?rev=260873&view=rev
Log:
[clang-tidy] ClangTidy check to flag uninitialized builtin and pointer fields.

Summary:
This patch is a continuation of http://reviews.llvm.org/D10553 by Jonathan B 
Coe.

The main additions are:

1. For C++11 the check suggests in-class field initialization as fix. This
makes the fields future proof towards the addition of new constructors.
2 For older language versions the fields are added in the right position
in the initializer list with more tests.
3. User documentation.

Reviewers: alexfh, jbcoe

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D16517

Added:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt?rev=260873&r1=260872&r2=260873&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt Sun Feb 
14 22:27:56 2016
@@ -7,6 +7,7 @@ add_clang_library(clangTidyCppCoreGuidel
   ProBoundsPointerArithmeticCheck.cpp
   ProTypeConstCastCheck.cpp
   ProTypeCstyleCastCheck.cpp
+  ProTypeMemberInitCheck.cpp
   ProTypeReinterpretCastCheck.cpp
   ProTypeStaticCastDowncastCheck.cpp
   ProTypeUnionAccessCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=260873&r1=260872&r2=260873&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 Sun Feb 14 22:27:56 2016
@@ -16,6 +16,7 @@
 #include "ProBoundsPointerArithmeticCheck.h"
 #include "ProTypeConstCastCheck.h"
 #include "ProTypeCstyleCastCheck.h"
+#include "ProTypeMemberInitCheck.h"
 #include "ProTypeReinterpretCastCheck.h"
 #include "ProTypeStaticCastDowncastCheck.h"
 #include "ProTypeUnionAccessCheck.h"
@@ -39,6 +40,8 @@ public:
 "cppcoreguidelines-pro-type-const-cast");
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-type-cstyle-cast");
+CheckFactories.registerCheck(
+"cppcoreguidelines-pro-type-member-init");
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-type-reinterpret-cast");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp?rev=260873&view=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
(added)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
Sun Feb 14 22:27:56 2016
@@ -0,0 +1,231 @@
+//===--- ProTypeMemberInitCheck.cpp - 
clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ProTypeMemberInitCheck.h"
+#include "../utils/LexerUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+using namespace clang::ast_matchers;
+using llvm::SmallPtrSet;
+using llvm::SmallPtrSetImpl;
+
+namespace clang {
+namespace tidy {
+namespace cppcoreguidelines {
+
+namespace {
+
+AST_MATCHER(CXXConstructorDecl, isUserProvided) {
+  return Node.isUserProvided();
+}
+
+static void
+fieldsRequiringInit(const RecordDecl::field_range &Fields,
+SmallPtrSetImpl &FieldsToInit) {
+  for (const FieldDecl *F : Fields) {
+QualType Type = F->getType()