]> granicus.if.org Git - clang/commitdiff
Revert r225085, it caused PR22096.
authorNico Weber <nicolasweber@gmx.de>
Wed, 7 Jan 2015 18:23:08 +0000 (18:23 +0000)
committerNico Weber <nicolasweber@gmx.de>
Wed, 7 Jan 2015 18:23:08 +0000 (18:23 +0000)
PR22096 has several test cases that assert that look fairly different. I'm
adding one of those as an automated test, but when relanding the other cases
should probably be checked as well.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225361 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCall.cpp
lib/CodeGen/CGDebugInfo.h
test/CodeGenCXX/crash.cpp

index f9b26b621036fe0135751bdafbd4958220ba4136..6403fa99aa7bb7766d38bea76ff69c8629ee4936 100644 (file)
@@ -2680,6 +2680,10 @@ void CodeGenFunction::EmitCallArgs(CallArgList &Args,
                                    const FunctionDecl *CalleeDecl,
                                    unsigned ParamsToSkip,
                                    bool ForceColumnInfo) {
+  CGDebugInfo *DI = getDebugInfo();
+  SourceLocation CallLoc;
+  if (DI) CallLoc = DI->getLocation();
+
   // We *have* to evaluate arguments from right to left in the MS C++ ABI,
   // because arguments are destroyed left to right in the callee.
   if (CGM.getTarget().getCXXABI().areArgsDestroyedLeftToRightInCallee()) {
@@ -2700,6 +2704,8 @@ void CodeGenFunction::EmitCallArgs(CallArgList &Args,
       EmitCallArg(Args, *Arg, ArgTypes[I]);
       emitNonNullArgCheck(*this, Args.back().RV, ArgTypes[I], Arg->getExprLoc(),
                           CalleeDecl, ParamsToSkip + I);
+      // Restore the debug location.
+      if (DI) DI->EmitLocation(Builder, CallLoc, ForceColumnInfo);
     }
 
     // Un-reverse the arguments we just evaluated so they match up with the LLVM
@@ -2714,6 +2720,8 @@ void CodeGenFunction::EmitCallArgs(CallArgList &Args,
     EmitCallArg(Args, *Arg, ArgTypes[I]);
     emitNonNullArgCheck(*this, Args.back().RV, ArgTypes[I], Arg->getExprLoc(),
                         CalleeDecl, ParamsToSkip + I);
+    // Restore the debug location.
+    if (DI) DI->EmitLocation(Builder, CallLoc, ForceColumnInfo);
   }
 }
 
index 8422a1f8e37f86821803243aa3f93a4debc3fa51..0be032c1d790e5a6001c259c7639dedc8746de0f 100644 (file)
@@ -222,6 +222,9 @@ public:
   /// invalid it is ignored.
   void setLocation(SourceLocation Loc);
 
+  /// getLocation - Return the current source location.
+  SourceLocation getLocation() const { return CurLoc; }
+
   /// EmitLocation - Emit metadata to indicate a change in line/column
   /// information in the source file.
   /// \param ForceColumnInfo  Assume DebugColumnInfo option is true.
index 073542dd15b0e2b222118118b6892701b7079bec..a4f6ec6a42e8d56aa1810b242eedb9fff8f16c7f 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -std=c++11 -emit-llvm-only
+// RUN: %clang_cc1 -emit-obj -o %t -gline-tables-only -O2 -std=c++11 %s
 // CHECK that we don't crash.
 
 // PR11676's example is ill-formed:
@@ -33,3 +34,28 @@ template <class ELFT> void finalizeDefaultAtomValues() {
 
 void f() { finalizeDefaultAtomValues<int>(); }
 }
+
+namespace PR22096 {
+class _String_val {
+  union _Bxty { int i; } _Bx;
+};
+struct string : public _String_val {
+  string(const char *_Ptr) : _String_val() {}
+};
+
+
+int ConvertIPv4NumberToIPv6Number(int);
+struct IPEndPoint {
+  IPEndPoint();
+  IPEndPoint(const int &address, int port);
+  const int &address() const {}
+};
+
+struct SourceAddressTokenTest {
+  SourceAddressTokenTest()
+      : ip4_dual_(ConvertIPv4NumberToIPv6Number(ip4_.address()), 1) {}
+  const string kPrimary = "<primary>";
+  IPEndPoint ip4_;
+  IPEndPoint ip4_dual_;
+} s;
+}