[cfe-commits] r39631 - in /cfe/cfe/trunk/include/clang/Parse: AttributeList.h DeclSpec.h

Steve Naroff snaroff at apple.com
Wed Jul 11 09:46:27 PDT 2007


Author: snaroff
Date: Wed Jul 11 11:46:26 2007
New Revision: 39631

URL: http://llvm.org/viewvc/llvm-project?rev=39631&view=rev
Log:
Bug #:
Submitted by:
Reviewed by:
Incorporate some feedback from Chris.
Fixed a crasher, added an assert.

Modified:
    cfe/cfe/trunk/include/clang/Parse/AttributeList.h
    cfe/cfe/trunk/include/clang/Parse/DeclSpec.h

Modified: cfe/cfe/trunk/include/clang/Parse/AttributeList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Parse/AttributeList.h?rev=39631&r1=39630&r2=39631&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/AttributeList.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/AttributeList.h Wed Jul 11 11:46:26 2007
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// This file defines the AttributeList class interface
+// This file defines the AttributeList class interface.
 //
 //===----------------------------------------------------------------------===//
 
@@ -15,11 +15,10 @@
 #define LLVM_CLANG_ATTRLIST_H
 
 #include "clang/Parse/Action.h"
-#include <assert.h>
+#include <cassert>
 
 namespace llvm {
 namespace clang {
-class IdentifierInfo;
 
 /// AttributeList - Represents GCC's __attribute__ declaration. There are
 /// 4 forms of this construct...they are:
@@ -52,6 +51,7 @@
   void setNext(AttributeList *N) { Next = N; }
   
   void addAttributeList(AttributeList *alist) {
+    assert((alist != 0) && "addAttributeList(): alist is null");
     AttributeList *next = this, *prev;
     do {
       prev = next;

Modified: cfe/cfe/trunk/include/clang/Parse/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=39631&r1=39630&r2=39631&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/DeclSpec.h Wed Jul 11 11:46:26 2007
@@ -220,7 +220,9 @@
   bool SetFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec);
   
   /// attributes
-  void AddAttribute(AttributeList *alist) { 
+  void AddAttribute(AttributeList *alist) {
+    if (!alist)
+      return; // we parsed __attribute__(()) or had a syntax error
     if (AttrList) 
       alist->addAttributeList(AttrList); 
     AttrList = alist;
@@ -514,6 +516,8 @@
   
   /// attributes
   void AddAttribute(AttributeList *alist) { 
+    if (!alist)
+      return; // we parsed __attribute__(()) or had a syntax error
     if (AttrList) 
       alist->addAttributeList(AttrList); 
     AttrList = alist;





More information about the cfe-commits mailing list