[clang] 03a9526 - [CGExprAgg] Fix infinite loop in `findPeephole`

2020-04-16 Thread Ehud Katz via cfe-commits

Author: Ehud Katz
Date: 2020-04-16T13:26:23+03:00
New Revision: 03a9526fe5adae909f1d5fd2736703e69fc46e09

URL: 
https://github.com/llvm/llvm-project/commit/03a9526fe5adae909f1d5fd2736703e69fc46e09
DIFF: 
https://github.com/llvm/llvm-project/commit/03a9526fe5adae909f1d5fd2736703e69fc46e09.diff

LOG: [CGExprAgg] Fix infinite loop in `findPeephole`

Simplify the function using IgnoreParenNoopCasts.

Fix PR45476

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

Added: 
clang/test/CodeGen/pr45476.cpp

Modified: 
clang/lib/CodeGen/CGExprAgg.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index fa2d228b7eeb..90d4f7e4e096 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -677,17 +677,13 @@ 
AggExprEmitter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
 
 /// Attempt to look through various unimportant expressions to find a
 /// cast of the given kind.
-static Expr *findPeephole(Expr *op, CastKind kind) {
-  while (true) {
-op = op->IgnoreParens();
-if (CastExpr *castE = dyn_cast(op)) {
-  if (castE->getCastKind() == kind)
-return castE->getSubExpr();
-  if (castE->getCastKind() == CK_NoOp)
-continue;
-}
-return nullptr;
+static Expr *findPeephole(Expr *op, CastKind kind, const ASTContext &ctx) {
+  op = op->IgnoreParenNoopCasts(ctx);
+  if (auto castE = dyn_cast(op)) {
+if (castE->getCastKind() == kind)
+  return castE->getSubExpr();
   }
+  return nullptr;
 }
 
 void AggExprEmitter::VisitCastExpr(CastExpr *E) {
@@ -776,7 +772,8 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) {
   (isToAtomic ? CK_AtomicToNonAtomic : CK_NonAtomicToAtomic);
 
 // These two cases are reverses of each other; try to peephole them.
-if (Expr *op = findPeephole(E->getSubExpr(), peepholeTarget)) {
+if (Expr *op =
+findPeephole(E->getSubExpr(), peepholeTarget, CGF.getContext())) {
   assert(CGF.getContext().hasSameUnqualifiedType(op->getType(),
  E->getType()) &&
"peephole significantly changed types?");

diff  --git a/clang/test/CodeGen/pr45476.cpp b/clang/test/CodeGen/pr45476.cpp
new file mode 100644
index ..61f3f3649986
--- /dev/null
+++ b/clang/test/CodeGen/pr45476.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// PR45476
+
+// This test used to get into an infinite loop,
+// which, in turn, caused clang to never finish execution.
+
+struct s3 {
+  char a, b, c;
+};
+
+_Atomic struct s3 a;
+
+extern "C" void foo() {
+  // CHECK-LABEL: @foo
+  // CHECK: store atomic i32
+
+  a = s3{1, 2, 3};
+}
+



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


[clang] c5fb73c - [APFloat] Add recoverable string parsing errors to APFloat

2020-01-06 Thread Ehud Katz via cfe-commits

Author: Ehud Katz
Date: 2020-01-06T10:09:01+02:00
New Revision: c5fb73c5d1b3f1adb77d99fc85c594b48bff08f9

URL: 
https://github.com/llvm/llvm-project/commit/c5fb73c5d1b3f1adb77d99fc85c594b48bff08f9
DIFF: 
https://github.com/llvm/llvm-project/commit/c5fb73c5d1b3f1adb77d99fc85c594b48bff08f9.diff

LOG: [APFloat] Add recoverable string parsing errors to APFloat

Implementing the APFloat part in PR4745.

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

Added: 


Modified: 
clang/lib/Lex/LiteralSupport.cpp
llvm/include/llvm/ADT/APFloat.h
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/Support/APFloat.cpp
llvm/lib/Support/StringRef.cpp
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
llvm/unittests/ADT/APFloatTest.cpp

Removed: 




diff  --git a/clang/lib/Lex/LiteralSupport.cpp 
b/clang/lib/Lex/LiteralSupport.cpp
index 2108408377fb..66309183a144 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -1051,7 +1051,10 @@ NumericLiteralParser::GetFloatValue(llvm::APFloat 
&Result) {
 Str = Buffer;
   }
 
-  return Result.convertFromString(Str, APFloat::rmNearestTiesToEven);
+  auto StatusOrErr =
+  Result.convertFromString(Str, APFloat::rmNearestTiesToEven);
+  assert(StatusOrErr && "Invalid floating point representation");
+  return StatusOrErr ? *StatusOrErr : APFloat::opInvalidOp;
 }
 
 static inline bool IsExponentPart(char c) {

diff  --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h
index afeed67e3f9e..e415054fc024 100644
--- a/llvm/include/llvm/ADT/APFloat.h
+++ b/llvm/include/llvm/ADT/APFloat.h
@@ -38,6 +38,7 @@ class StringRef;
 class APFloat;
 class raw_ostream;
 
+template  class Expected;
 template  class SmallVectorImpl;
 
 /// Enum that represents what fraction of the LSB truncated bits of an fp 
number
@@ -299,7 +300,7 @@ class IEEEFloat final : public APFloatBase {
   bool, roundingMode);
   opStatus convertFromZeroExtendedInteger(const integerPart *, unsigned int,
   bool, roundingMode);
-  opStatus convertFromString(StringRef, roundingMode);
+  Expected convertFromString(StringRef, roundingMode);
   APInt bitcastToAPInt() const;
   double convertToDouble() const;
   float convertToFloat() const;
@@ -525,8 +526,8 @@ class IEEEFloat final : public APFloatBase {
 bool *) const;
   opStatus convertFromUnsignedParts(const integerPart *, unsigned int,
 roundingMode);
-  opStatus convertFromHexadecimalString(StringRef, roundingMode);
-  opStatus convertFromDecimalString(StringRef, roundingMode);
+  Expected convertFromHexadecimalString(StringRef, roundingMode);
+  Expected convertFromDecimalString(StringRef, roundingMode);
   char *convertNormalToHexString(char *, unsigned int, bool,
  roundingMode) const;
   opStatus roundSignificandWithExponent(const integerPart *, unsigned int, int,
@@ -648,7 +649,7 @@ class DoubleAPFloat final : public APFloatBase {
   cmpResult compare(const DoubleAPFloat &RHS) const;
   bool bitwiseIsEqual(const DoubleAPFloat &RHS) const;
   APInt bitcastToAPInt() const;
-  opStatus convertFromString(StringRef, roundingMode);
+  Expected convertFromString(StringRef, roundingMode);
   opStatus next(bool nextDown);
 
   opStatus convertToInteger(MutableArrayRef Input,
@@ -1108,7 +1109,7 @@ class APFloat : public APFloatBase {
 APFLOAT_DISPATCH_ON_SEMANTICS(
 convertFromZeroExtendedInteger(Input, InputSize, IsSigned, RM));
   }
-  opStatus convertFromString(StringRef, roundingMode);
+  Expected convertFromString(StringRef, roundingMode);
   APInt bitcastToAPInt() const {
 APFLOAT_DISPATCH_ON_SEMANTICS(bitcastToAPInt());
   }

diff  --git a/llvm/lib/MC/MCParser/AsmParser.cpp 
b/llvm/lib/MC/MCParser/AsmParser.cpp
index 82318d081c9a..0c4eb953aa4e 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -3130,8 +3130,7 @@ bool AsmParser::parseRealValue(const fltSemantics 
&Semantics, APInt &Res) {
   Value = APFloat::getNaN(Semantics, false, ~0);
 else
   return TokError("invalid floating point literal");
-  } else if (Value.convertFromString(IDVal, APFloat::rmNearestTiesToEven) ==
- APFloat::opInvalidOp)
+  } else if (!Value.convertFromString(IDVal, APFloat::rmNearestTiesToEven))
 return TokError("invalid floating point literal");
   if (IsNeg)
 Value.changeSign();

diff  --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index c7500acaa729..f6999a6f236d 100644
--- a/llvm/lib/Support/APFloat.cpp
+++ b/llvm/lib/Support/APFloat.cpp
@@ -20,7 +20,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Support/Debug.h"
-#include "ll

[clang-tools-extra] f3f7dc3 - [APFloat] Fix compilation warnings

2020-01-06 Thread Ehud Katz via cfe-commits

Author: Ehud Katz
Date: 2020-01-06T11:30:40+02:00
New Revision: f3f7dc3d2990151a78b246a7a1485d0c13a9fb36

URL: 
https://github.com/llvm/llvm-project/commit/f3f7dc3d2990151a78b246a7a1485d0c13a9fb36
DIFF: 
https://github.com/llvm/llvm-project/commit/f3f7dc3d2990151a78b246a7a1485d0c13a9fb36.diff

LOG: [APFloat] Fix compilation warnings

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
clang/lib/Lex/LiteralSupport.cpp
llvm/lib/Support/APFloat.cpp
llvm/lib/Support/StringRef.cpp
llvm/unittests/ADT/APFloatTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
index 64806cee37ef..231e565f27e5 100644
--- a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
@@ -86,11 +86,15 @@ MagicNumbersCheck::MagicNumbersCheck(StringRef Name, 
ClangTidyContext *Context)
 IgnoredDoublePointValues.reserve(IgnoredFloatingPointValuesInput.size());
 for (const auto &InputValue : IgnoredFloatingPointValuesInput) {
   llvm::APFloat FloatValue(llvm::APFloat::IEEEsingle());
-  FloatValue.convertFromString(InputValue, DefaultRoundingMode);
+  if (!FloatValue.convertFromString(InputValue, DefaultRoundingMode)) {
+assert(false && "Invalid floating point representation");
+  }
   IgnoredFloatingPointValues.push_back(FloatValue.convertToFloat());
 
   llvm::APFloat DoubleValue(llvm::APFloat::IEEEdouble());
-  DoubleValue.convertFromString(InputValue, DefaultRoundingMode);
+  if (!DoubleValue.convertFromString(InputValue, DefaultRoundingMode)) {
+assert(false && "Invalid floating point representation");
+  }
   IgnoredDoublePointValues.push_back(DoubleValue.convertToDouble());
 }
 llvm::sort(IgnoredFloatingPointValues.begin(),

diff  --git a/clang/lib/Lex/LiteralSupport.cpp 
b/clang/lib/Lex/LiteralSupport.cpp
index 66309183a144..5881852b1424 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -1053,8 +1053,11 @@ NumericLiteralParser::GetFloatValue(llvm::APFloat 
&Result) {
 
   auto StatusOrErr =
   Result.convertFromString(Str, APFloat::rmNearestTiesToEven);
-  assert(StatusOrErr && "Invalid floating point representation");
-  return StatusOrErr ? *StatusOrErr : APFloat::opInvalidOp;
+  if (!StatusOrErr) {
+assert(false && "Invalid floating point representation");
+return APFloat::opInvalidOp;
+  }
+  return *StatusOrErr;
 }
 
 static inline bool IsExponentPart(char c) {

diff  --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index f6999a6f236d..d26c5e6cd2e6 100644
--- a/llvm/lib/Support/APFloat.cpp
+++ b/llvm/lib/Support/APFloat.cpp
@@ -4511,7 +4511,9 @@ hash_code hash_value(const APFloat &Arg) {
 APFloat::APFloat(const fltSemantics &Semantics, StringRef S)
 : APFloat(Semantics) {
   auto StatusOrErr = convertFromString(S, rmNearestTiesToEven);
-  assert(StatusOrErr && "Invalid floating point representation");
+  if (!StatusOrErr) {
+assert(false && "Invalid floating point representation");
+  }
 }
 
 APFloat::opStatus APFloat::convert(const fltSemantics &ToSemantics,

diff  --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp
index 4142d130d519..b5db172cc1a3 100644
--- a/llvm/lib/Support/StringRef.cpp
+++ b/llvm/lib/Support/StringRef.cpp
@@ -590,7 +590,7 @@ bool StringRef::getAsDouble(double &Result, bool 
AllowInexact) const {
   APFloat F(0.0);
   auto ErrOrStatus = F.convertFromString(*this, APFloat::rmNearestTiesToEven);
   if (!ErrOrStatus) {
-assert("Invalid floating point representation");
+assert(false && "Invalid floating point representation");
 return true;
   }
 

diff  --git a/llvm/unittests/ADT/APFloatTest.cpp 
b/llvm/unittests/ADT/APFloatTest.cpp
index 927e1fe13671..db529a094c37 100644
--- a/llvm/unittests/ADT/APFloatTest.cpp
+++ b/llvm/unittests/ADT/APFloatTest.cpp
@@ -666,26 +666,12 @@ TEST(APFloatTest, Zero) {
 TEST(APFloatTest, DecimalStringsWithoutNullTerminators) {
   // Make sure that we can parse strings without null terminators.
   // rdar://14323230.
-  APFloat Val(APFloat::IEEEdouble());
-  Val.convertFromString(StringRef("0.00", 3),
-llvm::APFloat::rmNearestTiesToEven);
-  EXPECT_EQ(Val.convertToDouble(), 0.0);
-  Val.convertFromString(StringRef("0.01", 3),
-llvm::APFloat::rmNearestTiesToEven);
-  EXPECT_EQ(Val.convertToDouble(), 0.0);
-  Val.convertFromString(StringRef("0.09", 3),
-llvm::APFloat::rmNearestTiesToEven);
-  EXPECT_EQ(Val.convertToDouble(), 0.0);
-  Val.convertFromString(StringRef("0.095", 4),
-llvm::APFloat::rmNearestTiesToEven);
-  EXPECT_EQ(Val.convertToDouble(), 0.09);
-  Val.convertFromString(Stri

[clang-tools-extra] 24b326c - [APFloat] Fix checked error assert failures

2020-01-08 Thread Ehud Katz via cfe-commits

Author: Ehud Katz
Date: 2020-01-09T09:42:32+02:00
New Revision: 24b326cc610dfdccdd50bc78505ec228d96c8e7a

URL: 
https://github.com/llvm/llvm-project/commit/24b326cc610dfdccdd50bc78505ec228d96c8e7a
DIFF: 
https://github.com/llvm/llvm-project/commit/24b326cc610dfdccdd50bc78505ec228d96c8e7a.diff

LOG: [APFloat] Fix checked error assert failures

`APFLoat::convertFromString` returns `Expected` result, which must be
"checked" if the LLVM_ENABLE_ABI_BREAKING_CHECKS preprocessor flag is
set.
To mark an `Expected` result as "checked" we must consume the `Error`
within.
In many cases, we are only interested in knowing if an error occured,
without the need to examine the error info. This is achieved, easily,
with the `errorToBool()` API.

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
clang/lib/Lex/LiteralSupport.cpp
llvm/include/llvm/ADT/StringRef.h
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/Support/APFloat.cpp
llvm/lib/Support/StringRef.cpp
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
llvm/unittests/ADT/APFloatTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
index 231e565f27e5..86443a155069 100644
--- a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
@@ -86,15 +86,17 @@ MagicNumbersCheck::MagicNumbersCheck(StringRef Name, 
ClangTidyContext *Context)
 IgnoredDoublePointValues.reserve(IgnoredFloatingPointValuesInput.size());
 for (const auto &InputValue : IgnoredFloatingPointValuesInput) {
   llvm::APFloat FloatValue(llvm::APFloat::IEEEsingle());
-  if (!FloatValue.convertFromString(InputValue, DefaultRoundingMode)) {
-assert(false && "Invalid floating point representation");
-  }
+  auto StatusOrErr =
+  FloatValue.convertFromString(InputValue, DefaultRoundingMode);
+  assert(StatusOrErr && "Invalid floating point representation");
+  consumeError(StatusOrErr.takeError());
   IgnoredFloatingPointValues.push_back(FloatValue.convertToFloat());
 
   llvm::APFloat DoubleValue(llvm::APFloat::IEEEdouble());
-  if (!DoubleValue.convertFromString(InputValue, DefaultRoundingMode)) {
-assert(false && "Invalid floating point representation");
-  }
+  StatusOrErr =
+  DoubleValue.convertFromString(InputValue, DefaultRoundingMode);
+  assert(StatusOrErr && "Invalid floating point representation");
+  consumeError(StatusOrErr.takeError());
   IgnoredDoublePointValues.push_back(DoubleValue.convertToDouble());
 }
 llvm::sort(IgnoredFloatingPointValues.begin(),

diff  --git a/clang/lib/Lex/LiteralSupport.cpp 
b/clang/lib/Lex/LiteralSupport.cpp
index 5881852b1424..9a852141c6ee 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -1053,11 +1053,9 @@ NumericLiteralParser::GetFloatValue(llvm::APFloat 
&Result) {
 
   auto StatusOrErr =
   Result.convertFromString(Str, APFloat::rmNearestTiesToEven);
-  if (!StatusOrErr) {
-assert(false && "Invalid floating point representation");
-return APFloat::opInvalidOp;
-  }
-  return *StatusOrErr;
+  assert(StatusOrErr && "Invalid floating point representation");
+  return !errorToBool(StatusOrErr.takeError()) ? *StatusOrErr
+   : APFloat::opInvalidOp;
 }
 
 static inline bool IsExponentPart(char c) {

diff  --git a/llvm/include/llvm/ADT/StringRef.h 
b/llvm/include/llvm/ADT/StringRef.h
index e87a08f7efff..9bfaaccd953e 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -566,7 +566,8 @@ namespace llvm {
 ///
 /// If \p AllowInexact is false, the function will fail if the string
 /// cannot be represented exactly.  Otherwise, the function only fails
-/// in case of an overflow or underflow.
+/// in case of an overflow or underflow, or an invalid floating point
+/// representation.
 bool getAsDouble(double &Result, bool AllowInexact = true) const;
 
 /// @}

diff  --git a/llvm/lib/MC/MCParser/AsmParser.cpp 
b/llvm/lib/MC/MCParser/AsmParser.cpp
index 0c4eb953aa4e..dc8132b627a6 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -3130,7 +3130,9 @@ bool AsmParser::parseRealValue(const fltSemantics 
&Semantics, APInt &Res) {
   Value = APFloat::getNaN(Semantics, false, ~0);
 else
   return TokError("invalid floating point literal");
-  } else if (!Value.convertFromString(IDVal, APFloat::rmNearestTiesToEven))
+  } else if (errorToBool(
+ Value.convertFromString(IDVal, APFloat::rmNearestTiesToEven)
+ .takeError()))
 return TokError("in

[clang-tools-extra] c63f1b1 - [DeclCXX] Remove unknown external linkage specifications

2019-11-21 Thread Ehud Katz via cfe-commits

Author: Ehud Katz
Date: 2019-11-21T15:23:05+02:00
New Revision: c63f1b160eb68cfac30113f259abae508d8be798

URL: 
https://github.com/llvm/llvm-project/commit/c63f1b160eb68cfac30113f259abae508d8be798
DIFF: 
https://github.com/llvm/llvm-project/commit/c63f1b160eb68cfac30113f259abae508d8be798.diff

LOG: [DeclCXX] Remove unknown external linkage specifications

Partial revert of r372681 "Support for DWARF-5 C++ language tags".

The change introduced new external linkage languages ("C++11" and
"C++14") which not supported in C++.

It also changed the definition of the existing enum to use the DWARF
constants. The problem is that "LinkageSpecDeclBits.Language" (the field
that reserves this enum) is actually defined as 3 bits length
(bitfield), which cannot contain the new DWARF constants. Defining the
enum as integer literals is more appropriate for maintaining valid
values.

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

Added: 


Modified: 
clang-tools-extra/modularize/Modularize.cpp
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/DeclPrinter.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaModule.cpp

Removed: 




diff  --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index 8d48324700e2..1905fdf4e2aa 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -585,8 +585,6 @@ class CollectEntitiesVisitor
   LinkageLabel = "extern \"C\" {}";
   break;
 case LinkageSpecDecl::lang_cxx:
-case LinkageSpecDecl::lang_cxx_11:
-case LinkageSpecDecl::lang_cxx_14:
   LinkageLabel = "extern \"C++\" {}";
   break;
 }

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 19a62acd9051..ce9f0467735d 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -42,7 +42,6 @@
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/iterator_range.h"
-#include "llvm/BinaryFormat/Dwarf.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/PointerLikeTypeTraits.h"
@@ -2758,15 +2757,8 @@ class LinkageSpecDecl : public Decl, public DeclContext {
   /// Represents the language in a linkage specification.
   ///
   /// The values are part of the serialization ABI for
-  /// ASTs and cannot be changed without altering that ABI.  To help
-  /// ensure a stable ABI for this, we choose the DW_LANG_ encodings
-  /// from the dwarf standard.
-  enum LanguageIDs {
-lang_c = llvm::dwarf::DW_LANG_C,
-lang_cxx = llvm::dwarf::DW_LANG_C_plus_plus,
-lang_cxx_11 = llvm::dwarf::DW_LANG_C_plus_plus_11,
-lang_cxx_14 = llvm::dwarf::DW_LANG_C_plus_plus_14
-  };
+  /// ASTs and cannot be changed without altering that ABI.
+  enum LanguageIDs { lang_c = 1, lang_cxx = 2 };
 
 private:
   /// The source location for the extern keyword.

diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index e59792710e75..6b17dd4dde75 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -1011,19 +1011,12 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
 
 void DeclPrinter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
   const char *l;
-  switch (D->getLanguage()) {
-  case LinkageSpecDecl::lang_c:
+  if (D->getLanguage() == LinkageSpecDecl::lang_c)
 l = "C";
-break;
-  case LinkageSpecDecl::lang_cxx_14:
-l = "C++14";
-break;
-  case LinkageSpecDecl::lang_cxx_11:
-l = "C++11";
-break;
-  case LinkageSpecDecl::lang_cxx:
+  else {
+assert(D->getLanguage() == LinkageSpecDecl::lang_cxx &&
+   "unknown language in linkage specification");
 l = "C++";
-break;
   }
 
   Out << "extern \"" << l << "\" ";

diff  --git a/clang/lib/AST/JSONNodeDumper.cpp 
b/clang/lib/AST/JSONNodeDumper.cpp
index 6d5912e5a07c..274cc25b8bb8 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -878,12 +878,6 @@ void JSONNodeDumper::VisitLinkageSpecDecl(const 
LinkageSpecDecl *LSD) {
   switch (LSD->getLanguage()) {
   case LinkageSpecDecl::lang_c: Lang = "C"; break;
   case LinkageSpecDecl::lang_cxx: Lang = "C++"; break;
-  case LinkageSpecDecl::lang_cxx_11:
-Lang = "C++11";
-break;
-  case LinkageSpecDecl::lang_cxx_14:
-Lang = "C++14";
-break;
   }
   JOS.attribute("language", Lang);
   attributeOnlyIfTrue("hasBraces", LSD->hasBraces());

diff  --git a/clang/lib/AST/TextNodeDumper.cpp 
b/clang/lib/AST/TextNodeDumper.cpp
index 987910da24a9..0ff95213118f 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -1769,12 +1769,6 @@ void TextNodeDumper::VisitLinkageSpecDecl(const 
LinkageSpecDecl *D) {