r307468 - [analyzer] Fix a path in the developer manual

2017-07-08 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Sat Jul  8 01:23:52 2017
New Revision: 307468

URL: http://llvm.org/viewvc/llvm-project?rev=307468&view=rev
Log:
[analyzer] Fix a path in the developer manual

Patch by: Reka Nikolett Kovacs

Modified:
cfe/trunk/www/analyzer/checker_dev_manual.html

Modified: cfe/trunk/www/analyzer/checker_dev_manual.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/checker_dev_manual.html?rev=307468&r1=307467&r2=307468&view=diff
==
--- cfe/trunk/www/analyzer/checker_dev_manual.html (original)
+++ cfe/trunk/www/analyzer/checker_dev_manual.html Sat Jul  8 01:23:52 2017
@@ -279,8 +279,8 @@ void ento::registerSimpleStreamChecker(C
 }
 
 A package was selected for the checker and the checker was defined in the
-table of checkers at lib/StaticAnalyzer/Checkers/Checkers.td. Since 
all
-checkers should first be developed as "alpha", and the SimpleStreamChecker
+table of checkers at 
include/clang/StaticAnalyzer/Checkers/Checkers.td.
+Since all checkers should first be developed as "alpha", and the 
SimpleStreamChecker
 performs UNIX API checks, the correct package is "alpha.unix", and the 
following
 was added to the corresponding UnixAlpha section of 
Checkers.td:
 


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


r307470 - CodeGen: Fix address space of global variable

2017-07-08 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Sat Jul  8 06:24:52 2017
New Revision: 307470

URL: http://llvm.org/viewvc/llvm-project?rev=307470&view=rev
Log:
CodeGen: Fix address space of global variable

Certain targets (e.g. amdgcn) require global variable to stay in global or 
constant address
space. In C or C++ global variables are emitted in the default (generic) 
address space.
This patch introduces virtual functions 
TargetCodeGenInfo::getGlobalVarAddressSpace
and TargetInfo::getConstantAddressSpace to handle this in a general approach.

It only affects IR generated for amdgcn target.

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

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/CodeGen/TargetInfo.h
cfe/trunk/test/CodeGen/address-space.c
cfe/trunk/test/CodeGen/default-address-space.c
cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=307470&r1=307469&r2=307470&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Sat Jul  8 06:24:52 2017
@@ -23,6 +23,7 @@
 #include "clang/Basic/VersionTuple.h"
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
@@ -954,6 +955,14 @@ public:
 return *AddrSpaceMap;
   }
 
+  /// \brief Return an AST address space which can be used opportunistically
+  /// for constant global memory. It must be possible to convert pointers into
+  /// this address space to LangAS::Default. If no such address space exists,
+  /// this may return None, and such optimizations will be disabled.
+  virtual llvm::Optional getConstantAddressSpace() const {
+return LangAS::Default;
+  }
+
   /// \brief Retrieve the name of the platform as it is used in the
   /// availability attribute.
   StringRef getPlatformName() const { return PlatformName; }

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=307470&r1=307469&r2=307470&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Sat Jul  8 06:24:52 2017
@@ -2404,6 +2404,10 @@ public:
 return LangAS::opencl_constant;
   }
 
+  llvm::Optional getConstantAddressSpace() const override {
+return LangAS::FirstTargetAddressSpace + AS.Constant;
+  }
+
   /// \returns Target specific vtbl ptr address space.
   unsigned getVtblPtrAddressSpace() const override { return AS.Constant; }
 

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=307470&r1=307469&r2=307470&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Sat Jul  8 06:24:52 2017
@@ -736,9 +736,9 @@ llvm::Value *CodeGenFunction::EmitBlockL
   llvm::Constant *isa =
   (!CGM.getContext().getLangOpts().OpenCL)
   ? CGM.getNSConcreteStackBlock()
-  : CGM.getNullPointer(cast(
-   CGM.getNSConcreteStackBlock()->getType()),
-   QualType(getContext().VoidPtrTy));
+  : CGM.getNullPointer(VoidPtrPtrTy,
+   CGM.getContext().getPointerType(
+   QualType(CGM.getContext().VoidPtrTy)));
   isa = llvm::ConstantExpr::getBitCast(isa, VoidPtrTy);
 
   // Build the block descriptor.
@@ -1141,12 +1141,11 @@ static llvm::Constant *buildGlobalBlock(
   auto fields = builder.beginStruct();
 
   // isa
-  fields.add(
-  (!CGM.getContext().getLangOpts().OpenCL)
-  ? CGM.getNSConcreteGlobalBlock()
-  : CGM.getNullPointer(cast(
-   CGM.getNSConcreteGlobalBlock()->getType()),
-   QualType(CGM.getContext().VoidPtrTy)));
+  fields.add((!CGM.getContext().getLangOpts().OpenCL)
+ ? CGM.getNSConcreteGlobalBlock()
+ : CGM.getNullPointer(CGM.VoidPtrPtrTy,
+  CGM.getContext().getPointerType(QualType(
+  CGM.getContext().VoidPtrTy;
 
   // __flags
   BlockFlags flags = BLOCK_IS_GLOBAL | BLOCK_HAS_SIGNATURE;

Modified: cfe/trunk/l

r307472 - [CodeGen] Fold variable into assert.

2017-07-08 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sat Jul  8 07:14:57 2017
New Revision: 307472

URL: http://llvm.org/viewvc/llvm-project?rev=307472&view=rev
Log:
[CodeGen] Fold variable into assert.

Avoids warnings in Release builds.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=307472&r1=307471&r2=307472&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sat Jul  8 07:14:57 2017
@@ -2433,8 +2433,8 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
   auto ExpectedAS =
   D ? D->getType().getAddressSpace()
 : (LangOpts.OpenCL ? LangAS::opencl_global : LangAS::Default);
-  auto ExpectedTargetAS = getContext().getTargetAddressSpace(ExpectedAS);
-  assert(ExpectedTargetAS == Ty->getPointerAddressSpace());
+  assert(getContext().getTargetAddressSpace(ExpectedAS) ==
+ Ty->getPointerAddressSpace());
   if (AddrSpace != ExpectedAS)
 return getTargetCodeGenInfo().performAddrSpaceCast(*this, GV, AddrSpace,
ExpectedAS, Ty);


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


r307478 - [Bash-autocompletion] Fix a bug that -foo=bar doesn't handled properly

2017-07-08 Thread Yuka Takahashi via cfe-commits
Author: yamaguchi
Date: Sat Jul  8 10:34:02 2017
New Revision: 307478

URL: http://llvm.org/viewvc/llvm-project?rev=307478&view=rev
Log:
[Bash-autocompletion] Fix a bug that -foo=bar doesn't handled properly

Summary: Fixed a bug that -foo=bar wasn't handled properly on old version of 
bash.

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

Modified:
cfe/trunk/utils/bash-autocomplete.sh

Modified: cfe/trunk/utils/bash-autocomplete.sh
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=307478&r1=307477&r2=307478&view=diff
==
--- cfe/trunk/utils/bash-autocomplete.sh (original)
+++ cfe/trunk/utils/bash-autocomplete.sh Sat Jul  8 10:34:02 2017
@@ -34,12 +34,18 @@ _clang()
   elif [[ "$w1" == -*  && "$cur" == '=' ]]; then
 # -foo=
 arg="$w1=,"
+  elif [[ "$cur" == -*= ]]; then
+# -foo=
+arg="$cur,"
   elif [[ "$w1" == -* ]]; then
 # -foo  or -foo bar
 arg="$w1,$cur"
   elif [[ "$w2" == -* && "$w1" == '=' ]]; then
 # -foo=bar
 arg="$w2=,$cur"
+  elif [[ ${cur: -1} != '=' && ${cur/=} != $cur ]]; then
+# -foo=bar
+arg="${cur%=*}=,${cur#*=}"
   fi
 
   # expand ~ to $HOME


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


r307479 - [Bash-autocompletion] Auto complete cc1 options if -cc1 is specified

2017-07-08 Thread Yuka Takahashi via cfe-commits
Author: yamaguchi
Date: Sat Jul  8 10:48:59 2017
New Revision: 307479

URL: http://llvm.org/viewvc/llvm-project?rev=307479&view=rev
Log:
[Bash-autocompletion] Auto complete cc1 options if -cc1 is specified

Summary:
We don't want to autocomplete flags whose Flags class has `NoDriverOption` when 
argv[1] is not `-cc1`.

Another idea for this implementation is to make --autocomplete a cc1
option and handle it in clang Frontend, by porting --autocomplete
handler from Driver to Frontend, so that we can handle Driver options
and CC1 options in unified manner.

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

Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/autocomplete.c
cfe/trunk/utils/bash-autocomplete.sh

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=307479&r1=307478&r2=307479&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Sat Jul  8 10:48:59 2017
@@ -1261,11 +1261,20 @@ bool Driver::HandleImmediateArgs(const C
 StringRef PassedFlags = A->getValue();
 std::vector SuggestedCompletions;
 
+unsigned short DisableFlags = options::NoDriverOption | 
options::Unsupported | options::Ignored;
+// We want to show cc1-only options only when clang is invoked as "clang 
-cc1".
+// When clang is invoked as "clang -cc1", we add "#" to the beginning of 
an --autocomplete
+// option so that the clang driver can distinguish whether it is requested 
to show cc1-only options or not.
+if (PassedFlags[0] == '#') {
+  DisableFlags &= ~options::NoDriverOption;
+  PassedFlags = PassedFlags.substr(1);
+}
+
 if (PassedFlags.find(',') == StringRef::npos) {
   // If the flag is in the form of "--autocomplete=-foo",
   // we were requested to print out all option names that start with 
"-foo".
   // For example, "--autocomplete=-fsyn" is expanded to "-fsyntax-only".
-  SuggestedCompletions = Opts->findByPrefix(PassedFlags);
+  SuggestedCompletions = Opts->findByPrefix(PassedFlags, DisableFlags);
 } else {
   // If the flag is in the form of "--autocomplete=foo,bar", we were
   // requested to print out all option values for "-foo" that start with

Modified: cfe/trunk/test/Driver/autocomplete.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=307479&r1=307478&r2=307479&view=diff
==
--- cfe/trunk/test/Driver/autocomplete.c (original)
+++ cfe/trunk/test/Driver/autocomplete.c Sat Jul  8 10:48:59 2017
@@ -36,3 +36,7 @@
 // MTHREADMODELALL: posix single
 // RUN: %clang --autocomplete=-mrelocation-model, | FileCheck %s 
-check-prefix=MRELOCMODELALL
 // MRELOCMODELALL: dynamic-no-pic pic ropi ropi-rwpi rwpi static
+// RUN: %clang --autocomplete=-mrelocation-mode | FileCheck %s 
-check-prefix=MRELOCMODEL_CLANG
+// MRELOCMODEL_CLANG-NOT: -mrelocation-model
+// RUN: %clang --autocomplete=#-mrelocation-mode | FileCheck %s 
-check-prefix=MRELOCMODEL_CC1
+// MRELOCMODEL_CC1: -mrelocation-model

Modified: cfe/trunk/utils/bash-autocomplete.sh
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=307479&r1=307478&r2=307479&view=diff
==
--- cfe/trunk/utils/bash-autocomplete.sh (original)
+++ cfe/trunk/utils/bash-autocomplete.sh Sat Jul  8 10:48:59 2017
@@ -27,25 +27,29 @@ _clang()
   w1="${COMP_WORDS[$cword - 1]}"
   if [[ $cword > 1 ]]; then
 w2="${COMP_WORDS[$cword - 2]}"
+  # Clang want to know if -cc1 or -Xclang option is specified or not, because 
we don't want to show
+  # cc1 options otherwise.
+  if [[ "${COMP_WORDS[1]}" == "-cc1" || "$w1" == "-Xclang" ]]; then
+arg="#"
   fi
   if [[ "$cur" == -* ]]; then
 # -foo
-arg="$cur"
+arg="$arg$cur"
   elif [[ "$w1" == -*  && "$cur" == '=' ]]; then
 # -foo=
-arg="$w1=,"
+arg="$arg$w1=,"
   elif [[ "$cur" == -*= ]]; then
 # -foo=
-arg="$cur,"
+arg="$arg$cur,"
   elif [[ "$w1" == -* ]]; then
 # -foo  or -foo bar
-arg="$w1,$cur"
+arg="$arg$w1,$cur"
   elif [[ "$w2" == -* && "$w1" == '=' ]]; then
 # -foo=bar
-arg="$w2=,$cur"
+arg="$arg$w2=,$cur"
   elif [[ ${cur: -1} != '=' && ${cur/=} != $cur ]]; then
 # -foo=bar
-arg="${cur%=*}=,${cur#*=}"
+arg="$arg${cur%=*}=,${cur#*=}"
   fi
 
   # expand ~ to $HOME


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


Re: [clang-tools-extra] r304583 - [clang-tidy] Add `const` to operator() to fix a warning.

2017-07-08 Thread Kim Gräsman via cfe-commits
This is even an error in VS2017, I've just fixed a number of instances of
this in an internal codebase.

- Kim

Den 6 juni 2017 4:32 em skrev "Alexander Kornienko via cfe-commits" <
cfe-commits@lists.llvm.org>:

> On Mon, Jun 5, 2017 at 7:11 PM, David Blaikie  wrote:
>
>> what was the warning?
>>
>
> I don't remember the exact warning text, but the idea was that a non-const
> operator() could not be called. The change is reasonable in any case: the
> operator() here has no reason to be non-const.
>
>
>>
>> On Fri, Jun 2, 2017 at 11:48 AM Alexander Kornienko via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: alexfh
>>> Date: Fri Jun  2 13:47:50 2017
>>> New Revision: 304583
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=304583&view=rev
>>> Log:
>>> [clang-tidy] Add `const` to operator() to fix a warning.
>>>
>>> Modified:
>>> clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h
>>>
>>> Modified: clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCh
>>> eck.h
>>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>>> clang-tidy/misc/LambdaFunctionNameCheck.h?rev=304583&r1=
>>> 304582&r2=304583&view=diff
>>> 
>>> ==
>>> --- clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h
>>> (original)
>>> +++ clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h
>>> Fri Jun  2 13:47:50 2017
>>> @@ -25,7 +25,7 @@ namespace misc {
>>>  class LambdaFunctionNameCheck : public ClangTidyCheck {
>>>  public:
>>>struct SourceRangeLessThan {
>>> -bool operator()(const SourceRange &L, const SourceRange &R) {
>>> +bool operator()(const SourceRange &L, const SourceRange &R) const {
>>>if (L.getBegin() == R.getBegin()) {
>>>  return L.getEnd() < R.getEnd();
>>>}
>>>
>>>
>>> ___
>>> 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
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r307481 - [Demangler] NFC: Move Db struct to beginning of file

2017-07-08 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Sat Jul  8 11:54:07 2017
New Revision: 307481

URL: http://llvm.org/viewvc/llvm-project?rev=307481&view=rev
Log:
[Demangler] NFC: Move Db struct to beginning of file

Differential revision: https://reviews.llvm.org/D35158

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=307481&r1=307480&r2=307481&view=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Sat Jul  8 11:54:07 2017
@@ -58,6 +58,212 @@ template 
 const char* parse_unqualified_name(const char* first, const char* last, C& 
db);
 template 
 const char* parse_decltype(const char* first, const char* last, C& db);
+template 
+class arena
+{
+static const std::size_t alignment = 16;
+alignas(alignment) char buf_[N];
+char* ptr_;
+
+std::size_t 
+align_up(std::size_t n) noexcept
+{return (n + (alignment-1)) & ~(alignment-1);}
+
+bool
+pointer_in_buffer(char* p) noexcept
+{return buf_ <= p && p <= buf_ + N;}
+
+public:
+arena() noexcept : ptr_(buf_) {}
+~arena() {ptr_ = nullptr;}
+arena(const arena&) = delete;
+arena& operator=(const arena&) = delete;
+
+char* allocate(std::size_t n);
+void deallocate(char* p, std::size_t n) noexcept;
+
+static constexpr std::size_t size() {return N;}
+std::size_t used() const {return static_cast(ptr_ - buf_);}
+void reset() {ptr_ = buf_;}
+};
+
+template 
+char*
+arena::allocate(std::size_t n)
+{
+n = align_up(n);
+if (static_cast(buf_ + N - ptr_) >= n)
+{
+char* r = ptr_;
+ptr_ += n;
+return r;
+}
+return static_cast(std::malloc(n));
+}
+
+template 
+void
+arena::deallocate(char* p, std::size_t n) noexcept
+{
+if (pointer_in_buffer(p))
+{
+n = align_up(n);
+if (p + n == ptr_)
+ptr_ = p;
+}
+else
+std::free(p);
+}
+
+template 
+class short_alloc
+{
+arena& a_;
+public:
+typedef T value_type;
+
+public:
+template  struct rebind {typedef short_alloc<_Up, N> other;};
+
+short_alloc(arena& a) noexcept : a_(a) {}
+template 
+short_alloc(const short_alloc& a) noexcept
+: a_(a.a_) {}
+short_alloc(const short_alloc&) = default;
+short_alloc& operator=(const short_alloc&) = delete;
+
+T* allocate(std::size_t n)
+{
+return reinterpret_cast(a_.allocate(n*sizeof(T)));
+}
+void deallocate(T* p, std::size_t n) noexcept
+{
+a_.deallocate(reinterpret_cast(p), n*sizeof(T));
+}
+
+template 
+friend
+bool
+operator==(const short_alloc& x, const short_alloc& y) 
noexcept;
+
+template  friend class short_alloc;
+};
+
+template 
+inline
+bool
+operator==(const short_alloc& x, const short_alloc& y) noexcept
+{
+return N == M && &x.a_ == &y.a_;
+}
+
+template 
+inline
+bool
+operator!=(const short_alloc& x, const short_alloc& y) noexcept
+{
+return !(x == y);
+}
+
+template 
+class malloc_alloc
+{
+public:
+typedef T value_type;
+typedef T& reference;
+typedef const T& const_reference;
+typedef T* pointer;
+typedef const T* const_pointer;
+typedef std::size_t size_type;
+typedef std::ptrdiff_t difference_type;
+
+malloc_alloc() = default;
+template  malloc_alloc(const malloc_alloc&) noexcept {}
+
+T* allocate(std::size_t n)
+{
+return static_cast(std::malloc(n*sizeof(T)));
+}
+void deallocate(T* p, std::size_t) noexcept
+{
+std::free(p);
+}
+
+template  struct rebind { using other = malloc_alloc; };
+template 
+void construct(U* p, Args&&... args)
+{
+::new ((void*)p) U(std::forward(args)...);
+}
+void destroy(T* p)
+{
+p->~T();
+}
+};
+
+template 
+inline
+bool
+operator==(const malloc_alloc&, const malloc_alloc&) noexcept
+{
+return true;
+}
+
+template 
+inline
+bool
+operator!=(const malloc_alloc& x, const malloc_alloc& y) noexcept
+{
+return !(x == y);
+}
+
+const size_t bs = 4 * 1024;
+template  using Alloc = short_alloc;
+template  using Vector = std::vector>;
+
+template 
+struct string_pair
+{
+StrT first;
+StrT second;
+
+string_pair() = default;
+string_pair(StrT f) : first(std::move(f)) {}
+string_pair(StrT f, StrT s)
+: first(std::move(f)), second(std::move(s)) {}
+template 
+string_pair(const char (&s)[N]) : first(s, N-1) {}
+
+size_t size() const {return first.size() + second.size();}
+bool empty() const { return first.empty() && second.empty(); }
+StrT full() const {return first + second;}
+StrT move_full() {return std::move(first) + std::move(second);}
+};
+
+struct Db
+{
+typedef std::basic_string,
+  malloc_alloc> String;
+typedef Vector

[libcxxabi] r307482 - [Demangler] NFC: Don't make the parse_* functions templates

2017-07-08 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Sat Jul  8 11:54:08 2017
New Revision: 307482

URL: http://llvm.org/viewvc/llvm-project?rev=307482&view=rev
Log:
[Demangler] NFC: Don't make the parse_* functions templates

Differential revision: https://reviews.llvm.org/D35158

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=307482&r1=307481&r2=307482&view=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Sat Jul  8 11:54:08 2017
@@ -41,23 +41,6 @@ enum
 success
 };
 
-template 
-const char* parse_type(const char* first, const char* last, C& db);
-template 
-const char* parse_encoding(const char* first, const char* last, C& db);
-template 
-const char* parse_name(const char* first, const char* last, C& db,
-   bool* ends_with_template_args = 0);
-template 
-const char* parse_expression(const char* first, const char* last, C& db);
-template 
-const char* parse_template_args(const char* first, const char* last, C& 
db);
-template 
-const char* parse_operator_name(const char* first, const char* last, C& 
db);
-template 
-const char* parse_unqualified_name(const char* first, const char* last, C& 
db);
-template 
-const char* parse_decltype(const char* first, const char* last, C& db);
 template 
 class arena
 {
@@ -265,6 +248,17 @@ struct Db
 {}
 };
 
+
+const char* parse_type(const char* first, const char* last, Db& db);
+const char* parse_encoding(const char* first, const char* last, Db& db);
+const char* parse_name(const char* first, const char* last, Db& db,
+   bool* ends_with_template_args = 0);
+const char* parse_expression(const char* first, const char* last, Db& db);
+const char* parse_template_args(const char* first, const char* last, Db& db);
+const char* parse_operator_name(const char* first, const char* last, Db& db);
+const char* parse_unqualified_name(const char* first, const char* last, Db& 
db);
+const char* parse_decltype(const char* first, const char* last, Db& db);
+
 template 
 void
 print_stack(const C& db)
@@ -384,9 +378,9 @@ struct float_data
 
 constexpr const char* float_data::spec;
 
-template 
+template 
 const char*
-parse_floating_number(const char* first, const char* last, C& db)
+parse_floating_number(const char* first, const char* last, Db& db)
 {
 const size_t N = float_data::mangled_size;
 if (static_cast(last - first) > N)
@@ -419,7 +413,7 @@ parse_floating_number(const char* first,
 int n = snprintf(num, sizeof(num), float_data::spec, value);
 if (static_cast(n) >= sizeof(num))
 return first;
-db.names.push_back(typename C::String(num, 
static_cast(n)));
+db.names.push_back(Db::String(num, static_cast(n)));
 first = t+1;
 }
 }
@@ -428,9 +422,8 @@ parse_floating_number(const char* first,
 
 //  ::=  
 
-template 
 const char*
-parse_source_name(const char* first, const char* last, C& db)
+parse_source_name(const char* first, const char* last, Db& db)
 {
 if (first != last)
 {
@@ -447,7 +440,7 @@ parse_source_name(const char* first, con
 }
 if (static_cast(last - t) >= n)
 {
-typename C::String r(t, n);
+Db::String r(t, n);
 if (r.substr(0, 10) == "_GLOBAL__N")
 db.names.push_back("(anonymous namespace)");
 else
@@ -470,9 +463,8 @@ parse_source_name(const char* first, con
 //  ::= So # ::std::basic_ostream >
 //  ::= Sd # ::std::basic_iostream >
 
-template 
 const char*
-parse_substitution(const char* first, const char* last, C& db)
+parse_substitution(const char* first, const char* last, Db& db)
 {
 if (last - first >= 2)
 {
@@ -578,9 +570,8 @@ parse_substitution(const char* first, co
 //::= Dn   # std::nullptr_t (i.e., decltype(nullptr))
 //::= u # vendor extended type
 
-template 
 const char*
-parse_builtin_type(const char* first, const char* last, C& db)
+parse_builtin_type(const char* first, const char* last, Db& db)
 {
 if (first != last)
 {
@@ -756,9 +747,8 @@ parse_cv_qualifiers(const char* first, c
 //  ::= T_# first template parameter
 //  ::= T  _
 
-template 
 const char*
-parse_template_param(const char* first, const char* last, C& db)
+parse_template_param(const char* first, const char* last, Db& db)
 {
 if (last - first >= 2)
 {
@@ -801,7 +791,7 @@ parse_template_param(const char* first,
 }
 else
 {
-db.names.push_back(typename C::String(first, t+1));
+db.names.push_back(Db::String(first, t+1));
 first = t+1;
 db.fix_forward_r

r307483 - Fix build failure with gcc about mixing enum and non-enum

2017-07-08 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Sat Jul  8 12:13:41 2017
New Revision: 307483

URL: http://llvm.org/viewvc/llvm-project?rev=307483&view=rev
Log:
Fix build failure with gcc about mixing enum and non-enum

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=307483&r1=307482&r2=307483&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sat Jul  8 12:13:41 2017
@@ -2432,7 +2432,8 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
 
   auto ExpectedAS =
   D ? D->getType().getAddressSpace()
-: (LangOpts.OpenCL ? LangAS::opencl_global : LangAS::Default);
+: static_cast(LangOpts.OpenCL ? LangAS::opencl_global
+: LangAS::Default);
   assert(getContext().getTargetAddressSpace(ExpectedAS) ==
  Ty->getPointerAddressSpace());
   if (AddrSpace != ExpectedAS)
@@ -2574,7 +2575,8 @@ CharUnits CodeGenModule::GetTargetTypeSt
 unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) {
   unsigned AddrSpace;
   if (LangOpts.OpenCL) {
-AddrSpace = D ? D->getType().getAddressSpace() : LangAS::opencl_global;
+AddrSpace = D ? D->getType().getAddressSpace()
+  : static_cast(LangAS::opencl_global);
 assert(AddrSpace == LangAS::opencl_global ||
AddrSpace == LangAS::opencl_constant ||
AddrSpace == LangAS::opencl_local ||

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=307483&r1=307482&r2=307483&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Sat Jul  8 12:13:41 2017
@@ -421,7 +421,8 @@ unsigned TargetCodeGenInfo::getGlobalVar
   assert(!CGM.getLangOpts().OpenCL &&
  !(CGM.getLangOpts().CUDA && CGM.getLangOpts().CUDAIsDevice) &&
  "Address space agnostic languages only");
-  return D ? D->getType().getAddressSpace() : LangAS::Default;
+  return D ? D->getType().getAddressSpace()
+   : static_cast(LangAS::Default);
 }
 
 llvm::Value *TargetCodeGenInfo::performAddrSpaceCast(


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